Index: Source/core/css/resolver/FontBuilder.cpp |
diff --git a/Source/core/css/resolver/FontBuilder.cpp b/Source/core/css/resolver/FontBuilder.cpp |
index 08f584156842d74115c03a1083ef2dd8fa461c41..3c94b72812d59d1f22df9374a99edc49c64ed0bd 100644 |
--- a/Source/core/css/resolver/FontBuilder.cpp |
+++ b/Source/core/css/resolver/FontBuilder.cpp |
@@ -123,6 +123,13 @@ void FontBuilder::setSize(const FontDescription::Size& size) |
setSize(m_fontDescription, size); |
} |
+void FontBuilder::setSizeAdjust(float aspectValue) |
+{ |
+ set(PropertySetFlag::SizeAdjust); |
+ |
+ m_fontDescription.setSizeAdjust(aspectValue); |
+} |
+ |
void FontBuilder::setStretch(FontStretch fontStretch) |
{ |
set(PropertySetFlag::Stretch); |
@@ -319,6 +326,29 @@ void FontBuilder::updateSpecifiedSize(FontDescription& fontDescription, const La |
checkForGenericFamilyChange(style.fontDescription(), fontDescription); |
} |
+void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const LayoutStyle& style) |
+{ |
+ const float sizeAdjust = fontDescription.sizeAdjust(); |
+ const float specifiedSize = fontDescription.specifiedSize(); |
+ if (!sizeAdjust || !specifiedSize) |
+ return; |
+ |
+ // We need to create a temporal Font to get xHeight of a primary font. |
+ Font font(fontDescription); |
+ font.update(nullptr); |
+ if (!font.fontMetrics().hasXHeight()) |
+ return; |
+ |
+ const 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::updateComputedSize(FontDescription& fontDescription, const LayoutStyle& style) |
{ |
float computedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effectiveZoom(), fontDescription.specifiedSize()); |
@@ -344,6 +374,8 @@ void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, |
description.setSpecifiedSize(m_fontDescription.specifiedSize()); |
description.setIsAbsoluteSize(m_fontDescription.isAbsoluteSize()); |
} |
+ if (isSet(PropertySetFlag::SizeAdjust)) |
+ description.setSizeAdjust(m_fontDescription.sizeAdjust()); |
if (isSet(PropertySetFlag::Weight)) |
description.setWeight(m_fontDescription.weight()); |
if (isSet(PropertySetFlag::Stretch)) |
@@ -371,6 +403,7 @@ void FontBuilder::createFont(PassRefPtrWillBeRawPtr<FontSelector> fontSelector, |
updateSpecifiedSize(description, style); |
updateComputedSize(description, style); |
+ updateAdjustedSize(description, style); |
style.setFontDescription(description); |
style.font().update(fontSelector); |