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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 const uint32_t*, uint32_t) const SK_OVERRIDE; | 268 const uint32_t*, uint32_t) const SK_OVERRIDE; |
269 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; | 269 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE
; |
270 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, | 270 virtual int onCharsToGlyphs(const void* chars, Encoding encoding, |
271 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; | 271 uint16_t glyphs[], int glyphCount) const SK_OVER
RIDE; |
272 virtual int onCountGlyphs() const SK_OVERRIDE; | 272 virtual int onCountGlyphs() const SK_OVERRIDE; |
273 virtual int onGetUPEM() const SK_OVERRIDE; | 273 virtual int onGetUPEM() const SK_OVERRIDE; |
274 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; | 274 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_
OVERRIDE; |
275 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; | 275 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE; |
276 virtual size_t onGetTableData(SkFontTableTag, size_t offset, | 276 virtual size_t onGetTableData(SkFontTableTag, size_t offset, |
277 size_t length, void* data) const SK_OVERRIDE; | 277 size_t length, void* data) const SK_OVERRIDE; |
278 virtual SkTypeface* onRefMatchingStyle(Style) const SK_OVERRIDE; | |
279 }; | 278 }; |
280 | 279 |
281 class FontMemResourceTypeface : public LogFontTypeface { | 280 class FontMemResourceTypeface : public LogFontTypeface { |
282 public: | 281 public: |
283 /** | 282 /** |
284 * Takes ownership of fontMemResource. | 283 * Takes ownership of fontMemResource. |
285 */ | 284 */ |
286 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : | 285 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF
ONT& lf, HANDLE fontMemResource) : |
287 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { | 286 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour
ce) { |
288 } | 287 } |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 } else if (familyFace) { | 2444 } else if (familyFace) { |
2446 LogFontTypeface* face = (LogFontTypeface*)familyFace; | 2445 LogFontTypeface* face = (LogFontTypeface*)familyFace; |
2447 lf = face->fLogFont; | 2446 lf = face->fLogFont; |
2448 } else { | 2447 } else { |
2449 logfont_for_name(familyName, &lf); | 2448 logfont_for_name(familyName, &lf); |
2450 } | 2449 } |
2451 setStyle(&lf, (SkTypeface::Style)styleBits); | 2450 setStyle(&lf, (SkTypeface::Style)styleBits); |
2452 return SkCreateTypefaceFromLOGFONT(lf); | 2451 return SkCreateTypefaceFromLOGFONT(lf); |
2453 } | 2452 } |
2454 | 2453 |
2455 SkTypeface* LogFontTypeface::onRefMatchingStyle(Style style) const { | |
2456 return create_typeface(this, NULL, style); | |
2457 } | |
2458 | |
2459 /////////////////////////////////////////////////////////////////////////////// | 2454 /////////////////////////////////////////////////////////////////////////////// |
2460 | 2455 |
2461 #include "SkFontMgr.h" | 2456 #include "SkFontMgr.h" |
2462 #include "SkDataTable.h" | 2457 #include "SkDataTable.h" |
2463 | 2458 |
2464 static bool valid_logfont_for_enum(const LOGFONT& lf) { | 2459 static bool valid_logfont_for_enum(const LOGFONT& lf) { |
2465 // TODO: Vector FON is unsupported and should not be listed. | 2460 // TODO: Vector FON is unsupported and should not be listed. |
2466 return | 2461 return |
2467 // Ignore implicit vertical variants. | 2462 // Ignore implicit vertical variants. |
2468 lf.lfFaceName[0] && lf.lfFaceName[0] != '@' | 2463 lf.lfFaceName[0] && lf.lfFaceName[0] != '@' |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 unsigned styleBits) SK_OVERRIDE { | 2605 unsigned styleBits) SK_OVERRIDE { |
2611 return create_typeface(NULL, familyName, styleBits); | 2606 return create_typeface(NULL, familyName, styleBits); |
2612 } | 2607 } |
2613 | 2608 |
2614 private: | 2609 private: |
2615 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2610 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2616 }; | 2611 }; |
2617 | 2612 |
2618 /////////////////////////////////////////////////////////////////////////////// | 2613 /////////////////////////////////////////////////////////////////////////////// |
2619 | 2614 |
2620 #ifndef SK_FONTHOST_USES_FONTMGR | |
2621 | |
2622 SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, | |
2623 const char familyName[], | |
2624 SkTypeface::Style styleBits) { | |
2625 return create_typeface(familyFace, familyName, styleBits); | |
2626 } | |
2627 | |
2628 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { | |
2629 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | |
2630 return stream.get() ? CreateTypefaceFromStream(stream) : NULL; | |
2631 } | |
2632 | |
2633 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | |
2634 return create_from_stream(stream); | |
2635 } | |
2636 | |
2637 #endif | |
2638 | |
2639 SkFontMgr* SkFontMgr_New_GDI() { | 2615 SkFontMgr* SkFontMgr_New_GDI() { |
2640 return SkNEW(SkFontMgrGDI); | 2616 return SkNEW(SkFontMgrGDI); |
2641 } | 2617 } |
OLD | NEW |