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

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

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/fonts/FontDescription.h ('k') | no next file » | 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) 2007 Nicholas Shanks <contact@nickshanks.com> 2 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com>
3 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 22 matching lines...) Expand all
33 #include "platform/RuntimeEnabledFeatures.h" 33 #include "platform/RuntimeEnabledFeatures.h"
34 #include "wtf/text/AtomicStringHash.h" 34 #include "wtf/text/AtomicStringHash.h"
35 #include "wtf/text/StringHash.h" 35 #include "wtf/text/StringHash.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 struct SameSizeAsFontDescription { 39 struct SameSizeAsFontDescription {
40 FontFamily familyList; 40 FontFamily familyList;
41 RefPtr<FontFeatureSettings> m_featureSettings; 41 RefPtr<FontFeatureSettings> m_featureSettings;
42 AtomicString locale; 42 AtomicString locale;
43 float sizes[4]; 43 float sizes[6];
44 // FXIME: Make them fit into one word. 44 // FXIME: Make them fit into one word.
45 uint32_t bitfields; 45 uint32_t bitfields;
46 uint32_t bitfields2 : 7; 46 uint32_t bitfields2 : 7;
47 }; 47 };
48 48
49 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), "Fon tDescription should stay small"); 49 static_assert(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), "Fon tDescription should stay small");
50 50
51 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; 51 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0;
52 52
53 bool FontDescription::s_useSubpixelTextPositioning = false; 53 bool FontDescription::s_useSubpixelTextPositioning = false;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 m_historicalLigaturesState = ligatures.historical; 153 m_historicalLigaturesState = ligatures.historical;
154 m_contextualLigaturesState = ligatures.contextual; 154 m_contextualLigaturesState = ligatures.contextual;
155 155
156 updateTypesettingFeatures(); 156 updateTypesettingFeatures();
157 } 157 }
158 158
159 float FontDescription::effectiveFontSize() const 159 float FontDescription::effectiveFontSize() const
160 { 160 {
161 // Ensure that the effective precision matches the font-cache precision. 161 // Ensure that the effective precision matches the font-cache precision.
162 // This guarantees that the same precision is used regardless of cache statu s. 162 // This guarantees that the same precision is used regardless of cache statu s.
163 return floorf(computedSize() * FontCacheKey::precisionMultiplier()) / FontCa cheKey::precisionMultiplier(); 163 float computedOrAdjustedSize = adjustedSize() ? adjustedSize() : computedSiz e();
164 return floorf(computedOrAdjustedSize * FontCacheKey::precisionMultiplier()) / FontCacheKey::precisionMultiplier();
164 } 165 }
165 166
166 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar ams, FontTraits desiredTraits) const 167 FontCacheKey FontDescription::cacheKey(const FontFaceCreationParams& creationPar ams, FontTraits desiredTraits) const
167 { 168 {
168 FontTraits fontTraits = desiredTraits.bitfield() ? desiredTraits : traits(); 169 FontTraits fontTraits = desiredTraits.bitfield() ? desiredTraits : traits();
169 170
170 unsigned options = 171 unsigned options =
171 static_cast<unsigned>(m_syntheticItalic) << 5 | // bit 6 172 static_cast<unsigned>(m_syntheticItalic) << 5 | // bit 6
172 static_cast<unsigned>(m_syntheticBold) << 4 | // bit 5 173 static_cast<unsigned>(m_syntheticBold) << 4 | // bit 5
173 static_cast<unsigned>(m_textRendering) << 2 | // bits 3-4 174 static_cast<unsigned>(m_textRendering) << 2 | // bits 3-4
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 if (discretionaryLigaturesState() == FontDescription::EnabledLigaturesSt ate 235 if (discretionaryLigaturesState() == FontDescription::EnabledLigaturesSt ate
235 || historicalLigaturesState() == FontDescription::EnabledLigaturesSt ate 236 || historicalLigaturesState() == FontDescription::EnabledLigaturesSt ate
236 || contextualLigaturesState() == FontDescription::EnabledLigaturesSt ate) { 237 || contextualLigaturesState() == FontDescription::EnabledLigaturesSt ate) {
237 m_typesettingFeatures |= blink::Ligatures; 238 m_typesettingFeatures |= blink::Ligatures;
238 } 239 }
239 } 240 }
240 } 241 }
241 242
242 } // namespace blink 243 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontDescription.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698