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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 FontFamily *currentFamily; // The current family being created | 44 FontFamily *currentFamily; // The current family being created |
45 FontFileInfo *currentFontInfo; // The current fontInfo being created | 45 FontFileInfo *currentFontInfo; // The current fontInfo being created |
46 int currentTag; // A flag to indicate whether we're in na
meset/fileset tags | 46 int currentTag; // A flag to indicate whether we're in na
meset/fileset tags |
47 }; | 47 }; |
48 | 48 |
49 /** | 49 /** |
50 * Handler for arbitrary text. This is used to parse the text inside each name | 50 * Handler for arbitrary text. This is used to parse the text inside each name |
51 * or file tag. The resulting strings are put into the fNames or FontFileInfo ar
rays. | 51 * or file tag. The resulting strings are put into the fNames or FontFileInfo ar
rays. |
52 */ | 52 */ |
53 static void textHandler(void *data, const char *s, int len) { | 53 static void textHandler(void *data, const char *s, int len) { |
54 SkAutoAsciiToLC tolc(s); | |
55 FamilyData *familyData = (FamilyData*) data; | 54 FamilyData *familyData = (FamilyData*) data; |
56 // Make sure we're in the right state to store this name information | 55 // Make sure we're in the right state to store this name information |
57 if (familyData->currentFamily && | 56 if (familyData->currentFamily && |
58 (familyData->currentTag == NAMESET_TAG || familyData->currentTag ==
FILESET_TAG)) { | 57 (familyData->currentTag == NAMESET_TAG || familyData->currentTag ==
FILESET_TAG)) { |
59 switch (familyData->currentTag) { | 58 switch (familyData->currentTag) { |
60 case NAMESET_TAG: | 59 case NAMESET_TAG: { |
| 60 SkAutoAsciiToLC tolc(s, len); |
61 familyData->currentFamily->fNames.push_back().set(tolc.lc(), len); | 61 familyData->currentFamily->fNames.push_back().set(tolc.lc(), len); |
62 break; | 62 break; |
| 63 } |
63 case FILESET_TAG: | 64 case FILESET_TAG: |
64 if (familyData->currentFontInfo) { | 65 if (familyData->currentFontInfo) { |
65 familyData->currentFontInfo->fFileName.set(s, len); | 66 familyData->currentFontInfo->fFileName.set(s, len); |
66 } | 67 } |
67 break; | 68 break; |
68 default: | 69 default: |
69 // Noop - don't care about any text that's not in the Fonts or Names
list | 70 // Noop - don't care about any text that's not in the Fonts or Names
list |
70 break; | 71 break; |
71 } | 72 } |
72 } | 73 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 SkString locale(6); | 340 SkString locale(6); |
340 char* localeCStr = locale.writable_str(); | 341 char* localeCStr = locale.writable_str(); |
341 | 342 |
342 strncpy(localeCStr, propLang, 2); | 343 strncpy(localeCStr, propLang, 2); |
343 localeCStr[2] = '-'; | 344 localeCStr[2] = '-'; |
344 strncpy(&localeCStr[3], propRegn, 2); | 345 strncpy(&localeCStr[3], propRegn, 2); |
345 localeCStr[5] = '\0'; | 346 localeCStr[5] = '\0'; |
346 | 347 |
347 return locale; | 348 return locale; |
348 } | 349 } |
OLD | NEW |