keeleysam / tenfourfox

Automatically exported from code.google.com/p/tenfourfox
0 stars 0 forks source link

Improve fallback font selection for missing glyphs #149

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
M705594 in Fx13 improves fallback selection, but by using CoreText methods to 
find the desired fonts. I don't know if PhonyCoreText in 10.4 has these 
methods, and more to the point, we can't really deal with a direct CTRef in 
Harfbuzz. So this issue is a scratchpad to think of some better ways.

The current code searches a fixed list of known likely fonts. We should make 
sure this list is complete (gfxPlatformMac::GetCommonFallbackFonts).

Also, in the short term, gfxMacPlatformFontList::GlobalFontFallback should 
simply always search CMAPs, which is no worse than what it's doing now.

Original issue reported on code.google.com by classi...@floodgap.com on 30 Apr 2012 at 5:42

GoogleCodeExporter commented 9 years ago
CMAPs is now permanently on and the fallback font is now defined as an 
ATSFontRef, so we at least have the framework.

Original comment by classi...@floodgap.com on 17 May 2012 at 1:18

GoogleCodeExporter commented 9 years ago
We also need to support FFFD fallback:

gfxFontEntry*
gfxPlatformFontList::SystemFindFontForChar(const PRUint32 aCh,
                                           PRInt32 aRunScript,
                                           const gfxFontStyle* aStyle)
 {
    gfxFontEntry* fontEntry = nsnull;

    // is codepoint with no matching font? return null immediately
    if (mCodepointsWithNoFonts.test(aCh)) {
        return nsnull;
    }

    // try to short-circuit font fallback for U+FFFD, used to represent
    // encoding errors: just use a platform-specific fallback system
    // font that is guaranteed (or at least highly likely) to be around,
    // or a cached family from last time U+FFFD was seen. this helps
    // speed up pages with lots of encoding errors, binary-as-text, etc.
    if (aCh == 0xFFFD && mReplacementCharFallbackFamily.Length() > 0) {
        bool needsBold;  // ignored in the system fallback case

        fontEntry = FindFontForFamily(mReplacementCharFallbackFamily,
                                      aStyle, needsBold);

        if (fontEntry && fontEntry->TestCharacterMap(aCh))
            return fontEntry;
    }

in gfxPlatformFontList.cpp. BY default this should be

mReplacementCharFallbackFamily = NS_LITERAL_STRING("Lucida Grande");

Need to verify this works.

Original comment by classi...@floodgap.com on 5 Jun 2012 at 8:40

GoogleCodeExporter commented 9 years ago
This has improved with issue 195, so I'm dropping priority.

Original comment by classi...@floodgap.com on 12 Jan 2013 at 9:28