<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Font.font will, on Windows, use
    IDWriteFontCollection::FindFamilyName(..)<br>
    The docs for that appear to be silent on whether the matching
    process will check all localized names,<br>
    but it sounds like it must not.  I don't see an alternative look up
    API, such as one that accepts a locale arg.<br>
    <br>
<a class="moz-txt-link-freetext" href="https://learn.microsoft.com/en-us/windows/win32/api/dwrite/nn-dwrite-idwritefontcollection">https://learn.microsoft.com/en-us/windows/win32/api/dwrite/nn-dwrite-idwritefontcollection</a>
    <p>It seems like the app (which in this case means the FX
      implementation) will have to do this itself which is going to be
      tedious.</p>
    <p>We would need to compare with every localized name of every font
      on the system looking for a match.</p>
    <p>And one annoying aspect of this is that until you've done that
      exhaustive search you don't<br>
      know if the name the application supplied is present at all on the
      system.</p>
    <p>How would you know that someone mis-spelled Arial as Ariel and
      not that Ariel is the German localized name for Arial ?</p>
    <p>So failed lookups will be slow.</p>
    <p>In Java 2D we already do this but I'd have hoped DW used by FX
      was better than this than GDI used by 2D.</p>
    Also note that<br>
    (1) fixing this for DW wouldn't help Linux or Mac so there'd need to
    be separate implementations if they also don't do it automatically<br>
    (2) There isn't any FX API which lets you enumerate or access
    localized names, so as you note, that also is an issue.<br>
    Although I'm actually a little surprised FX finds 幼圆 but reports
    YouYuan. I would have thought it would be consistent.<br>
    <br>
    I'm also a little surprised that it has taken this long for anyone
    to even implicitly ask for FX to support localized font names.<br>
    Java2D has had this support for a very long time.<br>
    <br>
    -phil.<br>
    <br>
    <div class="moz-cite-prefix">On 7/12/25 4:18 AM, Glavo wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAJL5A3mpGTi02Oppab3ZjbHx4Feuq8kjuNgJNeYWD-TyiamUFA@mail.gmail.com">
      
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div>Hi,</div>
            <div><br>
            </div>
            <div>We recently noticed a problem: For fonts with localized
              names, <font face="monospace">Font.font(String)</font>
              can only find the font based on the localized name in the
              current locale.</div>
            <div><br>
            </div>
            <div>For example, the Chinese version of Windows comes with
              a font called "YouYuan", and its Chinese name is "幼圆".</div>
            <div>When the system language is Chinese, JavaFX has the
              following behaviors:</div>
            <div><br>
            </div>
          </div>
          <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
            <div dir="ltr">
              <div><font face="monospace">jshell>
                  Font.font("YouYuan")<br>
                  $2 ==> Font[name=System Regular, family=System,
                  style=Regular, size=13.333333015441895]<br>
                  <br>
                  jshell> Font.font("幼圆")<br>
                  $3 ==> Font[name=YouYuan, family=YouYuan,
                  style=Regular, size=13.333333015441895]<br>
                  <br>
                  jshell> $3.getFamily()<br>
                  $4 ==> "YouYuan"</font></div>
            </div>
          </blockquote>
          <br>
          <div>As you can see, we cannot find the font based on the
            English name, we can only use the Chinese name.</div>
          <div>But <font face="monospace">Font::getName()</font>
            returns the English name, so we can't get the Chinese name
            from the <font face="monospace">Font</font>.</div>
          <div>This makes it impossible to generate a style sheet based
            on a <font face="monospace">Font</font><font face="arial, sans-serif"> object, </font>because </div>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div dir="ltr">
            <div><font face="monospace">"-fx-font-family:
                \"%s\";".formatted(font.getFamily())</font></div>
          </div>
        </blockquote>
        <div dir="ltr">
          <div>will not work with these fonts.</div>
          <div><br>
          </div>
          <div>The only workaround I can think of is to generate a
            mapping table from English names to Chinese names like this:</div>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div dir="ltr">
            <div><font face="monospace"><br>
              </font></div>
            <div><font face="monospace">Font.getFamilies().stream().collect(Collectors.toMap(it
                -> Font.font(it).getFamily(), Function.identity()))</font></div>
          </div>
        </blockquote>
        <div dir="ltr">
          <div><br>
          </div>
          <div>But this seems like a lot of overhead :( </div>
          <div><br>
          </div>
          <div>So, I want JavaFX to provide the following features:</div>
          <div>
            <ol>
              <li>Regardless of the current system language, <font face="monospace">Font.font(String)</font> should be
                able to find the font by its English name;</li>
              <li>Provide a new method <font face="monospace">Font::getLocalizedFamily()</font>
                to get the localized name of the font.</li>
            </ol>
          </div>
          <div>Glavo</div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>