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 "SkFontHost.h" | 8 #include "SkFontHost.h" |
9 #include "SkFontHost_FreeType_common.h" | 9 #include "SkFontHost_FreeType_common.h" |
10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 | 794 |
795 if (NULL == tf) { | 795 if (NULL == tf) { |
796 tf = find_best_face(gDefaultFamily, style); | 796 tf = find_best_face(gDefaultFamily, style); |
797 } | 797 } |
798 | 798 |
799 // we ref(), since the semantic is to return a new instance | 799 // we ref(), since the semantic is to return a new instance |
800 tf->ref(); | 800 tf->ref(); |
801 return tf; | 801 return tf; |
802 } | 802 } |
803 | 803 |
804 SkTypeface* SkAndroidNextLogicalTypeface(SkFontID currFontID, | 804 SkTypeface* SkAndroidNextLogicalTypeface(const SkScalerContextRec& rec) { |
805 SkFontID origFontID) { | 805 #if !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
806 #if defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) | |
807 // Skia does not support font fallback for ndk applications in order to | 806 // Skia does not support font fallback for ndk applications in order to |
808 // enable clients such as WebKit to customize their font selection. | 807 // enable clients such as WebKit to customize their font selection. |
809 // Clients can use GetFallbackFamilyNameForChar() to get the fallback | 808 // Clients can use GetFallbackFamilyNameForChar() to get the fallback |
810 // font for individual characters. | 809 // font for individual characters. |
811 return NULL; | 810 return NULL; |
812 #else | 811 #endif |
813 SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex); | 812 SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex); |
814 | 813 |
815 load_system_fonts(); | 814 load_system_fonts(); |
816 | 815 |
817 const SkTypeface* origTypeface = find_from_uniqueID(origFontID); | 816 const SkTypeface* origTypeface = find_from_uniqueID(rec.fOrigFontID); |
818 const SkTypeface* currTypeface = find_from_uniqueID(currFontID); | 817 const SkTypeface* currTypeface = find_from_uniqueID(rec.fFontID); |
819 | 818 |
820 SkASSERT(origTypeface != 0); | 819 SkASSERT(origTypeface != 0); |
821 SkASSERT(currTypeface != 0); | 820 SkASSERT(currTypeface != 0); |
822 SkASSERT(gFallbackFonts); | 821 SkASSERT(gFallbackFonts); |
823 | 822 |
824 // Our fallback list always stores the id of the plain in each fallback | 823 // Our fallback list always stores the id of the plain in each fallback |
825 // family, so we transform currFontID to its plain equivalent. | 824 // family, so we transform currFontID to its plain equivalent. |
826 currFontID = find_typeface(currTypeface, SkTypeface::kNormal)->uniqueID(); | 825 uint32_t currFontID = find_typeface(currTypeface, SkTypeface::kNormal)->uniq
ueID(); |
827 | 826 |
828 /* First see if fontID is already one of our fallbacks. If so, return | 827 /* First see if fontID is already one of our fallbacks. If so, return |
829 its successor. If fontID is not in our list, then return the first one | 828 its successor. If fontID is not in our list, then return the first one |
830 in our list. Note: list is zero-terminated, and returning zero means | 829 in our list. Note: list is zero-terminated, and returning zero means |
831 we have no more fonts to use for fallbacks. | 830 we have no more fonts to use for fallbacks. |
832 */ | 831 */ |
833 const uint32_t* list = gFallbackFonts; | 832 const uint32_t* list = gFallbackFonts; |
834 for (int i = 0; list[i] != 0; i++) { | 833 for (int i = 0; list[i] != 0; i++) { |
835 if (list[i] == currFontID) { | 834 if (list[i] == currFontID) { |
836 if (list[i+1] == 0) | 835 if (list[i+1] == 0) |
837 return NULL; | 836 return NULL; |
838 const SkTypeface* nextTypeface = find_from_uniqueID(list[i+1]); | 837 const SkTypeface* nextTypeface = find_from_uniqueID(list[i+1]); |
839 return SkRef(find_typeface(nextTypeface, origTypeface->style())); | 838 return SkRef(find_typeface(nextTypeface, origTypeface->style())); |
840 } | 839 } |
841 } | 840 } |
842 | 841 |
843 // If we get here, currFontID was not a fallback, so we start at the | 842 // If we get here, currFontID was not a fallback, so we start at the |
844 // beginning of our list. Assuming there is at least one fallback font, | 843 // beginning of our list. Assuming there is at least one fallback font, |
845 // i.e. gFallbackFonts[0] != 0. | 844 // i.e. gFallbackFonts[0] != 0. |
846 const SkTypeface* firstTypeface = find_from_uniqueID(list[0]); | 845 const SkTypeface* firstTypeface = find_from_uniqueID(list[0]); |
847 return SkRef(find_typeface(firstTypeface, origTypeface->style())); | 846 return SkRef(find_typeface(firstTypeface, origTypeface->style())); |
848 #endif | |
849 } | 847 } |
850 | 848 |
851 /////////////////////////////////////////////////////////////////////////////// | 849 /////////////////////////////////////////////////////////////////////////////// |
852 | 850 |
853 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { | 851 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { |
854 if (NULL == stream || stream->getLength() <= 0) { | 852 if (NULL == stream || stream->getLength() <= 0) { |
855 return NULL; | 853 return NULL; |
856 } | 854 } |
857 | 855 |
858 bool isFixedPitch; | 856 bool isFixedPitch; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 } | 933 } |
936 | 934 |
937 /////////////////////////////////////////////////////////////////////////////// | 935 /////////////////////////////////////////////////////////////////////////////// |
938 | 936 |
939 #include "SkFontMgr.h" | 937 #include "SkFontMgr.h" |
940 | 938 |
941 SkFontMgr* SkFontMgr::Factory() { | 939 SkFontMgr* SkFontMgr::Factory() { |
942 // todo | 940 // todo |
943 return NULL; | 941 return NULL; |
944 } | 942 } |
OLD | NEW |