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; }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const { return floatWidthForComplexText(run); }
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; }