void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const ComputedStyle& style, FontSelector* fontSelector) { const float specifiedSize = fontDescription.specifiedSize(); if (!fontDescription.hasSizeAdjust() || !specifiedSize) return; // We need to create a temporal Font to get xHeight of a primary font. // The aspect value is based on the xHeight of the font for the computed font size, // so we need to reset the adjustedSize to computedSize. See FontDescription::effectiveFontSize. fontDescription.setAdjustedSize(fontDescription.computedSize()); Font font(fontDescription); font.update(fontSelector); if (!font.fontMetrics().hasXHeight()) return; const float sizeAdjust = fontDescription.sizeAdjust(); float aspectValue = font.fontMetrics().xHeight() / specifiedSize; float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), adjustedSize); float multiplier = style.textAutosizingMultiplier(); if (multiplier > 1) adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, multiplier); fontDescription.setAdjustedSize(adjustedSize); }
void FontBuilder::createFontForDocument(PassRefPtr<FontSelector> fontSelector, RenderStyle* documentStyle) { FontDescription fontDescription = FontDescription(); fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale())); if (Settings* settings = m_document->settings()) { fontDescription.setUsePrinterFont(m_document->printing()); const AtomicString& standardFont = settings->standardFontFamily(fontDescription.script()); if (!standardFont.isEmpty()) { fontDescription.setGenericFamily(FontDescription::StandardFamily); fontDescription.firstFamily().setFamily(standardFont); fontDescription.firstFamily().appendFamily(0); } fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false); fontDescription.setSpecifiedSize(size); fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, documentStyle->effectiveZoom(), size)); } else { fontDescription.setUsePrinterFont(m_document->printing()); } FontOrientation fontOrientation; NonCJKGlyphOrientation glyphOrientation; getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation); fontDescription.setOrientation(fontOrientation); fontDescription.setNonCJKGlyphOrientation(glyphOrientation); documentStyle->setFontDescription(fontDescription); documentStyle->font().update(fontSelector); }
void FontBuilder::updateComputedSize(FontDescription& fontDescription, const ComputedStyle& style) { float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), fontDescription.specifiedSize()); float multiplier = style.textAutosizingMultiplier(); if (multiplier > 1) computedSize = TextAutosizer::computeAutosizedFontSize(computedSize, multiplier); fontDescription.setComputedSize(computedSize); }
void FontBuilder::createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, RenderStyle* documentStyle) { FontDescription fontDescription = FontDescription(); fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale())); setFontFamilyToStandard(fontDescription, m_document); fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); int size = FontSize::fontSizeForKeyword(m_document, CSSValueMedium, false); fontDescription.setSpecifiedSize(size); fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, documentStyle->effectiveZoom(), size)); FontOrientation fontOrientation; NonCJKGlyphOrientation glyphOrientation; getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation); fontDescription.setOrientation(fontOrientation); fontDescription.setNonCJKGlyphOrientation(glyphOrientation); documentStyle->setFontDescription(fontDescription); documentStyle->font().update(fontSelector); }
void FontBuilder::fromSystemFont(CSSValueID valueId, float effectiveZoom) { FontDescriptionChangeScope scope(this); FontDescription fontDescription; RenderTheme::theme().systemFont(valueId, fontDescription); // Double-check and see if the theme did anything. If not, don't bother updating the font. if (!fontDescription.isAbsoluteSize()) return; // Make sure the rendering mode and printer font settings are updated. const Settings* settings = m_document->settings(); ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings if (!settings) return; // Handle the zoom factor. fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, effectiveZoom, fontDescription.specifiedSize())); scope.set(fontDescription); }
void FontBuilder::setSize(FontDescription& fontDescription, float effectiveZoom, float size) { fontDescription.setSpecifiedSize(size); fontDescription.setComputedSize(getComputedSizeFromSpecifiedSize(fontDescription, effectiveZoom, size)); }
void FontBuilder::updateComputedSize(RenderStyle* style, const RenderStyle* parentStyle) { FontDescriptionChangeScope scope(this); scope.fontDescription().setComputedSize(getComputedSizeFromSpecifiedSize(scope.fontDescription(), style->effectiveZoom(), scope.fontDescription().specifiedSize())); }