Exemplo n.º 1
0
GlyphData FontCascadeFonts::glyphDataForNormalVariant(UChar32 c, const FontDescription& description)
{
    const unsigned pageNumber = c / GlyphPage::size;

    for (unsigned fallbackIndex = 0; true; ++fallbackIndex) {
        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex);
        if (fontRanges.isNull())
            break;
        auto* font = fontRanges.fontForCharacter(c);
        auto* page = font ? font->glyphPage(pageNumber) : nullptr;
        if (!page)
            continue;
        GlyphData data = page->glyphDataForCharacter(c);
        if (data.font) {
            if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
                if (!FontCascade::isCJKIdeographOrSymbol(c))
                    return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data);

                if (!data.font->hasVerticalGlyphs()) {
                    // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
                    // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
                    return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackIndex);
                }
#if PLATFORM(COCOA)
                if (data.font->platformData().syntheticOblique())
                    return glyphDataForCJKCharacterWithoutSyntheticItalic(c, data);
#endif
            }

            return data;
        }
    }

    return glyphDataForSystemFallback(c, description, NormalVariant);
}
Exemplo n.º 2
0
GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 c, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
{
    while (true) {
        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex++);
        if (fontRanges.isNull())
            break;
        GlyphData data = fontRanges.glyphDataForCharacter(c);
        if (!data.font)
            continue;
        // The variantFont function should not normally return 0.
        // But if it does, we will just render the capital letter big.
        if (const Font* variantFont = data.font->variantFont(description, variant))
            return variantFont->glyphDataForCharacter(c);
        return data;
    }

    return glyphDataForSystemFallback(c, description, variant);
}