Exemplo n.º 1
0
int FontSize::legacyFontSize(const Document* document, int pixelFontSize, FixedPitchFontType fixedPitchFontType)
{
    const Settings* settings = document->settings();
    if (!settings)
        return 1;

    int mediumSize = 0;
    int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumSize);
    if (row >= 0)
        return findNearestLegacyFontSize<int>(pixelFontSize, strictFontSizeTable[row], 1);

    return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, mediumSize);
}
int FontSize::legacyFontSize(const Document* document, int pixelFontSize, bool isMonospace)
{
    const Settings* settings = document->settings();
    if (!settings)
        return 1;

    bool quirksMode = document->inQuirksMode();
    int mediumSize = 0;
    int row = rowFromMediumFontSizeInRange(settings, quirksMode, isMonospace, mediumSize);
    if (row >= 0)
        return findNearestLegacyFontSize<int>(pixelFontSize, quirksMode ? quirksFontSizeTable[row] : strictFontSizeTable[row], 1);

    return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, mediumSize);
}
Exemplo n.º 3
0
float FontSize::fontSizeForKeyword(const Document* document, CSSValueID keyword, FixedPitchFontType fixedPitchFontType)
{
    ASSERT(keyword >= CSSValueXxSmall && keyword <= CSSValueWebkitXxxLarge);
    const Settings* settings = document->settings();
    if (!settings)
        return 1.0f;

    int mediumSize = 0;
    int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumSize);
    if (row >= 0) {
        int col = (keyword - CSSValueXxSmall);
        return strictFontSizeTable[row][col];
    }

    // Value is outside the range of the table. Apply the scale factor instead.
    float minLogicalSize = 1;
    return std::max(fontSizeFactors[keyword - CSSValueXxSmall] * mediumSize, minLogicalSize);
}
float FontSize::fontSizeForKeyword(const Document* document, unsigned keyword, bool isMonospace)
{
    ASSERT(keyword >= 1 && keyword <= 8);
    const Settings* settings = document->settings();
    if (!settings)
        return 1.0f;

    bool quirksMode = document->inQuirksMode();
    int mediumSize = 0;
    int row = rowFromMediumFontSizeInRange(settings, quirksMode, isMonospace, mediumSize);
    if (row >= 0) {
        int col = (keyword - 1);
        return quirksMode ? quirksFontSizeTable[row][col] : strictFontSizeTable[row][col];
    }

    // Value is outside the range of the table. Apply the scale factor instead.
    float minLogicalSize = std::max(settings->minimumLogicalFontSize(), 1);
    return std::max(fontSizeFactors[keyword - 1] * mediumSize, minLogicalSize);
}