Menu

#1051 Aggressive Font Fallback doesn't work on Java 11

5.6
closed-fixed
Java11 (2)
5
2021-10-06
2021-06-25
No

When running with Java 11 on macOS 11.4, Aggressive Font Fallback doesn't work even in cases where it does work with Java 8.

It appears that the methods we use to check whether a font supports a codepoint (Font#canDisplay, Font#canDisplayUpTo) always report true or -1 respectively.

There are related reports on the internet but no known fixes or workarounds that I have seen:

Related

Bugs: #1043
Bugs: #994

Discussion

  • Aaron Madlon-Kay

    • labels: --> Java11
     
  • Hiroshi Miura

    Hiroshi Miura - 2021-06-25

    Inspired from Intellij-community(Apache-2.0).

    import java.awt.Font;
    import java.awt.font.FontRenderContext;
    
    import org.omegat.util.Platform;
    import sun.font.CompositeGlyphMapper;
    
        public static FontRenderContext DEFAULT_CONTEXT = new FontRenderContext(null, false, false);
    
        public boolean canDisplay(Font font, final int codePoint) {
            if (!Character.isValidCodePoint(codePoint)) return false;
            if (Platform.isMacOSX()) {
                int glyphCode = font.createGlyphVector(DEFAULT_CONTEXT, new String(new int[]{codePoint}, 0, 1)).getGlyphCode(0);
                return (glyphCode & CompositeGlyphMapper.GLYPHMASK) != 0 && (glyphCode & CompositeGlyphMapper.SLOTMASK) == 0;
            } else {
                return font.canDisplay(codePoint);
            }
       }
    
     
    • Hiroshi Miura

      Hiroshi Miura - 2021-06-26
       
      • Hiroshi Miura

        Hiroshi Miura - 2021-07-01

        Fix merged.

         
  • Aaron Madlon-Kay

    • status: open --> open-fixed
    • assigned_to: Hiroshi Miura
     
  • Aaron Madlon-Kay

    A workaround is implemented in [39e2da]. The workaround attempts to detect when Font#canDisplay is unreliable, and in that case uses a slower, but accurate, codepath. Hence affected systems may see decreased performance of Agressive Font Fallback.

     

    Related

    Commit: [39e2da]

  • Jean-Christophe Helary

    documented in changes.txt

     
  • Aaron Madlon-Kay

    • status: open-fixed --> closed-fixed
     
  • Aaron Madlon-Kay

    Released in OmegaT 5.6.0.

     

Log in to post a comment.