OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 useSkiaAntiAlias = useAntiAlias; | 72 useSkiaAntiAlias = useAntiAlias; |
73 } | 73 } |
74 | 74 |
75 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) | 75 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) |
76 { | 76 { |
77 useSkiaSubpixelRendering = useSubpixelRendering; | 77 useSkiaSubpixelRendering = useSubpixelRendering; |
78 } | 78 } |
79 | 79 |
80 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) | 80 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) |
81 : m_textSize(0) | 81 : m_textSize(0) |
| 82 , m_emSizeInFontUnits(0) |
82 , m_syntheticBold(false) | 83 , m_syntheticBold(false) |
83 , m_syntheticItalic(false) | 84 , m_syntheticItalic(false) |
84 , m_orientation(Horizontal) | 85 , m_orientation(Horizontal) |
85 , m_isHashTableDeletedValue(true) | 86 , m_isHashTableDeletedValue(true) |
86 { | 87 { |
87 } | 88 } |
88 | 89 |
89 FontPlatformData::FontPlatformData() | 90 FontPlatformData::FontPlatformData() |
90 : m_textSize(0) | 91 : m_textSize(0) |
| 92 , m_emSizeInFontUnits(0) |
91 , m_syntheticBold(false) | 93 , m_syntheticBold(false) |
92 , m_syntheticItalic(false) | 94 , m_syntheticItalic(false) |
93 , m_orientation(Horizontal) | 95 , m_orientation(Horizontal) |
94 , m_isHashTableDeletedValue(false) | 96 , m_isHashTableDeletedValue(false) |
95 { | 97 { |
96 } | 98 } |
97 | 99 |
98 FontPlatformData::FontPlatformData(float textSize, bool syntheticBold, bool synt
heticItalic) | 100 FontPlatformData::FontPlatformData(float textSize, bool syntheticBold, bool synt
heticItalic) |
99 : m_textSize(textSize) | 101 : m_textSize(textSize) |
| 102 , m_emSizeInFontUnits(0) |
100 , m_syntheticBold(syntheticBold) | 103 , m_syntheticBold(syntheticBold) |
101 , m_syntheticItalic(syntheticItalic) | 104 , m_syntheticItalic(syntheticItalic) |
102 , m_orientation(Horizontal) | 105 , m_orientation(Horizontal) |
103 , m_isHashTableDeletedValue(false) | 106 , m_isHashTableDeletedValue(false) |
104 { | 107 { |
105 } | 108 } |
106 | 109 |
107 FontPlatformData::FontPlatformData(const FontPlatformData& src) | 110 FontPlatformData::FontPlatformData(const FontPlatformData& src) |
108 : m_typeface(src.m_typeface) | 111 : m_typeface(src.m_typeface) |
109 , m_family(src.m_family) | 112 , m_family(src.m_family) |
110 , m_textSize(src.m_textSize) | 113 , m_textSize(src.m_textSize) |
| 114 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
111 , m_syntheticBold(src.m_syntheticBold) | 115 , m_syntheticBold(src.m_syntheticBold) |
112 , m_syntheticItalic(src.m_syntheticItalic) | 116 , m_syntheticItalic(src.m_syntheticItalic) |
113 , m_orientation(src.m_orientation) | 117 , m_orientation(src.m_orientation) |
114 , m_style(src.m_style) | 118 , m_style(src.m_style) |
115 , m_harfBuzzFace(nullptr) | 119 , m_harfBuzzFace(nullptr) |
116 , m_isHashTableDeletedValue(false) | 120 , m_isHashTableDeletedValue(false) |
117 { | 121 { |
118 } | 122 } |
119 | 123 |
120 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orie
ntation, bool subpixelTextPosition) | 124 FontPlatformData::FontPlatformData(PassRefPtr<SkTypeface> tf, const char* family
, float textSize, bool syntheticBold, bool syntheticItalic, FontOrientation orie
ntation, bool subpixelTextPosition) |
121 : m_typeface(tf) | 125 : m_typeface(tf) |
122 , m_family(family) | 126 , m_family(family) |
123 , m_textSize(textSize) | 127 , m_textSize(textSize) |
| 128 , m_emSizeInFontUnits(0) |
124 , m_syntheticBold(syntheticBold) | 129 , m_syntheticBold(syntheticBold) |
125 , m_syntheticItalic(syntheticItalic) | 130 , m_syntheticItalic(syntheticItalic) |
126 , m_orientation(orientation) | 131 , m_orientation(orientation) |
127 , m_isHashTableDeletedValue(false) | 132 , m_isHashTableDeletedValue(false) |
128 { | 133 { |
129 querySystemForRenderStyle(subpixelTextPosition); | 134 querySystemForRenderStyle(subpixelTextPosition); |
130 } | 135 } |
131 | 136 |
132 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) | 137 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
133 : m_typeface(src.m_typeface) | 138 : m_typeface(src.m_typeface) |
134 , m_family(src.m_family) | 139 , m_family(src.m_family) |
135 , m_textSize(textSize) | 140 , m_textSize(textSize) |
| 141 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
136 , m_syntheticBold(src.m_syntheticBold) | 142 , m_syntheticBold(src.m_syntheticBold) |
137 , m_syntheticItalic(src.m_syntheticItalic) | 143 , m_syntheticItalic(src.m_syntheticItalic) |
138 , m_orientation(src.m_orientation) | 144 , m_orientation(src.m_orientation) |
139 , m_harfBuzzFace(nullptr) | 145 , m_harfBuzzFace(nullptr) |
140 , m_isHashTableDeletedValue(false) | 146 , m_isHashTableDeletedValue(false) |
141 { | 147 { |
142 querySystemForRenderStyle(FontDescription::subpixelPositioning()); | 148 querySystemForRenderStyle(FontDescription::subpixelPositioning()); |
143 } | 149 } |
144 | 150 |
145 FontPlatformData::~FontPlatformData() | 151 FontPlatformData::~FontPlatformData() |
146 { | 152 { |
147 } | 153 } |
148 | 154 |
| 155 int FontPlatformData::emSizeInFontUnits() const |
| 156 { |
| 157 if (m_emSizeInFontUnits) |
| 158 return m_emSizeInFontUnits; |
| 159 |
| 160 m_emSizeInFontUnits = m_typeface->getUnitsPerEm(); |
| 161 return m_emSizeInFontUnits; |
| 162 } |
| 163 |
149 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) | 164 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) |
150 { | 165 { |
151 m_typeface = src.m_typeface; | 166 m_typeface = src.m_typeface; |
152 m_family = src.m_family; | 167 m_family = src.m_family; |
153 m_textSize = src.m_textSize; | 168 m_textSize = src.m_textSize; |
154 m_syntheticBold = src.m_syntheticBold; | 169 m_syntheticBold = src.m_syntheticBold; |
155 m_syntheticItalic = src.m_syntheticItalic; | 170 m_syntheticItalic = src.m_syntheticItalic; |
156 m_harfBuzzFace = nullptr; | 171 m_harfBuzzFace = nullptr; |
157 m_orientation = src.m_orientation; | 172 m_orientation = src.m_orientation; |
158 m_style = src.m_style; | 173 m_style = src.m_style; |
| 174 m_emSizeInFontUnits = src.m_emSizeInFontUnits; |
159 | 175 |
160 return *this; | 176 return *this; |
161 } | 177 } |
162 | 178 |
163 #ifndef NDEBUG | 179 #ifndef NDEBUG |
164 String FontPlatformData::description() const | 180 String FontPlatformData::description() const |
165 { | 181 { |
166 return String(); | 182 return String(); |
167 } | 183 } |
168 #endif | 184 #endif |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) | 295 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) |
280 m_style.useSubpixelRendering = useSkiaSubpixelRendering; | 296 m_style.useSubpixelRendering = useSkiaSubpixelRendering; |
281 | 297 |
282 // TestRunner specifically toggles the subpixel positioning flag. | 298 // TestRunner specifically toggles the subpixel positioning flag. |
283 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference | 299 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference |
284 || isRunningLayoutTest()) | 300 || isRunningLayoutTest()) |
285 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; | 301 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; |
286 } | 302 } |
287 | 303 |
288 } // namespace WebCore | 304 } // namespace WebCore |
OLD | NEW |