コード例 #1
0
ファイル: Font.cpp プロジェクト: glenkim-dev/blink-crosswalk
float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
    CodePath codePathToUse = codePath(run);
    if (codePathToUse != ComplexPath) {
        // The complex path is more restrictive about returning fallback fonts than the simple path, so we need an explicit test to make their behaviors match.
        if (!FontPlatformFeatures::canReturnFallbackFontsForComplexText())
            fallbackFonts = 0;
        // The simple path can optimize the case where glyph overflow is not observable.
        if (codePathToUse != SimpleWithGlyphOverflowPath && (glyphOverflow && !glyphOverflow->computeBounds))
            glyphOverflow = 0;
    }

    bool hasKerningOrLigatures = fontDescription().typesettingFeatures() & (Kerning | Ligatures);
    bool hasWordSpacingOrLetterSpacing = fontDescription().wordSpacing() || fontDescription().letterSpacing();
    float* cacheEntry = m_fontFallbackList->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
    if (cacheEntry && !std::isnan(*cacheEntry))
        return *cacheEntry;

    float result;
    if (codePathToUse == ComplexPath)
        result = floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
    else
        result = floatWidthForSimpleText(run, fallbackFonts, glyphOverflow);

    if (cacheEntry && (!fallbackFonts || fallbackFonts->isEmpty()))
        *cacheEntry = result;
    return result;
}
コード例 #2
0
ファイル: BTFont.cpp プロジェクト: jackiekaon/owb-mirror
float Font::floatWidth(const TextRun& run, const WebCore::TextStyle& style) const
{
    if (canUseGlyphCache(run))
        return floatWidthForSimpleText(run, style, 0, 0);
    else
        return floatWidthForComplexText(run, style);
}
コード例 #3
0
ファイル: Font.cpp プロジェクト: Chingliu/EAWebkit
float Font::floatWidth(const TextRun& run) const
{
#if ENABLE(SVG_FONTS)
    if (primaryFont()->isSVGFont())
        return floatWidthUsingSVGFont(run);
#endif

    if (canUseGlyphCache(run))
        return floatWidthForSimpleText(run, 0);
    return floatWidthForComplexText(run);
}
コード例 #4
0
ファイル: Font.cpp プロジェクト: bearmingo/UI
float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
    CodePath codePathToUse = codePath(run);
    if (codePathToUse != Complex) {
        // If the complex text implementation cannot return fallback fonts, avoid
        // returning them for simple text as well.
        static bool returnFallbackFonts = canReturnFallbackFontsForComplexText();
        return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow || (glyphOverflow && glyphOverflow->computeBounds) ? glyphOverflow : 0);
    }

    return floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
}
コード例 #5
0
ファイル: Font.cpp プロジェクト: Chingliu/EAWebkit
float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
{
#if ENABLE(SVG_FONTS)
    if (primaryFont()->isSVGFont())
        return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);
#endif

    charsConsumed = run.length();
    glyphName = "";
    if (canUseGlyphCache(run))
        return floatWidthForSimpleText(run, 0);
    return floatWidthForComplexText(run);
}
コード例 #6
0
ファイル: Font.cpp プロジェクト: bearmingo/UI
float Font::width(const TextRun& run, int& charsConsumed, String& glyphName) const
{
#if ENABLE(SVG_FONTS)
    if (TextRun::RenderingContext* renderingContext = run.renderingContext())
        return renderingContext->floatWidthUsingSVGFont(*this, run, charsConsumed, glyphName);
#endif

    charsConsumed = run.length();
    glyphName = "";

    if (codePath(run) != Complex)
        return floatWidthForSimpleText(run, 0);

    return floatWidthForComplexText(run);
}
コード例 #7
0
ファイル: Font.cpp プロジェクト: a33g-dev/platform_samsung
float Font::width(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
{
#if !ENABLE(SVG_FONTS)
    UNUSED_PARAM(extraCharsAvailable);
#else
    if (primaryFont()->isSVGFont())
        return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);
#endif

    charsConsumed = run.length();
    glyphName = "";

    if (codePath(run) != Complex)
        return floatWidthForSimpleText(run, 0);

    return floatWidthForComplexText(run);
}
コード例 #8
0
ファイル: Font.cpp プロジェクト: mikedougherty/webkit
float Font::floatWidth(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
#if ENABLE(SVG_FONTS)
    if (primaryFont()->isSVGFont())
        return floatWidthUsingSVGFont(run);
#endif

    CodePath codePathToUse = codePath(run);
    if (codePathToUse != Complex) {
        // If the complex text implementation cannot return fallback fonts, avoid
        // returning them for simple text as well.
        static bool returnFallbackFonts = canReturnFallbackFontsForComplexText();
        return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow ? glyphOverflow : 0);
    }

    return floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
}
コード例 #9
0
float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const
{
    return floatWidthForComplexText(run);
}
コード例 #10
0
int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
{
    void* font = 0;
    float w = 0.f;
    const UChar* str = 0;
    UChar c = 0;
    const SimpleFontData* sfont = 0;
    int i, len;
    float delta = (float)x;
    float scale = 0;

    len = run.length();
    if (!len) return 0;

    str = run.characters();
    sfont = primaryFont();
    font = sfont->platformData().Font();
    if (!font) return 0;
    scale = sfont->platformData().scale();

    i = 0;
    if (run.rtl()) {
        delta -= floatWidthForComplexText(run, 0);
        while (i<len) {
            c = fixedChar(str[i]);
            if (c) {
                w = (float)wkcFontGetCharWidthPeer(font, c) * scale;
            } else {
                w = 0;
            }
            delta += w;
            if (includePartialGlyphs) {
                if (delta - w / 2 >= 0)
                    break;
            } else {
                if (delta >= 0)
                    break;
            }
            i++;
        }
    } else {
        while (i<len) {
            c = fixedChar(str[i]);
            if (c) {
                w = (float)wkcFontGetCharWidthPeer(font, c) * scale;
            } else {
                w = 0;
            }
            delta -= w;
            if (includePartialGlyphs) {
                if (delta + w / 2 <= 0)
                    break;
            } else {
                if (delta <= 0)
                    break;
            }
            i++;
        }
    }

    return i;
}