https://bugs.documentfoundation.org/show_bug.cgi?id=172259
--- Comment #7 from [email protected] --- To fix the issue on my example: in https://git.libreoffice.org/core/+/refs/heads/master/emfio/source/reader/mtftools.cxx In MtfTools::DrawText(), there is this block of code: "else if (nGfxMode == GraphicsMode::GM_COMPATIBLE) {...}" (Currently Line 2101) Replace these lines: const float fTestWidthScale = std::fabs(fYScale / fXScale); // If Width is 0, the font is scaled proportionally based on Height. if (aFontSize.Width() == 0) aFontSize.setWidth(basegfx::fround<tools::Long>(aFontSize.Height() * fTestWidthScale)); else aFontSize.setWidth(basegfx::fround<tools::Long>(aFontSize.Width() * fTestWidthScale)); aTmp.SetFontSize(aFontSize); bChangeFont = true; with these lines: if (aFontSize.Width() != 0) { const float fTestWidthScale = std::fabs(fYScale / fXScale); aFontSize.setWidth(basegfx::fround<tools::Long>(aFontSize.Width() * fTestWidthScale)); aTmp.SetFontSize(aFontSize); bChangeFont = true; } Using my example emf file, fXScale=4.23657703, fYScale=4.23567343 I believe this is a bug introduced in https://git.libreoffice.org/core/+/edf5386fa304fa70bb84d9dc53ad8af49a1da009%5E%21 "EMF Fix font scaling and orientation in GM_COMPATIBLE" Using Microsoft Windows ::CreateFont() / ::CreateFontIndirect(), if the font width is unset (0) then the font width is chosen by the GDI based on the font height. The documentation says "The average width, in logical units, of characters in the font. If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference." Therefore if the font height is 20, and the scale is 1:1, the font width is not 20. Maybe a solution is to create a temporary font, and use GetTextMetrics to obtain tmAveCharWidth. I guess this could have a performance impact. Please note, I do not know how fonts operate within vcl/win/gdi -- You are receiving this mail because: You are the assignee for the bug.
