djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SKFONTCONFIGPARSER_ANDROID_H_ |
| 9 | #define SKFONTCONFIGPARSER_ANDROID_H_ |
| 10 | |
Derek Sollenberger | da7a944 | 2014-08-06 16:34:40 -0400 | [diff] [blame^] | 11 | #include "SkTypes.h" |
| 12 | |
| 13 | #include "SkPaintOptionsAndroid.h" |
djsollen@google.com | 9a70f34 | 2013-06-25 18:07:45 +0000 | [diff] [blame] | 14 | #include "SkString.h" |
djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 15 | #include "SkTDArray.h" |
| 16 | |
| 17 | struct FontFileInfo { |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 18 | FontFileInfo() : fIndex(0), fWeight(0) { } |
bungeman | 8d84c99 | 2014-07-24 08:05:09 -0700 | [diff] [blame] | 19 | |
commit-bot@chromium.org | 31db71d | 2014-04-04 18:14:39 +0000 | [diff] [blame] | 20 | SkString fFileName; |
bungeman | 8d84c99 | 2014-07-24 08:05:09 -0700 | [diff] [blame] | 21 | int fIndex; |
Derek Sollenberger | da7a944 | 2014-08-06 16:34:40 -0400 | [diff] [blame^] | 22 | SkPaintOptionsAndroid fPaintOptions; |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 23 | int fWeight; |
djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | /** |
| 27 | * The FontFamily data structure is created during parsing and handed back to |
| 28 | * Skia to fold into its representation of font families. fNames is the list of |
| 29 | * font names that alias to a font family. fontFileArray is the list of information |
| 30 | * about each file. Order is the priority order for the font. This is |
| 31 | * used internally to determine the order in which to place fallback fonts as |
| 32 | * they are read from the configuration files. |
| 33 | */ |
| 34 | struct FontFamily { |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 35 | FontFamily() |
Derek Sollenberger | da7a944 | 2014-08-06 16:34:40 -0400 | [diff] [blame^] | 36 | : fVariant(SkPaintOptionsAndroid::kDefault_Variant) |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 37 | , order(-1) |
| 38 | , fIsFallbackFont(false) { } |
djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 39 | |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 40 | SkTArray<SkString> fNames; |
| 41 | SkTArray<FontFileInfo> fFontFiles; |
| 42 | SkLanguage fLanguage; |
Derek Sollenberger | da7a944 | 2014-08-06 16:34:40 -0400 | [diff] [blame^] | 43 | SkPaintOptionsAndroid::FontVariant fVariant; |
tomhudson | 0754475 | 2014-08-05 13:35:00 -0700 | [diff] [blame] | 44 | int order; // only used internally by SkFontConfigParser |
| 45 | bool fIsFallbackFont; |
djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | namespace SkFontConfigParser { |
| 49 | |
| 50 | /** |
| 51 | * Parses all system font configuration files and returns the results in an |
| 52 | * array of FontFamily structures. |
| 53 | */ |
| 54 | void GetFontFamilies(SkTDArray<FontFamily*> &fontFamilies); |
| 55 | |
| 56 | /** |
| 57 | * Parses all test font configuration files and returns the results in an |
| 58 | * array of FontFamily structures. |
| 59 | */ |
| 60 | void GetTestFontFamilies(SkTDArray<FontFamily*> &fontFamilies, |
| 61 | const char* testMainConfigFile, |
| 62 | const char* testFallbackConfigFile); |
| 63 | |
djsollen@google.com | bfae9d3 | 2013-05-21 16:53:50 +0000 | [diff] [blame] | 64 | } // SkFontConfigParser namespace |
| 65 | |
| 66 | #endif /* SKFONTCONFIGPARSER_ANDROID_H_ */ |