SUMMARY Bitmap fonts in BDF format comes in separate files per font size. When using fontconfig to select font files in KoFontRegistry::facesForCSSValues, the code is unable to pick the correct font file for the specified font size. STEPS TO REPRODUCE 1. Install "WenQuanYi Bitmap Song" from https://sourceforge.net/projects/wqy/files/wqy-bitmapfont/1.0.0-RC1/ (on Windows, extract BDF files into `%LocalAppData%\Microsoft\Windows\Fonts`) 2. Create a file at 72 ppi, switch to 100% or 200% zoom 3. Create a text shape with the following SVG: ```svg <text style="fill:#000000; letter-spacing:0; font-family:WenQuanYi Bitmap Song; font-size:12; stroke-width:0"><tspan x="0">佔位文字 Testing </tspan><tspan x="0" dy="20" style="font-style:italic;">佔位文字 Testing</tspan></text> ``` 4. Save the text and observe the result 5. Change font-size to 16 6 Save the text and observe the result OBSERVED RESULT At font-size 12, the two lines of text incorrectly use different font sizes: first line uses 9pt (12px); second line uses 10pt (13px). At font-size 16, the two lines still use the same font size as before. EXPECTED RESULT Font-size 12 should be using 9pt (12px) `wenquanyi_9pt.bdf`. Font-size 16 should be using 12pt (16px) `wenquanyi_12pt.bdf`. SOFTWARE/OS VERSIONS Windows: 10 Base commit is 57d5a2c958
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1893
Git commit 46cf97a60952a5b610e10364690438dd2d0064e6 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier. Committed on 09/08/2023 at 13:42. Pushed by woltherav into branch 'master'. Fix BDF font-size matching. This actually works around a bug in font config that always seems to consider 10pt the primary match for sizes above 12, but skipping over this primary match does lead to the font not being considered for fallback. M +17 -1 libs/flake/text/KoFontRegistry.cpp https://invent.kde.org/graphics/krita/-/commit/46cf97a60952a5b610e10364690438dd2d0064e6
Git commit c43b7f69385785872aab632d3e257a9dc2bea05e by Alvin Wong, on behalf of Wolthera van Hövell tot Westerflier. Committed on 28/08/2023 at 19:49. Pushed by alvinwong into branch 'krita/5.2'. Fix BDF font-size matching. This actually works around a bug in font config that always seems to consider 10pt the primary match for sizes above 12, but skipping over this primary match does lead to the font not being considered for fallback. (cherry picked from commit 46cf97a60952a5b610e10364690438dd2d0064e6) M +17 -1 libs/flake/text/KoFontRegistry.cpp https://invent.kde.org/graphics/krita/-/commit/c43b7f69385785872aab632d3e257a9dc2bea05e