OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
10 | 10 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return (0 == otmRet) ? 0 : otm.otmEMSquare; | 203 return (0 == otmRet) ? 0 : otm.otmEMSquare; |
204 } | 204 } |
205 | 205 |
206 class LogFontTypeface : public SkTypeface { | 206 class LogFontTypeface : public SkTypeface { |
207 public: | 207 public: |
208 LogFontTypeface(const SkFontStyle& style, const LOGFONT& lf, bool serializeA
sStream) | 208 LogFontTypeface(const SkFontStyle& style, const LOGFONT& lf, bool serializeA
sStream) |
209 : SkTypeface(style, false) | 209 : SkTypeface(style, false) |
210 , fLogFont(lf) | 210 , fLogFont(lf) |
211 , fSerializeAsStream(serializeAsStream) | 211 , fSerializeAsStream(serializeAsStream) |
212 { | 212 { |
213 | |
214 // If the font has cubic outlines, it will not be rendered with ClearTyp
e. | |
215 HFONT font = CreateFontIndirect(&lf); | 213 HFONT font = CreateFontIndirect(&lf); |
216 | 214 |
217 HDC deviceContext = ::CreateCompatibleDC(nullptr); | 215 HDC deviceContext = ::CreateCompatibleDC(nullptr); |
218 HFONT savefont = (HFONT)SelectObject(deviceContext, font); | 216 HFONT savefont = (HFONT)SelectObject(deviceContext, font); |
219 | 217 |
220 TEXTMETRIC textMetric; | 218 TEXTMETRIC textMetric; |
221 if (0 == GetTextMetrics(deviceContext, &textMetric)) { | 219 if (0 == GetTextMetrics(deviceContext, &textMetric)) { |
222 call_ensure_accessible(lf); | 220 call_ensure_accessible(lf); |
223 if (0 == GetTextMetrics(deviceContext, &textMetric)) { | 221 if (0 == GetTextMetrics(deviceContext, &textMetric)) { |
224 textMetric.tmPitchAndFamily = TMPF_TRUETYPE; | 222 textMetric.tmPitchAndFamily = TMPF_TRUETYPE; |
225 } | 223 } |
226 } | 224 } |
227 if (deviceContext) { | 225 if (deviceContext) { |
228 ::SelectObject(deviceContext, savefont); | 226 ::SelectObject(deviceContext, savefont); |
229 ::DeleteDC(deviceContext); | 227 ::DeleteDC(deviceContext); |
230 } | 228 } |
231 if (font) { | 229 if (font) { |
232 ::DeleteObject(font); | 230 ::DeleteObject(font); |
233 } | 231 } |
234 | 232 |
235 // The fixed pitch bit is set if the font is *not* fixed pitch. | 233 // The fixed pitch bit is set if the font is *not* fixed pitch. |
236 this->setIsFixedPitch((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) =
= 0); | 234 this->setIsFixedPitch((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) =
= 0); |
| 235 this->setFontStyle(SkFontStyle(textMetric.tmWeight, style.width(), style
.slant())); |
237 | 236 |
238 // Used a logfont on a memory context, should never get a device font. | 237 // Used a logfont on a memory context, should never get a device font. |
239 // Therefore all TMPF_DEVICE will be PostScript (cubic) fonts. | 238 // Therefore all TMPF_DEVICE will be PostScript (cubic) fonts. |
| 239 // If the font has cubic outlines, it will not be rendered with ClearTyp
e. |
240 fCanBeLCD = !((textMetric.tmPitchAndFamily & TMPF_VECTOR) && | 240 fCanBeLCD = !((textMetric.tmPitchAndFamily & TMPF_VECTOR) && |
241 (textMetric.tmPitchAndFamily & TMPF_DEVICE)); | 241 (textMetric.tmPitchAndFamily & TMPF_DEVICE)); |
242 } | 242 } |
243 | 243 |
244 LOGFONT fLogFont; | 244 LOGFONT fLogFont; |
245 bool fSerializeAsStream; | 245 bool fSerializeAsStream; |
246 bool fCanBeLCD; | 246 bool fCanBeLCD; |
247 | 247 |
248 static LogFontTypeface* Create(const LOGFONT& lf) { | 248 static LogFontTypeface* Create(const LOGFONT& lf) { |
249 return new LogFontTypeface(get_style(lf), lf, false); | 249 return new LogFontTypeface(get_style(lf), lf, false); |
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2505 | 2505 |
2506 private: | 2506 private: |
2507 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2507 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2508 }; | 2508 }; |
2509 | 2509 |
2510 /////////////////////////////////////////////////////////////////////////////// | 2510 /////////////////////////////////////////////////////////////////////////////// |
2511 | 2511 |
2512 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } | 2512 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } |
2513 | 2513 |
2514 #endif//defined(SK_BUILD_FOR_WIN32) | 2514 #endif//defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |