<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>472791</bug_id>
          
          <creation_ts>2023-07-30 08:47:59 +0000</creation_ts>
          <short_desc>Unable to pick correct pixel size of BDF bitmap font</short_desc>
          <delta_ts>2023-08-28 17:50:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>2</classification_id>
          <classification>Applications</classification>
          <product>krita</product>
          <component>Tool/Text</component>
          <version>git master (please specify the git hash!)</version>
          <rep_platform>Microsoft Windows</rep_platform>
          <op_sys>Microsoft Windows</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alvin Wong">alvin</reporter>
          <assigned_to name="Krita Bugs">krita-bugs-null</assigned_to>
          <cc>griffinvalley</cc>
          
          <cf_commitlink>https://invent.kde.org/graphics/krita/-/commit/c43b7f69385785872aab632d3e257a9dc2bea05e</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2243465</commentid>
    <comment_count>0</comment_count>
    <who name="Alvin Wong">alvin</who>
    <bug_when>2023-07-30 08:47:59 +0000</bug_when>
    <thetext>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 &quot;WenQuanYi Bitmap Song&quot; 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
&lt;text style=&quot;fill:#000000; letter-spacing:0; font-family:WenQuanYi Bitmap Song; font-size:12; stroke-width:0&quot;&gt;&lt;tspan x=&quot;0&quot;&gt;佔位文字 Testing
&lt;/tspan&gt;&lt;tspan x=&quot;0&quot; dy=&quot;20&quot; style=&quot;font-style:italic;&quot;&gt;佔位文字 Testing&lt;/tspan&gt;&lt;/text&gt;
```
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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2245213</commentid>
    <comment_count>1</comment_count>
    <who name="Bug Janitor Service">bug-janitor</who>
    <bug_when>2023-08-08 12:50:18 +0000</bug_when>
    <thetext>A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1893</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2245431</commentid>
    <comment_count>2</comment_count>
    <who name="wolthera">griffinvalley</who>
    <bug_when>2023-08-09 11:46:05 +0000</bug_when>
    <thetext>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 &apos;master&apos;.

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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2249066</commentid>
    <comment_count>3</comment_count>
    <who name="Alvin Wong">alvin</who>
    <bug_when>2023-08-28 17:50:57 +0000</bug_when>
    <thetext>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 &apos;krita/5.2&apos;.

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</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>