Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 The Android Open Source Project | 2 * Copyright 2011 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 #ifndef SKFONTCONFIGPARSER_ANDROID_H_ | 8 #ifndef SKFONTCONFIGPARSER_ANDROID_H_ |
| 9 #define SKFONTCONFIGPARSER_ANDROID_H_ | 9 #define SKFONTCONFIGPARSER_ANDROID_H_ |
| 10 | 10 |
| 11 #include "SkTypes.h" | |
| 12 | |
| 13 #include "SkPaintOptionsAndroid.h" | |
| 14 #include "SkString.h" | 11 #include "SkString.h" |
| 15 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
| 16 | 13 |
| 14 /** \class SkLanguage | |
| 15 | |
| 16 The SkLanguage class represents a human written language, and is used by | |
| 17 text draw operations to determine which glyph to draw when drawing | |
| 18 characters with variants (ie Han-derived characters). | |
| 19 */ | |
| 20 class SkLanguage { | |
| 21 public: | |
| 22 SkLanguage() { } | |
| 23 SkLanguage(const SkString& tag) : fTag(tag) { } | |
| 24 SkLanguage(const char* tag) : fTag(tag) { } | |
| 25 SkLanguage(const char* tag, size_t len) : fTag(tag, len) { } | |
| 26 SkLanguage(const SkLanguage& b) : fTag(b.fTag) { } | |
| 27 | |
| 28 /** Gets a BCP 47 language identifier for this SkLanguage. | |
| 29 @return a BCP 47 language identifier representing this language | |
| 30 */ | |
| 31 const SkString& getTag() const { return fTag; } | |
| 32 | |
| 33 /** Performs BCP 47 fallback to return an SkLanguage one step more general. | |
| 34 @return an SkLanguage one step more general | |
| 35 */ | |
| 36 SkLanguage getParent() const; | |
| 37 | |
| 38 bool operator==(const SkLanguage& b) const { | |
| 39 return fTag == b.fTag; | |
| 40 } | |
| 41 bool operator!=(const SkLanguage& b) const { | |
| 42 return fTag != b.fTag; | |
| 43 } | |
| 44 SkLanguage& operator=(const SkLanguage& b) { | |
| 45 fTag = b.fTag; | |
| 46 return *this; | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 //! BCP 47 language identifier | |
| 51 SkString fTag; | |
| 52 }; | |
| 53 | |
| 54 enum FontVariants { | |
| 55 kDefault_FontVariant = 0x01, | |
| 56 kCompact_FontVariant = 0x02, | |
| 57 kElegant_FontVariant = 0x04, | |
| 58 kLast_FontVariant = kElegant_FontVariant, | |
| 59 }; | |
| 60 typedef uint32_t FontVariant; | |
|
tomhudson
2014/08/13 19:52:28
Why are these a bitfield masquerading as an enum?
djsollen
2014/08/13 20:00:22
The initial intent was to match the values used by
| |
| 61 | |
| 17 struct FontFileInfo { | 62 struct FontFileInfo { |
| 18 FontFileInfo() : fIndex(0), fWeight(0) { } | 63 FontFileInfo() : fIndex(0), fWeight(0) { } |
| 19 | 64 |
| 20 SkString fFileName; | 65 SkString fFileName; |
| 21 int fIndex; | 66 int fIndex; |
| 22 SkPaintOptionsAndroid fPaintOptions; | |
| 23 int fWeight; | 67 int fWeight; |
| 24 }; | 68 }; |
| 25 | 69 |
| 26 /** | 70 /** |
| 27 * A font family provides one or more names for a collection of fonts, each of | 71 * A font family provides one or more names for a collection of fonts, each of |
| 28 * which has a different style (normal, italic) or weight (thin, light, bold, | 72 * which has a different style (normal, italic) or weight (thin, light, bold, |
| 29 * etc). | 73 * etc). |
| 30 * Some fonts may occur in compact variants for use in the user interface. | 74 * Some fonts may occur in compact variants for use in the user interface. |
| 31 * Android distinguishes "fallback" fonts to support non-ASCII character sets. | 75 * Android distinguishes "fallback" fonts to support non-ASCII character sets. |
| 32 */ | 76 */ |
| 33 struct FontFamily { | 77 struct FontFamily { |
| 34 FontFamily() | 78 FontFamily() |
| 35 : fVariant(SkPaintOptionsAndroid::kDefault_Variant) | 79 : fVariant(kDefault_FontVariant) |
| 36 , fOrder(-1) | 80 , fOrder(-1) |
| 37 , fIsFallbackFont(false) { } | 81 , fIsFallbackFont(false) { } |
| 38 | 82 |
| 39 SkTArray<SkString> fNames; | 83 SkTArray<SkString> fNames; |
| 40 SkTArray<FontFileInfo> fFonts; | 84 SkTArray<FontFileInfo> fFonts; |
| 41 SkLanguage fLanguage; | 85 SkLanguage fLanguage; |
| 42 SkPaintOptionsAndroid::FontVariant fVariant; | 86 FontVariant fVariant; |
| 43 int fOrder; // internal to SkFontConfigParser | 87 int fOrder; // internal to SkFontConfigParser |
| 44 bool fIsFallbackFont; | 88 bool fIsFallbackFont; |
| 45 }; | 89 }; |
| 46 | 90 |
| 47 namespace SkFontConfigParser { | 91 namespace SkFontConfigParser { |
| 48 | 92 |
| 49 /** | 93 /** |
| 50 * Parses all system font configuration files and returns the results in an | 94 * Parses all system font configuration files and returns the results in an |
| 51 * array of FontFamily structures. | 95 * array of FontFamily structures. |
| 52 */ | 96 */ |
| 53 void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies); | 97 void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies); |
| 54 | 98 |
| 55 /** | 99 /** |
| 56 * Parses all test font configuration files and returns the results in an | 100 * Parses all test font configuration files and returns the results in an |
| 57 * array of FontFamily structures. | 101 * array of FontFamily structures. |
| 58 */ | 102 */ |
| 59 void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies, | 103 void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies, |
| 60 const char* testMainConfigFile, | 104 const char* testMainConfigFile, |
| 61 const char* testFallbackConfigFile); | 105 const char* testFallbackConfigFile); |
| 62 | 106 |
| 63 } // SkFontConfigParser namespace | 107 } // SkFontConfigParser namespace |
| 64 | 108 |
| 65 #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */ | 109 #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */ |
| OLD | NEW |