| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void familyElementHandler(FontFamily* family, const char** attributes) { | 85 void familyElementHandler(FontFamily* family, const char** attributes) { |
| 86 // A non-fallback <family> tag must have a canonical name attribute. | 86 // A non-fallback <family> tag must have a canonical name attribute. |
| 87 // A (fallback) <family> tag may have lang and variant attributes. | 87 // A (fallback) <family> tag may have lang and variant attributes. |
| 88 for (size_t i = 0; attributes[i] != NULL && | 88 for (size_t i = 0; attributes[i] != NULL && |
| 89 attributes[i+1] != NULL; i += 2) { | 89 attributes[i+1] != NULL; i += 2) { |
| 90 const char* name = attributes[i]; | 90 const char* name = attributes[i]; |
| 91 const char* value = attributes[i+1]; | 91 const char* value = attributes[i+1]; |
| 92 size_t nameLen = strlen(name); | 92 size_t nameLen = strlen(name); |
| 93 size_t valueLen = strlen(value); | 93 size_t valueLen = strlen(value); |
| 94 if (nameLen == 4 && !strncmp("name", name, nameLen)) { | 94 if (nameLen == 4 && !strncmp("name", name, nameLen)) { |
| 95 family->fNames.push_back().set(value); | 95 SkAutoAsciiToLC tolc(value); |
| 96 family->fNames.push_back().set(tolc.lc()); |
| 96 } else if (nameLen == 4 && !strncmp("lang", name, nameLen)) { | 97 } else if (nameLen == 4 && !strncmp("lang", name, nameLen)) { |
| 97 family->fLanguage = SkLanguage (value); | 98 family->fLanguage = SkLanguage (value); |
| 98 } else if (nameLen == 7 && !strncmp("variant", name, nameLen)) { | 99 } else if (nameLen == 7 && !strncmp("variant", name, nameLen)) { |
| 99 // Value should be either elegant or compact. | 100 // Value should be either elegant or compact. |
| 100 if (valueLen == 7 && !strncmp("elegant", value, valueLen)) { | 101 if (valueLen == 7 && !strncmp("elegant", value, valueLen)) { |
| 101 family->fVariant = SkPaintOptionsAndroid::kElegant_Variant; | 102 family->fVariant = SkPaintOptionsAndroid::kElegant_Variant; |
| 102 } else if (valueLen == 7 && !strncmp("compact", value, valueLen)) { | 103 } else if (valueLen == 7 && !strncmp("compact", value, valueLen)) { |
| 103 family->fVariant = SkPaintOptionsAndroid::kCompact_Variant; | 104 family->fVariant = SkPaintOptionsAndroid::kCompact_Variant; |
| 104 } | 105 } |
| 105 } | 106 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 162 |
| 162 SkString aliasName; | 163 SkString aliasName; |
| 163 SkString to; | 164 SkString to; |
| 164 int weight = 0; | 165 int weight = 0; |
| 165 for (size_t i = 0; attributes[i] != NULL && | 166 for (size_t i = 0; attributes[i] != NULL && |
| 166 attributes[i+1] != NULL; i += 2) { | 167 attributes[i+1] != NULL; i += 2) { |
| 167 const char* name = attributes[i]; | 168 const char* name = attributes[i]; |
| 168 const char* value = attributes[i+1]; | 169 const char* value = attributes[i+1]; |
| 169 size_t nameLen = strlen(name); | 170 size_t nameLen = strlen(name); |
| 170 if (nameLen == 4 && !strncmp("name", name, nameLen)) { | 171 if (nameLen == 4 && !strncmp("name", name, nameLen)) { |
| 171 aliasName.set(value); | 172 SkAutoAsciiToLC tolc(value); |
| 173 aliasName.set(tolc.lc()); |
| 172 } else if (nameLen == 2 && !strncmp("to", name, nameLen)) { | 174 } else if (nameLen == 2 && !strncmp("to", name, nameLen)) { |
| 173 to.set(value); | 175 to.set(value); |
| 174 } else if (nameLen == 6 && !strncmp("weight", name, nameLen)) { | 176 } else if (nameLen == 6 && !strncmp("weight", name, nameLen)) { |
| 175 parseNonNegativeInteger(value, &weight); | 177 parseNonNegativeInteger(value, &weight); |
| 176 } | 178 } |
| 177 } | 179 } |
| 178 | 180 |
| 179 // Assumes that the named family is already declared | 181 // Assumes that the named family is already declared |
| 180 FontFamily* targetFamily = findFamily(familyData, to.c_str()); | 182 FontFamily* targetFamily = findFamily(familyData, to.c_str()); |
| 181 if (!targetFamily) { | 183 if (!targetFamily) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 if (NULL != testFallbackConfigFile) { | 572 if (NULL != testFallbackConfigFile) { |
| 571 parseConfigFile(testFallbackConfigFile, fallbackFonts); | 573 parseConfigFile(testFallbackConfigFile, fallbackFonts); |
| 572 } | 574 } |
| 573 | 575 |
| 574 // Append all fallback fonts to system fonts | 576 // Append all fallback fonts to system fonts |
| 575 for (int i = 0; i < fallbackFonts.count(); ++i) { | 577 for (int i = 0; i < fallbackFonts.count(); ++i) { |
| 576 fallbackFonts[i]->fIsFallbackFont = true; | 578 fallbackFonts[i]->fIsFallbackFont = true; |
| 577 *fontFamilies.append() = fallbackFonts[i]; | 579 *fontFamilies.append() = fallbackFonts[i]; |
| 578 } | 580 } |
| 579 } | 581 } |
| OLD | NEW |