<div dir="ltr"><font face="arial, sans-serif"><span style="color:rgb(25,27,31)">Thank you for your help</span>. </font><div><font face="arial, sans-serif">I am a new hand on java, you mentioned “Swing implements an implicit fall back for most uses by controls where it is safer to assume<br>they just want to display some glyph”, it means swing </font>implicitly<font face="arial, sans-serif"> uses logical font to fallback?</font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Philip Race <<a href="mailto:philip.race@oracle.com">philip.race@oracle.com</a>> 于2024年1月13日周六 03:10写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
  <div>
    Right. This is on purpose.  We do not want to change that behaviour.<br>
    A font should not lie about what glyphs it contains and provide no
    way for apps<br>
    to know if that is REALLY from this font. Proper text rendering is
    not possible<br>
    if you lie to the app.<br>
    <br>
    JDK on MacOS does things differently because that's the
    implementation we unfortunately inherited<br>
    from Apple. It is a real pain.<br>
    <br>
    Swing implements an implicit fall back for most uses by controls
    where it is safer to assume<br>
    they just want to display some glyph, but a change to do that
    globally for Java 2D is not going to be accepted,<br>
    and even the Swing one causes some problems as there's no way to
    tell it has a fall back.<br>
    <br>
    The fall back to "Dialog" if a font is not found cannot be changed.
    It is specified.<br>
    <br>
<a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#%3Cinit%3E(java.lang.String,int,int)" target="_blank">https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#%3Cinit%3E(java.lang.String,int,int)</a><br>
    <br>
    "<span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline">If
      the<span> </span></span><code style="font-size:14px;padding-top:4px;margin-top:8px;line-height:1.4em;color:rgb(71,71,71);font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">name</code><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span> </span>parameter represents
      something other than a logical font, i.e. is interpreted as a
      physical font face or family, and this cannot be mapped by the
      implementation to a physical font or a compatible alternative,
      then the font system will map the Font instance to "Dialog", such
      that for example, the family as reported by<span> </span></span><a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#getFamily()" style="text-decoration:none;font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank"><code style="padding-top:4px;margin-top:8px;line-height:1.4em">getFamily</code></a><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:left;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration:none;float:none;display:inline"><span> </span>will be "Dialog".<br>
      <br>
    </span>-phil.<br>
    <br>
    <br>
    <div>On 1/12/24 4:56 AM, 林kurn wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>
          <div>Hi everyone, </div>
          <div><br>
          </div>
          <div>I am doing GUI development based on Java on Ubuntu, and I
            find some problems in it.<br>
          </div>
          <div>Would it be possible for me to discuss with you?</div>
          <div><br>
          </div>
          <div>1. There is no fallback font on Windows and Linux when
            using physical fonts.</div>
          <div>The FileFont class does not implements FontSubstitution
            interface, so there are no substituting glyphs from another
            font at render time(in GlyphLayout::layout).</div>
          <div>For example, when "jTextField.setFont(new Font("Ubuntu
            Mono", Font.PLAIN, 20))" on Ubuntu, all the CJK characters
            will show as tofu in this jTextField. Almost every font does
            not contain all possible inputs, adding some fallbacks font
            may help those who don't just use one language.</div>
        </div>
        <div><br>
        </div>
        <div>2. The fonts that JDK does not found are mapped to the
          “Dialog” font.</div>
        <div>As <a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#%3Cinit%3E(java.lang.String,int,int)" target="_blank">https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Font.html#%3Cinit%3E(java.lang.String,int,int)</a>
          shows, If the name parameter represents something other than a
          logical font, i.e. is interpreted as a physical font face or
          family, and this cannot be mapped by the implementation to a
          physical font or a compatible alternative, then the font
          system will map the Font instance to "Dialog".</div>
        <div>On Linux, get map fonts by fontconfig may be more flexible,
          more configurable.<br>
        </div>
        <div><br>
        </div>
        <div>For the two questions above, I have a preliminary patch.<br>
        </div>
        <div><br>
        </div>
        <div><font face="arial, sans-serif" color="#000000">I added a
            new fallback form “FONTCONFIGURATION_FALLBACK”
            and implemented it for Linux system, it c</font>reates a
          composite font by obtaining map fonts info for the specified
          name and style through fontconfig<font face="arial, sans-serif" color="#000000">.</font></div>
        <div>
          <div><font face="arial, sans-serif" color="#000000">And I make
              the FileFont class implement the FontSubstitution
              interface, reuse the </font><span style="color:rgb(0,0,0);font-family:arial,sans-serif">FONTCONFIGURATION_FALLBACK
              code.</span></div>
        </div>
        <div><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br>
          </span></div>
        <div><span style="color:rgb(0,0,0);font-family:arial,sans-serif"><br>
          </span></div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>