Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(843)

Side by Side Diff: src/ports/SkFontConfigParser_android.cpp

Issue 384503002: WIP SkFontMgrAndroid (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanup main file Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "SkTypeface.h" 11 #include "SkTypeface.h"
11 12
12 #include <expat.h> 13 #include <expat.h>
13 #include <stdio.h> 14 #include <stdio.h>
14 #include <sys/system_properties.h> 15 #include <sys/system_properties.h>
15 16
16 #define SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml" 17 #define SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml"
17 #define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml" 18 #define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml"
18 #define VENDOR_FONTS_FILE "/vendor/etc/fallback_fonts.xml" 19 #define VENDOR_FONTS_FILE "/vendor/etc/fallback_fonts.xml"
19 20
(...skipping 21 matching lines...) Expand all
41 FontFamily *currentFamily; // The current family being created 42 FontFamily *currentFamily; // The current family being created
42 FontFileInfo *currentFontInfo; // The current fontInfo being created 43 FontFileInfo *currentFontInfo; // The current fontInfo being created
43 int currentTag; // A flag to indicate whether we're in na meset/fileset tags 44 int currentTag; // A flag to indicate whether we're in na meset/fileset tags
44 }; 45 };
45 46
46 /** 47 /**
47 * Handler for arbitrary text. This is used to parse the text inside each name 48 * Handler for arbitrary text. This is used to parse the text inside each name
48 * or file tag. The resulting strings are put into the fNames or FontFileInfo ar rays. 49 * or file tag. The resulting strings are put into the fNames or FontFileInfo ar rays.
49 */ 50 */
50 static void textHandler(void *data, const char *s, int len) { 51 static void textHandler(void *data, const char *s, int len) {
52 SkAutoAsciiToLC tolc(s);
51 FamilyData *familyData = (FamilyData*) data; 53 FamilyData *familyData = (FamilyData*) data;
52 // Make sure we're in the right state to store this name information 54 // Make sure we're in the right state to store this name information
53 if (familyData->currentFamily && 55 if (familyData->currentFamily &&
54 (familyData->currentTag == NAMESET_TAG || familyData->currentTag == FILESET_TAG)) { 56 (familyData->currentTag == NAMESET_TAG || familyData->currentTag == FILESET_TAG)) {
55 switch (familyData->currentTag) { 57 switch (familyData->currentTag) {
56 case NAMESET_TAG: 58 case NAMESET_TAG:
57 familyData->currentFamily->fNames.push_back().set(s, len); 59 familyData->currentFamily->fNames.push_back().set(tolc.lc(), len);
58 break; 60 break;
59 case FILESET_TAG: 61 case FILESET_TAG:
60 if (familyData->currentFontInfo) { 62 if (familyData->currentFontInfo) {
61 familyData->currentFontInfo->fFileName.set(s, len); 63 familyData->currentFontInfo->fFileName.set(s, len);
62 } 64 }
63 break; 65 break;
64 default: 66 default:
65 // Noop - don't care about any text that's not in the Fonts or Names list 67 // Noop - don't care about any text that's not in the Fonts or Names list
66 break; 68 break;
67 } 69 }
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 SkString locale(6); 308 SkString locale(6);
307 char* localeCStr = locale.writable_str(); 309 char* localeCStr = locale.writable_str();
308 310
309 strncpy(localeCStr, propLang, 2); 311 strncpy(localeCStr, propLang, 2);
310 localeCStr[2] = '-'; 312 localeCStr[2] = '-';
311 strncpy(&localeCStr[3], propRegn, 2); 313 strncpy(&localeCStr[3], propRegn, 2);
312 localeCStr[5] = '\0'; 314 localeCStr[5] = '\0';
313 315
314 return locale; 316 return locale;
315 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698