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 #include "SkFontConfigParser_android.h" | 8 #include "SkFontConfigParser_android.h" |
9 #include "SkTDArray.h" | 9 #include "SkTDArray.h" |
10 #include "SkTSearch.h" | 10 #include "SkTSearch.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 n = (n * 10) + d; | 84 n = (n * 10) + d; |
85 } | 85 } |
86 *value = n; | 86 *value = n; |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 namespace lmpParser { | 90 namespace lmpParser { |
91 | 91 |
92 void familyElementHandler(FontFamily* family, const char** attributes) { | 92 void familyElementHandler(FontFamily* family, const char** attributes) { |
93 // A non-fallback <family> tag must have a canonical name attribute. | 93 // A non-fallback <family> tag must have a canonical name attribute. |
94 // A (fallback) <family> tag may have lang and variant attributes. | 94 // A fallback <family> tag has no name, and may have lang and variant |
| 95 // attributes. |
| 96 family->fIsFallbackFont = true; |
95 for (size_t i = 0; attributes[i] != NULL && | 97 for (size_t i = 0; attributes[i] != NULL && |
96 attributes[i+1] != NULL; i += 2) { | 98 attributes[i+1] != NULL; i += 2) { |
97 const char* name = attributes[i]; | 99 const char* name = attributes[i]; |
98 const char* value = attributes[i+1]; | 100 const char* value = attributes[i+1]; |
99 size_t nameLen = strlen(name); | 101 size_t nameLen = strlen(name); |
100 size_t valueLen = strlen(value); | 102 size_t valueLen = strlen(value); |
101 if (nameLen == 4 && !strncmp("name", name, nameLen)) { | 103 if (nameLen == 4 && !strncmp("name", name, nameLen)) { |
102 SkAutoAsciiToLC tolc(value); | 104 SkAutoAsciiToLC tolc(value); |
103 family->fNames.push_back().set(tolc.lc()); | 105 family->fNames.push_back().set(tolc.lc()); |
| 106 family->fIsFallbackFont = false; |
104 } else if (nameLen == 4 && !strncmp("lang", name, nameLen)) { | 107 } else if (nameLen == 4 && !strncmp("lang", name, nameLen)) { |
105 family->fLanguage = SkLanguage (value); | 108 family->fLanguage = SkLanguage (value); |
106 } else if (nameLen == 7 && !strncmp("variant", name, nameLen)) { | 109 } else if (nameLen == 7 && !strncmp("variant", name, nameLen)) { |
107 // Value should be either elegant or compact. | 110 // Value should be either elegant or compact. |
108 if (valueLen == 7 && !strncmp("elegant", value, valueLen)) { | 111 if (valueLen == 7 && !strncmp("elegant", value, valueLen)) { |
109 family->fVariant = SkPaintOptionsAndroid::kElegant_Variant; | 112 family->fVariant = SkPaintOptionsAndroid::kElegant_Variant; |
110 } else if (valueLen == 7 && !strncmp("compact", value, valueLen)) { | 113 } else if (valueLen == 7 && !strncmp("compact", value, valueLen)) { |
111 family->fVariant = SkPaintOptionsAndroid::kCompact_Variant; | 114 family->fVariant = SkPaintOptionsAndroid::kCompact_Variant; |
112 } | 115 } |
113 } | 116 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 if (NULL != testFallbackConfigFile) { | 586 if (NULL != testFallbackConfigFile) { |
584 parseConfigFile(testFallbackConfigFile, fallbackFonts); | 587 parseConfigFile(testFallbackConfigFile, fallbackFonts); |
585 } | 588 } |
586 | 589 |
587 // Append all fallback fonts to system fonts | 590 // Append all fallback fonts to system fonts |
588 for (int i = 0; i < fallbackFonts.count(); ++i) { | 591 for (int i = 0; i < fallbackFonts.count(); ++i) { |
589 fallbackFonts[i]->fIsFallbackFont = true; | 592 fallbackFonts[i]->fIsFallbackFont = true; |
590 *fontFamilies.append() = fallbackFonts[i]; | 593 *fontFamilies.append() = fallbackFonts[i]; |
591 } | 594 } |
592 } | 595 } |
OLD | NEW |