Open Yaroslav-Kuznetsov opened 4 years ago
Pretty sure MeasureString
uses MeasureCharacterRanges
. Therefore, it's entirely likely/probable that this is related to https://github.com/mono/libgdiplus/issues/623
Notice the values on Linux are always rounded?
I'm using the System.Drawing.Common NuGet package and the latest version of libgdiplus (v6.0.x). On Windows, increasing the Bitmap resolution increases the accuracy at which the
MeasureCharacterRanges
method calculates text dimensions. On Linux, it actually scales the result which is not correct or expected. Bellow is the code snippet illustrating the difference:Here is the output this code produces:
//win result //image dpi = 300 ; letterBounds = {X=1000,Y=575.4775,Width=14.00451,Height=49.03564} //image dpi = 600 ; letterBounds = {X=1000,Y=575.5,Width=13.5,Height=49}
//linux docker result //image dpi = 300 ; letterBounds = {X=1000,Y=592,Width=5,Height=15} //image dpi = 600 ; letterBounds = {X=2000,Y=1392,Width=5,Height=15}