| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
| 10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 virtual int onGetUPEM() const SK_OVERRIDE; | 277 virtual int onGetUPEM() const SK_OVERRIDE; |
| 278 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 278 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; |
| 279 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 279 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
| 280 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 280 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
| 281 size_t length, void* data) const SK_OVERRIDE; | 281 size_t length, void* data) const SK_OVERRIDE; |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 class FontMemResourceTypeface : public LogFontTypeface { | 284 class FontMemResourceTypeface : public LogFontTypeface { |
| 285 public: | 285 public: |
| 286 /** | 286 /** |
| 287 * Takes ownership of fontMemResource. | |
| 288 */ | |
| 289 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : | |
| 290 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { | |
| 291 } | |
| 292 | |
| 293 HANDLE fFontMemResource; | |
| 294 | |
| 295 /** | |
| 296 * The created FontMemResourceTypeface takes ownership of fontMemResource. | 287 * The created FontMemResourceTypeface takes ownership of fontMemResource. |
| 297 */ | 288 */ |
| 298 static FontMemResourceTypeface* Create(const LOGFONT& lf, HANDLE fontMemReso
urce) { | 289 static FontMemResourceTypeface* Create(const LOGFONT& lf, HANDLE fontMemReso
urce) { |
| 299 SkTypeface::Style style = get_style(lf); | 290 SkTypeface::Style style = get_style(lf); |
| 300 SkFontID fontID = SkTypefaceCache::NewFontID(); | 291 SkFontID fontID = SkTypefaceCache::NewFontID(); |
| 301 return new FontMemResourceTypeface(style, fontID, lf, fontMemResource); | 292 return new FontMemResourceTypeface(style, fontID, lf, fontMemResource); |
| 302 } | 293 } |
| 303 | 294 |
| 304 protected: | 295 protected: |
| 305 virtual void weak_dispose() const SK_OVERRIDE { | 296 virtual void weak_dispose() const SK_OVERRIDE { |
| 306 RemoveFontMemResourceEx(fFontMemResource); | 297 RemoveFontMemResourceEx(fFontMemResource); |
| 307 //SkTypefaceCache::Remove(this); | 298 //SkTypefaceCache::Remove(this); |
| 308 INHERITED::weak_dispose(); | 299 INHERITED::weak_dispose(); |
| 309 } | 300 } |
| 310 | 301 |
| 311 private: | 302 private: |
| 303 /** |
| 304 * Takes ownership of fontMemResource. |
| 305 */ |
| 306 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : |
| 307 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { |
| 308 } |
| 309 |
| 310 HANDLE fFontMemResource; |
| 311 |
| 312 typedef LogFontTypeface INHERITED; | 312 typedef LogFontTypeface INHERITED; |
| 313 }; | 313 }; |
| 314 | 314 |
| 315 static const LOGFONT& get_default_font() { | 315 static const LOGFONT& get_default_font() { |
| 316 static LOGFONT gDefaultFont; | 316 static LOGFONT gDefaultFont; |
| 317 return gDefaultFont; | 317 return gDefaultFont; |
| 318 } | 318 } |
| 319 | 319 |
| 320 static bool FindByLogFont(SkTypeface* face, SkTypeface::Style requestedStyle, vo
id* ctx) { | 320 static bool FindByLogFont(SkTypeface* face, SkTypeface::Style requestedStyle, vo
id* ctx) { |
| 321 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face); | 321 LogFontTypeface* lface = static_cast<LogFontTypeface*>(face); |
| (...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2639 | 2639 |
| 2640 private: | 2640 private: |
| 2641 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2641 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
| 2642 }; | 2642 }; |
| 2643 | 2643 |
| 2644 /////////////////////////////////////////////////////////////////////////////// | 2644 /////////////////////////////////////////////////////////////////////////////// |
| 2645 | 2645 |
| 2646 SkFontMgr* SkFontMgr_New_GDI() { | 2646 SkFontMgr* SkFontMgr_New_GDI() { |
| 2647 return SkNEW(SkFontMgrGDI); | 2647 return SkNEW(SkFontMgrGDI); |
| 2648 } | 2648 } |
| OLD | NEW |