Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/ports/SkFontConfigInterface_android.cpp

Issue 107663012: Android now uses Harfbuzz-NG. No need to keep code specific to the old version of Harfbuzz around! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 The Android Open Source Project 3 * Copyright 2013 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 "SkFontConfigInterface.h" 9 #include "SkFontConfigInterface.h"
10 #include "SkTypeface_android.h" 10 #include "SkTypeface_android.h"
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface(); 774 SkFontConfigInterfaceAndroid* fontConfig = getSingletonInterface();
775 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options, 775 return fontConfig->getTypefaceForGlyphID(glyphID, origTypeface, options,
776 lowerBounds, upperBounds); 776 lowerBounds, upperBounds);
777 } 777 }
778 778
779 /////////////////////////////////////////////////////////////////////////////// 779 ///////////////////////////////////////////////////////////////////////////////
780 780
781 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 781 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
782 782
783 struct HB_UnicodeMapping { 783 struct HB_UnicodeMapping {
784 // TODO: when the WebView no longer needs harfbuzz_old, remove
785 HB_Script script_old;
786 hb_script_t script; 784 hb_script_t script;
787 const SkUnichar unicode; 785 const SkUnichar unicode;
788 }; 786 };
789 787
790 /* 788 /*
791 * The following scripts are not complex fonts and we do not expect them to be p arsed by this table 789 * The following scripts are not complex fonts and we do not expect them to be p arsed by this table
792 * HB_SCRIPT_COMMON, 790 * HB_SCRIPT_COMMON,
793 * HB_SCRIPT_GREEK, 791 * HB_SCRIPT_GREEK,
794 * HB_SCRIPT_CYRILLIC, 792 * HB_SCRIPT_CYRILLIC,
795 * HB_SCRIPT_HANGUL 793 * HB_SCRIPT_HANGUL
796 * HB_SCRIPT_INHERITED 794 * HB_SCRIPT_INHERITED
797 */ 795 */
798 796
799 /* Harfbuzz (old) is missing a number of scripts in its table. For these, 797 /* Harfbuzz (old) is missing a number of scripts in its table. For these,
800 * we include a value which can never happen. We won't get complex script 798 * we include a value which can never happen. We won't get complex script
801 * shaping in these cases, but the library wouldn't know how to shape 799 * shaping in these cases, but the library wouldn't know how to shape
802 * them anyway. */ 800 * them anyway. */
803 #define HB_Script_Unknown HB_ScriptCount 801 #define HB_Script_Unknown HB_ScriptCount
804 802
805 static HB_UnicodeMapping HB_UnicodeMappingArray[] = { 803 static HB_UnicodeMapping HB_UnicodeMappingArray[] = {
806 {HB_Script_Armenian, HB_SCRIPT_ARMENIAN, 0x0531}, 804 {HB_SCRIPT_ARMENIAN, 0x0531},
807 {HB_Script_Hebrew, HB_SCRIPT_HEBREW, 0x0591}, 805 {HB_SCRIPT_HEBREW, 0x0591},
808 {HB_Script_Arabic, HB_SCRIPT_ARABIC, 0x0600}, 806 {HB_SCRIPT_ARABIC, 0x0600},
809 {HB_Script_Syriac, HB_SCRIPT_SYRIAC, 0x0710}, 807 {HB_SCRIPT_SYRIAC, 0x0710},
810 {HB_Script_Thaana, HB_SCRIPT_THAANA, 0x0780}, 808 {HB_SCRIPT_THAANA, 0x0780},
811 {HB_Script_Nko, HB_SCRIPT_NKO, 0x07C0}, 809 {HB_SCRIPT_NKO, 0x07C0},
812 {HB_Script_Devanagari, HB_SCRIPT_DEVANAGARI, 0x0901}, 810 {HB_SCRIPT_DEVANAGARI, 0x0901},
813 {HB_Script_Bengali, HB_SCRIPT_BENGALI, 0x0981}, 811 {HB_SCRIPT_BENGALI, 0x0981},
814 {HB_Script_Gurmukhi, HB_SCRIPT_GURMUKHI, 0x0A10}, 812 {HB_SCRIPT_GURMUKHI, 0x0A10},
815 {HB_Script_Gujarati, HB_SCRIPT_GUJARATI, 0x0A90}, 813 {HB_SCRIPT_GUJARATI, 0x0A90},
816 {HB_Script_Oriya, HB_SCRIPT_ORIYA, 0x0B10}, 814 {HB_SCRIPT_ORIYA, 0x0B10},
817 {HB_Script_Tamil, HB_SCRIPT_TAMIL, 0x0B82}, 815 {HB_SCRIPT_TAMIL, 0x0B82},
818 {HB_Script_Telugu, HB_SCRIPT_TELUGU, 0x0C10}, 816 {HB_SCRIPT_TELUGU, 0x0C10},
819 {HB_Script_Kannada, HB_SCRIPT_KANNADA, 0x0C90}, 817 {HB_SCRIPT_KANNADA, 0x0C90},
820 {HB_Script_Malayalam, HB_SCRIPT_MALAYALAM, 0x0D10}, 818 {HB_SCRIPT_MALAYALAM, 0x0D10},
821 {HB_Script_Sinhala, HB_SCRIPT_SINHALA, 0x0D90}, 819 {HB_SCRIPT_SINHALA, 0x0D90},
822 {HB_Script_Thai, HB_SCRIPT_THAI, 0x0E01}, 820 {HB_SCRIPT_THAI, 0x0E01},
823 {HB_Script_Lao, HB_SCRIPT_LAO, 0x0E81}, 821 {HB_SCRIPT_LAO, 0x0E81},
824 {HB_Script_Tibetan, HB_SCRIPT_TIBETAN, 0x0F00}, 822 {HB_SCRIPT_TIBETAN, 0x0F00},
825 {HB_Script_Myanmar, HB_SCRIPT_MYANMAR, 0x1000}, 823 {HB_SCRIPT_MYANMAR, 0x1000},
826 {HB_Script_Georgian, HB_SCRIPT_GEORGIAN, 0x10A0}, 824 {HB_SCRIPT_GEORGIAN, 0x10A0},
827 {HB_Script_Unknown, HB_SCRIPT_ETHIOPIC, 0x1200}, 825 {HB_SCRIPT_ETHIOPIC, 0x1200},
828 {HB_Script_Unknown, HB_SCRIPT_CHEROKEE, 0x13A0}, 826 {HB_SCRIPT_CHEROKEE, 0x13A0},
829 {HB_Script_Ogham, HB_SCRIPT_OGHAM, 0x1680}, 827 {HB_SCRIPT_OGHAM, 0x1680},
830 {HB_Script_Runic, HB_SCRIPT_RUNIC, 0x16A0}, 828 {HB_SCRIPT_RUNIC, 0x16A0},
831 {HB_Script_Khmer, HB_SCRIPT_KHMER, 0x1780}, 829 {HB_SCRIPT_KHMER, 0x1780},
832 {HB_Script_Unknown, HB_SCRIPT_TAI_LE, 0x1950}, 830 {HB_SCRIPT_TAI_LE, 0x1950},
833 {HB_Script_Unknown, HB_SCRIPT_NEW_TAI_LUE, 0x1980}, 831 {HB_SCRIPT_NEW_TAI_LUE, 0x1980},
834 {HB_Script_Unknown, HB_SCRIPT_TAI_THAM, 0x1A20}, 832 {HB_SCRIPT_TAI_THAM, 0x1A20},
835 {HB_Script_Unknown, HB_SCRIPT_CHAM, 0xAA00}, 833 {HB_SCRIPT_CHAM, 0xAA00},
836 }; 834 };
837 835
838 static hb_script_t getHBScriptFromHBScriptOld(HB_Script script_old) {
839 hb_script_t script = HB_SCRIPT_INVALID;
840 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMa pping);
841 for (int i = 0; i < numSupportedFonts; i++) {
842 if (script_old == HB_UnicodeMappingArray[i].script_old) {
843 script = HB_UnicodeMappingArray[i].script;
844 break;
845 }
846 }
847 return script;
848 }
849
850 // returns 0 for "Not Found" 836 // returns 0 for "Not Found"
851 static SkUnichar getUnicodeFromHBScript(hb_script_t script) { 837 static SkUnichar getUnicodeFromHBScript(hb_script_t script) {
852 SkUnichar unichar = 0; 838 SkUnichar unichar = 0;
853 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMa pping); 839 int numSupportedFonts = sizeof(HB_UnicodeMappingArray) / sizeof(HB_UnicodeMa pping);
854 for (int i = 0; i < numSupportedFonts; i++) { 840 for (int i = 0; i < numSupportedFonts; i++) {
855 if (script == HB_UnicodeMappingArray[i].script) { 841 if (script == HB_UnicodeMappingArray[i].script) {
856 unichar = HB_UnicodeMappingArray[i].unicode; 842 unichar = HB_UnicodeMappingArray[i].unicode;
857 break; 843 break;
858 } 844 }
859 } 845 }
(...skipping 17 matching lines...) Expand all
877 } 863 }
878 if (first.style != second.style) { 864 if (first.style != second.style) {
879 return (first.style > second.style) ? 1 : -1; 865 return (first.style > second.style) ? 1 : -1;
880 } 866 }
881 if (first.fontVariant != second.fontVariant) { 867 if (first.fontVariant != second.fontVariant) {
882 return (first.fontVariant > second.fontVariant) ? 1 : -1; 868 return (first.fontVariant > second.fontVariant) ? 1 : -1;
883 } 869 }
884 return 0; 870 return 0;
885 } 871 }
886 872
887 SkTypeface* SkCreateTypefaceForScriptNG(hb_script_t script, SkTypeface::Style st yle, 873 SkTypeface* SkCreateTypefaceForScript(hb_script_t script, SkTypeface::Style styl e,
888 SkPaintOptionsAndroid::FontVariant fontV ariant) { 874 SkPaintOptionsAndroid::FontVariant fontVar iant) {
889 SkAutoMutexAcquire ac(gTypefaceTableMutex); 875 SkAutoMutexAcquire ac(gTypefaceTableMutex);
890 876
891 TypefaceLookupStruct key; 877 TypefaceLookupStruct key;
892 key.script = script; 878 key.script = script;
893 key.style = style; 879 key.style = style;
894 key.fontVariant = fontVariant; 880 key.fontVariant = fontVariant;
895 881
896 int index = SkTSearch<TypefaceLookupStruct>( 882 int index = SkTSearch<TypefaceLookupStruct>(
897 (const TypefaceLookupStruct*) gTypefaceTable.begin(), 883 (const TypefaceLookupStruct*) gTypefaceTable.begin(),
898 gTypefaceTable.count(), key, sizeof(TypefaceLookupStruct), 884 gTypefaceTable.count(), key, sizeof(TypefaceLookupStruct),
(...skipping 14 matching lines...) Expand all
913 899
914 // add to the lookup table 900 // add to the lookup table
915 key.typeface = retTypeface; 901 key.typeface = retTypeface;
916 *gTypefaceTable.insert(~index) = key; 902 *gTypefaceTable.insert(~index) = key;
917 } 903 }
918 904
919 // we ref(), the caller is expected to unref when they are done 905 // we ref(), the caller is expected to unref when they are done
920 return SkSafeRef(retTypeface); 906 return SkSafeRef(retTypeface);
921 } 907 }
922 908
923 SkTypeface* SkCreateTypefaceForScript(HB_Script script, SkTypeface::Style style,
924 SkPaintOptionsAndroid::FontVariant fontVar iant) {
925 return SkCreateTypefaceForScriptNG(getHBScriptFromHBScriptOld(script), style , fontVariant);
926 }
927
928 #endif 909 #endif
929 910
930 /////////////////////////////////////////////////////////////////////////////// 911 ///////////////////////////////////////////////////////////////////////////////
931 912
932 SkFontMgr* SkFontMgr::Factory() { 913 SkFontMgr* SkFontMgr::Factory() {
933 return NULL; 914 return NULL;
934 } 915 }
OLDNEW
« include/ports/SkTypeface_android.h ('K') | « include/ports/SkTypeface_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698