MIERUNE / qgis-plugx-plugin

QGIS to Illustrator with PlugX
GNU General Public License v2.0
3 stars 0 forks source link

inaccurate calculation in unit conversion to point #124

Open Kanahiro opened 11 months ago

Kanahiro commented 11 months ago

<ラベルのポイント数について> v0.0.9プラグインでエクスポートした際、JSONに書き出されるラベルのサイズが設定値と若干変わってしまうようです。 (例) QGIS設定値 ⇒ JSONの値 7.0pt ⇒ 6.75pt 8.0pt ⇒ 8.25pt 10.0pt ⇒ 9.75pt 2.0mm ⇒ 6.0pt (実際は2mmは約5.7pt) 添付画像は、P_districtsレイヤのラベルが7ptに設定されているところ、JSONでは6.75ptになってしまっているところです。 恐れ入りますが、ご確認をいただけますと幸いです。

bordoray commented 10 months ago

No difference when convert point to point in P_districts

image
bordoray commented 10 months ago

Point to point conversion looks not have problem

mm to pt has small gap To be: 2mm = 5.699 pt

image
bordoray commented 10 months ago

Looks to come directly from "extract label" processing tool. Size in point for 4mm should be 11.338582677 pt.

I am suspecting something wrong to extract label algorithm based on dpi, crs and scale...

image
bordoray commented 10 months ago

Dpi looks to vary depending on dpi here implemented iface.mapCanvas().mapSettings().outputDpi() is 144 Default dpi is set as 96

Label is set as 4mm which is truely 11.338582677 pt image

bordoray commented 10 months ago

size may be calculated as below const double fontSize = static_cast<double>( font.pixelSize() ) * 72 / context.painter()->device()->logicalDpiX(); https://github.com/qgis/QGIS/blob/3a4a9f08bdc7630120ab7a0f55d5f8e68371c50b/src/analysis/processing/qgsalgorithmextractlabels.cpp#L246

Kanahiro commented 10 months ago

We guess why this occurs:

IMO, this is QGIS natural behaivior and not bug. Labels rendered in canvas may be sized in pixel. Then there is no problem inside QGIS.