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 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2554 LOGFONT lf; | 2554 LOGFONT lf; |
2555 sk_bzero(&lf, sizeof(lf)); | 2555 sk_bzero(&lf, sizeof(lf)); |
2556 lf.lfCharSet = DEFAULT_CHARSET; | 2556 lf.lfCharSet = DEFAULT_CHARSET; |
2557 | 2557 |
2558 HDC hdc = ::CreateCompatibleDC(NULL); | 2558 HDC hdc = ::CreateCompatibleDC(NULL); |
2559 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fLogFontArray,
0); | 2559 ::EnumFontFamiliesEx(hdc, &lf, enum_family_proc, (LPARAM)&fLogFontArray,
0); |
2560 ::DeleteDC(hdc); | 2560 ::DeleteDC(hdc); |
2561 } | 2561 } |
2562 | 2562 |
2563 protected: | 2563 protected: |
2564 virtual int onCountFamilies() SK_OVERRIDE { | 2564 virtual int onCountFamilies() const SK_OVERRIDE { |
2565 return fLogFontArray.count(); | 2565 return fLogFontArray.count(); |
2566 } | 2566 } |
2567 | 2567 |
2568 virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE { | 2568 virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERR
IDE { |
2569 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); | 2569 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); |
2570 tchar_to_skstring(fLogFontArray[index].elfLogFont.lfFaceName, familyName
); | 2570 tchar_to_skstring(fLogFontArray[index].elfLogFont.lfFaceName, familyName
); |
2571 } | 2571 } |
2572 | 2572 |
2573 virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE { | 2573 virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE { |
2574 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); | 2574 SkASSERT((unsigned)index < (unsigned)fLogFontArray.count()); |
2575 return SkNEW_ARGS(SkFontStyleSetGDI, (fLogFontArray[index].elfLogFont.lf
FaceName)); | 2575 return SkNEW_ARGS(SkFontStyleSetGDI, (fLogFontArray[index].elfLogFont.lf
FaceName)); |
2576 } | 2576 } |
2577 | 2577 |
2578 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) SK_OVERRIDE { | 2578 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVER
RIDE { |
2579 if (NULL == familyName) { | 2579 if (NULL == familyName) { |
2580 familyName = ""; // do we need this check??? | 2580 familyName = ""; // do we need this check??? |
2581 } | 2581 } |
2582 LOGFONT lf; | 2582 LOGFONT lf; |
2583 logfont_for_name(familyName, &lf); | 2583 logfont_for_name(familyName, &lf); |
2584 return SkNEW_ARGS(SkFontStyleSetGDI, (lf.lfFaceName)); | 2584 return SkNEW_ARGS(SkFontStyleSetGDI, (lf.lfFaceName)); |
2585 } | 2585 } |
2586 | 2586 |
2587 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 2587 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
2588 const SkFontStyle& fontstyle) SK_OVER
RIDE { | 2588 const SkFontStyle& fontstyle) const S
K_OVERRIDE { |
2589 // could be in base impl | 2589 // could be in base impl |
2590 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); | 2590 SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName)); |
2591 return sset->matchStyle(fontstyle); | 2591 return sset->matchStyle(fontstyle); |
2592 } | 2592 } |
2593 | 2593 |
2594 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 2594 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, |
2595 const SkFontStyle& fontstyle) SK_OVERRI
DE { | 2595 const SkFontStyle& fontstyle) const SK_
OVERRIDE { |
2596 // could be in base impl | 2596 // could be in base impl |
2597 SkString familyName; | 2597 SkString familyName; |
2598 ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); | 2598 ((LogFontTypeface*)familyMember)->getFamilyName(&familyName); |
2599 return this->matchFamilyStyle(familyName.c_str(), fontstyle); | 2599 return this->matchFamilyStyle(familyName.c_str(), fontstyle); |
2600 } | 2600 } |
2601 | 2601 |
2602 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) SK_OV
ERRIDE { | 2602 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const
SK_OVERRIDE { |
2603 return create_from_stream(stream); | 2603 return create_from_stream(stream); |
2604 } | 2604 } |
2605 | 2605 |
2606 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) SK_OVERRIDE
{ | 2606 virtual SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OV
ERRIDE { |
2607 // could be in base impl | 2607 // could be in base impl |
2608 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data))); | 2608 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data))); |
2609 return this->createFromStream(stream); | 2609 return this->createFromStream(stream); |
2610 } | 2610 } |
2611 | 2611 |
2612 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) SK_OVE
RRIDE { | 2612 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
SK_OVERRIDE { |
2613 // could be in base impl | 2613 // could be in base impl |
2614 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 2614 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); |
2615 return this->createFromStream(stream); | 2615 return this->createFromStream(stream); |
2616 } | 2616 } |
2617 | 2617 |
2618 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 2618 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
2619 unsigned styleBits) SK_OVERRIDE { | 2619 unsigned styleBits) const SK_OVER
RIDE { |
2620 LOGFONT lf; | 2620 LOGFONT lf; |
2621 if (NULL == familyName) { | 2621 if (NULL == familyName) { |
2622 lf = get_default_font(); | 2622 lf = get_default_font(); |
2623 } else { | 2623 } else { |
2624 logfont_for_name(familyName, &lf); | 2624 logfont_for_name(familyName, &lf); |
2625 } | 2625 } |
2626 setStyle(&lf, (SkTypeface::Style)styleBits); | 2626 setStyle(&lf, (SkTypeface::Style)styleBits); |
2627 return SkCreateTypefaceFromLOGFONT(lf); | 2627 return SkCreateTypefaceFromLOGFONT(lf); |
2628 } | 2628 } |
2629 | 2629 |
2630 private: | 2630 private: |
2631 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2631 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2632 }; | 2632 }; |
2633 | 2633 |
2634 /////////////////////////////////////////////////////////////////////////////// | 2634 /////////////////////////////////////////////////////////////////////////////// |
2635 | 2635 |
2636 SkFontMgr* SkFontMgr_New_GDI() { | 2636 SkFontMgr* SkFontMgr_New_GDI() { |
2637 return SkNEW(SkFontMgrGDI); | 2637 return SkNEW(SkFontMgrGDI); |
2638 } | 2638 } |
OLD | NEW |