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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 HANDLE fFontMemResource; | 301 HANDLE fFontMemResource; |
302 | 302 |
303 typedef LogFontTypeface INHERITED; | 303 typedef LogFontTypeface INHERITED; |
304 }; | 304 }; |
305 | 305 |
306 static const LOGFONT& get_default_font() { | 306 static const LOGFONT& get_default_font() { |
307 static LOGFONT gDefaultFont; | 307 static LOGFONT gDefaultFont; |
308 return gDefaultFont; | 308 return gDefaultFont; |
309 } | 309 } |
310 | 310 |
311 static bool FindByLogFont(SkTypeface* face, const SkFontStyle& requestedStyle, v
oid* ctx) { | 311 static bool FindByLogFont(SkTypeface* face, void* ctx) { |
312 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face); | 312 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face); |
313 const LOGFONT* lf = reinterpret_cast<const LOGFONT*>(ctx); | 313 const LOGFONT* lf = reinterpret_cast<const LOGFONT*>(ctx); |
314 | 314 |
315 return lface && | 315 return !memcmp(&lface->fLogFont, lf, sizeof(LOGFONT)); |
316 get_style(lface->fLogFont) == requestedStyle && | |
317 !memcmp(&lface->fLogFont, lf, sizeof(LOGFONT)); | |
318 } | 316 } |
319 | 317 |
320 /** | 318 /** |
321 * This guy is public. It first searches the cache, and if a match is not found
, | 319 * This guy is public. It first searches the cache, and if a match is not found
, |
322 * it creates a new face. | 320 * it creates a new face. |
323 */ | 321 */ |
324 SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) { | 322 SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) { |
325 LOGFONT lf = origLF; | 323 LOGFONT lf = origLF; |
326 make_canonical(&lf); | 324 make_canonical(&lf); |
327 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf); | 325 SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf); |
328 if (nullptr == face) { | 326 if (nullptr == face) { |
329 face = LogFontTypeface::Create(lf); | 327 face = LogFontTypeface::Create(lf); |
330 SkTypefaceCache::Add(face, get_style(lf)); | 328 SkTypefaceCache::Add(face); |
331 } | 329 } |
332 return face; | 330 return face; |
333 } | 331 } |
334 | 332 |
335 /** | 333 /** |
336 * The created SkTypeface takes ownership of fontMemResource. | 334 * The created SkTypeface takes ownership of fontMemResource. |
337 */ | 335 */ |
338 SkTypeface* SkCreateFontMemResourceTypefaceFromLOGFONT(const LOGFONT& origLF, HA
NDLE fontMemResource) { | 336 SkTypeface* SkCreateFontMemResourceTypefaceFromLOGFONT(const LOGFONT& origLF, HA
NDLE fontMemResource) { |
339 LOGFONT lf = origLF; | 337 LOGFONT lf = origLF; |
340 make_canonical(&lf); | 338 make_canonical(&lf); |
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2516 | 2514 |
2517 private: | 2515 private: |
2518 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2516 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2519 }; | 2517 }; |
2520 | 2518 |
2521 /////////////////////////////////////////////////////////////////////////////// | 2519 /////////////////////////////////////////////////////////////////////////////// |
2522 | 2520 |
2523 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } | 2521 SkFontMgr* SkFontMgr_New_GDI() { return new SkFontMgrGDI; } |
2524 | 2522 |
2525 #endif//defined(SK_BUILD_FOR_WIN32) | 2523 #endif//defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |