Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/platform/fonts/FontDescription.h

Issue 943463002: Initial implementation of font-size-adjust (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add some tests which need a rebaseline to TestExpectation Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/RuntimeEnabledFeatures.in ('k') | Source/platform/fonts/FontDescription.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFam ily, 50 enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFam ily,
51 MonospaceFamily, CursiveFamily, FantasyFamily, Pict ographFamily }; 51 MonospaceFamily, CursiveFamily, FantasyFamily, Pict ographFamily };
52 52
53 enum Kerning { AutoKerning, NormalKerning, NoneKerning }; 53 enum Kerning { AutoKerning, NormalKerning, NoneKerning };
54 54
55 enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledL igaturesState }; 55 enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledL igaturesState };
56 56
57 FontDescription() 57 FontDescription()
58 : m_specifiedSize(0) 58 : m_specifiedSize(0)
59 , m_computedSize(0) 59 , m_computedSize(0)
60 , m_adjustedSize(0)
61 , m_sizeAdjust(0)
60 , m_letterSpacing(0) 62 , m_letterSpacing(0)
61 , m_wordSpacing(0) 63 , m_wordSpacing(0)
62 , m_orientation(Horizontal) 64 , m_orientation(Horizontal)
63 , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight) 65 , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight)
64 , m_widthVariant(RegularWidth) 66 , m_widthVariant(RegularWidth)
65 , m_style(FontStyleNormal) 67 , m_style(FontStyleNormal)
66 , m_variant(FontVariantNormal) 68 , m_variant(FontVariantNormal)
67 , m_isAbsoluteSize(false) 69 , m_isAbsoluteSize(false)
68 , m_weight(FontWeightNormal) 70 , m_weight(FontWeightNormal)
69 , m_stretch(FontStretchNormal) 71 , m_stretch(FontStretchNormal)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 GenericFamilyType genericFamily; 126 GenericFamilyType genericFamily;
125 FontFamily family; 127 FontFamily family;
126 }; 128 };
127 129
128 const FontFamily& family() const { return m_familyList; } 130 const FontFamily& family() const { return m_familyList; }
129 FamilyDescription familyDescription() const { return FamilyDescription(gener icFamily(), family()); } 131 FamilyDescription familyDescription() const { return FamilyDescription(gener icFamily(), family()); }
130 FontFamily& firstFamily() { return m_familyList; } 132 FontFamily& firstFamily() { return m_familyList; }
131 Size size() const { return Size(m_keywordSize, m_specifiedSize, m_isAbsolute Size); } 133 Size size() const { return Size(m_keywordSize, m_specifiedSize, m_isAbsolute Size); }
132 float specifiedSize() const { return m_specifiedSize; } 134 float specifiedSize() const { return m_specifiedSize; }
133 float computedSize() const { return m_computedSize; } 135 float computedSize() const { return m_computedSize; }
136 float adjustedSize() const { return m_adjustedSize; }
137 float sizeAdjust() const { return m_sizeAdjust; }
134 FontStyle style() const { return static_cast<FontStyle>(m_style); } 138 FontStyle style() const { return static_cast<FontStyle>(m_style); }
135 int computedPixelSize() const { return int(m_computedSize + 0.5f); } 139 int computedPixelSize() const { return int(m_computedSize + 0.5f); }
136 FontVariant variant() const { return static_cast<FontVariant>(m_variant); } 140 FontVariant variant() const { return static_cast<FontVariant>(m_variant); }
137 bool isAbsoluteSize() const { return m_isAbsoluteSize; } 141 bool isAbsoluteSize() const { return m_isAbsoluteSize; }
138 FontWeight weight() const { return static_cast<FontWeight>(m_weight); } 142 FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
139 FontStretch stretch() const { return static_cast<FontStretch>(m_stretch); } 143 FontStretch stretch() const { return static_cast<FontStretch>(m_stretch); }
140 static FontWeight lighterWeight(FontWeight); 144 static FontWeight lighterWeight(FontWeight);
141 static FontWeight bolderWeight(FontWeight); 145 static FontWeight bolderWeight(FontWeight);
142 static Size largerSize(const Size&); 146 static Size largerSize(const Size&);
143 static Size smallerSize(const Size&); 147 static Size smallerSize(const Size&);
(...skipping 28 matching lines...) Expand all
172 NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<N onCJKGlyphOrientation>(m_nonCJKGlyphOrientation); } 176 NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<N onCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
173 FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant> (m_widthVariant); } 177 FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant> (m_widthVariant); }
174 FontFeatureSettings* featureSettings() const { return m_featureSettings.get( ); } 178 FontFeatureSettings* featureSettings() const { return m_featureSettings.get( ); }
175 179
176 float effectiveFontSize() const; // Returns either the computedSize or the c omputedPixelSize 180 float effectiveFontSize() const; // Returns either the computedSize or the c omputedPixelSize
177 FontCacheKey cacheKey(const FontFaceCreationParams&, FontTraits desiredTrait s = FontTraits(0)) const; 181 FontCacheKey cacheKey(const FontFaceCreationParams&, FontTraits desiredTrait s = FontTraits(0)) const;
178 182
179 void setFamily(const FontFamily& family) { m_familyList = family; } 183 void setFamily(const FontFamily& family) { m_familyList = family; }
180 void setComputedSize(float s) { m_computedSize = clampTo<float>(s); } 184 void setComputedSize(float s) { m_computedSize = clampTo<float>(s); }
181 void setSpecifiedSize(float s) { m_specifiedSize = clampTo<float>(s); } 185 void setSpecifiedSize(float s) { m_specifiedSize = clampTo<float>(s); }
186 void setAdjustedSize(float s) { m_adjustedSize = clampTo<float>(s); }
187 void setSizeAdjust(float aspect) { m_sizeAdjust = clampTo<float>(aspect); }
182 void setStyle(FontStyle i) { m_style = i; } 188 void setStyle(FontStyle i) { m_style = i; }
183 void setVariant(FontVariant c) { m_variant = c; } 189 void setVariant(FontVariant c) { m_variant = c; }
184 void setVariantLigatures(const VariantLigatures&); 190 void setVariantLigatures(const VariantLigatures&);
185 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; } 191 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
186 void setWeight(FontWeight w) { m_weight = w; } 192 void setWeight(FontWeight w) { m_weight = w; }
187 void setStretch(FontStretch s) { m_stretch = s; } 193 void setStretch(FontStretch s) { m_stretch = s; }
188 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = g enericFamily; } 194 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = g enericFamily; }
189 void setKerning(Kerning kerning) { m_kerning = kerning; updateTypesettingFea tures(); } 195 void setKerning(Kerning kerning) { m_kerning = kerning; updateTypesettingFea tures(); }
190 void setKeywordSize(unsigned s) { m_keywordSize = s; } 196 void setKeywordSize(unsigned s) { m_keywordSize = s; }
191 void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoot hing; } 197 void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoot hing; }
(...skipping 22 matching lines...) Expand all
214 FontFamily m_familyList; // The list of font families to be used. 220 FontFamily m_familyList; // The list of font families to be used.
215 RefPtr<FontFeatureSettings> m_featureSettings; 221 RefPtr<FontFeatureSettings> m_featureSettings;
216 AtomicString m_locale; 222 AtomicString m_locale;
217 223
218 void updateTypesettingFeatures() const; 224 void updateTypesettingFeatures() const;
219 225
220 float m_specifiedSize; // Specified CSS value. Independent of rendering is sues such as integer 226 float m_specifiedSize; // Specified CSS value. Independent of rendering is sues such as integer
221 // rounding, minimum font sizes, and zooming. 227 // rounding, minimum font sizes, and zooming.
222 float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor. 228 float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor.
223 229
230 // (Given aspect value / aspect value of a font family) * specifiedSize.
231 // This value is adjusted for the minimum font size and the zoom factor
232 // as well as a computed size is.
233 float m_adjustedSize;
234
235 // Given aspect value, i.e. font-size-adjust.
236 float m_sizeAdjust;
237
224 float m_letterSpacing; 238 float m_letterSpacing;
225 float m_wordSpacing; 239 float m_wordSpacing;
226 240
227 unsigned m_orientation : 1; // FontOrientation - Whether the font is renderi ng on a horizontal line or a vertical line. 241 unsigned m_orientation : 1; // FontOrientation - Whether the font is renderi ng on a horizontal line or a vertical line.
228 unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used by vertical text. Determines the default orientation for non-ideograph glyphs. 242 unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used by vertical text. Determines the default orientation for non-ideograph glyphs.
229 243
230 unsigned m_widthVariant : 2; // FontWidthVariant 244 unsigned m_widthVariant : 2; // FontWidthVariant
231 245
232 unsigned m_style : 1; // FontStyle 246 unsigned m_style : 1; // FontStyle
233 unsigned m_variant : 1; // FontVariant 247 unsigned m_variant : 1; // FontVariant
(...skipping 26 matching lines...) Expand all
260 static TypesettingFeatures s_defaultTypesettingFeatures; 274 static TypesettingFeatures s_defaultTypesettingFeatures;
261 275
262 static bool s_useSubpixelTextPositioning; 276 static bool s_useSubpixelTextPositioning;
263 }; 277 };
264 278
265 inline bool FontDescription::operator==(const FontDescription& other) const 279 inline bool FontDescription::operator==(const FontDescription& other) const
266 { 280 {
267 return m_familyList == other.m_familyList 281 return m_familyList == other.m_familyList
268 && m_specifiedSize == other.m_specifiedSize 282 && m_specifiedSize == other.m_specifiedSize
269 && m_computedSize == other.m_computedSize 283 && m_computedSize == other.m_computedSize
284 && m_adjustedSize == other.m_adjustedSize
285 && m_sizeAdjust == other.m_sizeAdjust
270 && m_letterSpacing == other.m_letterSpacing 286 && m_letterSpacing == other.m_letterSpacing
271 && m_wordSpacing == other.m_wordSpacing 287 && m_wordSpacing == other.m_wordSpacing
272 && m_style == other.m_style 288 && m_style == other.m_style
273 && m_variant == other.m_variant 289 && m_variant == other.m_variant
274 && m_isAbsoluteSize == other.m_isAbsoluteSize 290 && m_isAbsoluteSize == other.m_isAbsoluteSize
275 && m_weight == other.m_weight 291 && m_weight == other.m_weight
276 && m_stretch == other.m_stretch 292 && m_stretch == other.m_stretch
277 && m_genericFamily == other.m_genericFamily 293 && m_genericFamily == other.m_genericFamily
278 && m_kerning == other.m_kerning 294 && m_kerning == other.m_kerning
279 && m_commonLigaturesState == other.m_commonLigaturesState 295 && m_commonLigaturesState == other.m_commonLigaturesState
280 && m_discretionaryLigaturesState == other.m_discretionaryLigaturesState 296 && m_discretionaryLigaturesState == other.m_discretionaryLigaturesState
281 && m_historicalLigaturesState == other.m_historicalLigaturesState 297 && m_historicalLigaturesState == other.m_historicalLigaturesState
282 && m_contextualLigaturesState == other.m_contextualLigaturesState 298 && m_contextualLigaturesState == other.m_contextualLigaturesState
283 && m_keywordSize == other.m_keywordSize 299 && m_keywordSize == other.m_keywordSize
284 && m_fontSmoothing == other.m_fontSmoothing 300 && m_fontSmoothing == other.m_fontSmoothing
285 && m_textRendering == other.m_textRendering 301 && m_textRendering == other.m_textRendering
286 && m_orientation == other.m_orientation 302 && m_orientation == other.m_orientation
287 && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation 303 && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
288 && m_widthVariant == other.m_widthVariant 304 && m_widthVariant == other.m_widthVariant
289 && m_script == other.m_script 305 && m_script == other.m_script
290 && m_syntheticBold == other.m_syntheticBold 306 && m_syntheticBold == other.m_syntheticBold
291 && m_syntheticItalic == other.m_syntheticItalic 307 && m_syntheticItalic == other.m_syntheticItalic
292 && m_featureSettings == other.m_featureSettings 308 && m_featureSettings == other.m_featureSettings
293 && m_subpixelTextPosition == other.m_subpixelTextPosition; 309 && m_subpixelTextPosition == other.m_subpixelTextPosition;
294 } 310 }
295 311
296 } // namespace blink 312 } // namespace blink
297 313
298 #endif 314 #endif
OLDNEW
« no previous file with comments | « Source/platform/RuntimeEnabledFeatures.in ('k') | Source/platform/fonts/FontDescription.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698