float LayoutTextControl::getAvgCharWidth(AtomicString family)
{
    if (hasValidAvgCharWidth(family))
        return roundf(style()->font().primaryFont()->avgCharWidth());

    const UChar ch = '0';
    const String str = String(&ch, 1);
    const Font& font = style()->font();
    TextRun textRun = constructTextRun(this, font, str, styleRef(), TextRun::AllowTrailingExpansion);
    return font.width(textRun);
}
Ejemplo n.º 2
0
float LayoutTextControl::getAvgCharWidth(const AtomicString& family) const {
    const Font& font = style()->font();

    const SimpleFontData* primaryFont = font.primaryFont();
    if (primaryFont && hasValidAvgCharWidth(primaryFont, family))
        return roundf(primaryFont->avgCharWidth());

    const UChar ch = '0';
    const String str = String(&ch, 1);
    TextRun textRun =
        constructTextRun(font, str, styleRef(), TextRun::AllowTrailingExpansion);
    return font.width(textRun);
}