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

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

Issue 183813005: Add font-stretch to FontDescription (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 24 matching lines...) Expand all
35 #include "wtf/text/StringHash.h" 35 #include "wtf/text/StringHash.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
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 float sizes[4]; 42 float sizes[4];
43 // FXIME: Make them fit into one word. 43 // FXIME: Make them fit into one word.
44 uint32_t bitfields; 44 uint32_t bitfields;
45 uint32_t bitfields2 : 8; 45 uint32_t bitfields2 : 12;
46 }; 46 };
47 47
48 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon tDescription_should_stay_small); 48 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), Fon tDescription_should_stay_small);
49 49
50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0; 50 TypesettingFeatures FontDescription::s_defaultTypesettingFeatures = 0;
51 51
52 bool FontDescription::s_useSubpixelTextPositioning = false; 52 bool FontDescription::s_useSubpixelTextPositioning = false;
53 53
54 FontWeight FontDescription::lighterWeight(void) const 54 FontWeight FontDescription::lighterWeight(void) const
55 { 55 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return FontWeight900; 92 return FontWeight900;
93 } 93 }
94 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
95 return FontWeightNormal; 95 return FontWeightNormal;
96 } 96 }
97 97
98 FontTraitsMask FontDescription::traitsMask() const 98 FontTraitsMask FontDescription::traitsMask() const
99 { 99 {
100 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty leNormalMask) 100 return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontSty leNormalMask)
101 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask) 101 | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask)
102 | (FontWeight100Mask << (m_weight - FontWeight100))); 102 | (FontWeight100Mask << (m_weight - FontWeight100))
103 103 | (m_stretch << FontStretchBit1));
104 } 104 }
105 105
106 void FontDescription::setTraitsMask(FontTraitsMask traitsMask) 106 void FontDescription::setTraitsMask(FontTraitsMask traitsMask)
107 { 107 {
108 switch (traitsMask & FontWeightMask) { 108 switch (traitsMask & FontWeightMask) {
109 case FontWeight100Mask: 109 case FontWeight100Mask:
110 setWeight(FontWeight100); 110 setWeight(FontWeight100);
111 break; 111 break;
112 case FontWeight200Mask: 112 case FontWeight200Mask:
113 setWeight(FontWeight200); 113 setWeight(FontWeight200);
(...skipping 17 matching lines...) Expand all
131 setWeight(FontWeight800); 131 setWeight(FontWeight800);
132 break; 132 break;
133 case FontWeight900Mask: 133 case FontWeight900Mask:
134 setWeight(FontWeight900); 134 setWeight(FontWeight900);
135 break; 135 break;
136 default: 136 default:
137 ASSERT_NOT_REACHED(); 137 ASSERT_NOT_REACHED();
138 } 138 }
139 setItalic((traitsMask & FontStyleItalicMask) ? FontItalicOn : FontItalicOff) ; 139 setItalic((traitsMask & FontStyleItalicMask) ? FontItalicOn : FontItalicOff) ;
140 setSmallCaps((traitsMask & FontVariantSmallCapsMask) ? FontSmallCapsOn : Fon tSmallCapsOff); 140 setSmallCaps((traitsMask & FontVariantSmallCapsMask) ? FontSmallCapsOn : Fon tSmallCapsOff);
141 setStretch(static_cast<FontStretch>((traitsMask & FontStretchMask) >> FontSt retchBit1));
141 } 142 }
142 143
143 FontDescription FontDescription::makeNormalFeatureSettings() const 144 FontDescription FontDescription::makeNormalFeatureSettings() const
144 { 145 {
145 FontDescription normalDescription(*this); 146 FontDescription normalDescription(*this);
146 normalDescription.setFeatureSettings(nullptr); 147 normalDescription.setFeatureSettings(nullptr);
147 return normalDescription; 148 return normalDescription;
148 } 149 }
149 150
150 float FontDescription::effectiveFontSize() const 151 float FontDescription::effectiveFontSize() const
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 break; 221 break;
221 case FontDescription::EnabledLigaturesState: 222 case FontDescription::EnabledLigaturesState:
222 m_typesettingFeatures |= Ligatures; 223 m_typesettingFeatures |= Ligatures;
223 break; 224 break;
224 case FontDescription::NormalLigaturesState: 225 case FontDescription::NormalLigaturesState:
225 break; 226 break;
226 } 227 }
227 } 228 }
228 229
229 } // namespace WebCore 230 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698