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

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

Issue 468893002: Mark fallback fonts in new Android font config parser (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | tests/FontConfigParser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkTSearch.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/FontConfigParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698