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

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

Issue 458543002: Update path to Android font config file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Derek's late review 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 | no next file » | 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"
11 #include "SkTypeface.h" 11 #include "SkTypeface.h"
12 12
13 #include <expat.h> 13 #include <expat.h>
14 #include <dirent.h> 14 #include <dirent.h>
15 #include <stdio.h> 15 #include <stdio.h>
16 16
17 #include <limits> 17 #include <limits>
18 18
19 19
20 20
21 // From Android version LMP onwards, all font files collapse into 21 // From Android version LMP onwards, all font files collapse into
22 // /system/fonts/fonts.xml. Instead of trying to detect which version 22 // /system/etc/fonts.xml. Instead of trying to detect which version
23 // we're on, try to open fonts.xml; if that fails, fall back to the 23 // we're on, try to open fonts.xml; if that fails, fall back to the
24 // older filename. 24 // older filename.
25 #define LMP_SYSTEM_FONTS_FILE "/system/etc/fonts.xml" 25 #define LMP_SYSTEM_FONTS_FILE "/system/etc/fonts.xml"
26 #define OLD_SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml" 26 #define OLD_SYSTEM_FONTS_FILE "/system/etc/system_fonts.xml"
27 #define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml" 27 #define FALLBACK_FONTS_FILE "/system/etc/fallback_fonts.xml"
28 #define VENDOR_FONTS_FILE "/vendor/etc/fallback_fonts.xml" 28 #define VENDOR_FONTS_FILE "/vendor/etc/fallback_fonts.xml"
29 29
30 #define LOCALE_FALLBACK_FONTS_SYSTEM_DIR "/system/etc" 30 #define LOCALE_FALLBACK_FONTS_SYSTEM_DIR "/system/etc"
31 #define LOCALE_FALLBACK_FONTS_VENDOR_DIR "/vendor/etc" 31 #define LOCALE_FALLBACK_FONTS_VENDOR_DIR "/vendor/etc"
32 #define LOCALE_FALLBACK_FONTS_PREFIX "fallback_fonts-" 32 #define LOCALE_FALLBACK_FONTS_PREFIX "fallback_fonts-"
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (feof(file) != 0) { 458 if (feof(file) != 0) {
459 done = true; 459 done = true;
460 } 460 }
461 XML_Parse(parser, buffer, len, done); 461 XML_Parse(parser, buffer, len, done);
462 } 462 }
463 XML_ParserFree(parser); 463 XML_ParserFree(parser);
464 fclose(file); 464 fclose(file);
465 } 465 }
466 466
467 static void getSystemFontFamilies(SkTDArray<FontFamily*> &fontFamilies) { 467 static void getSystemFontFamilies(SkTDArray<FontFamily*> &fontFamilies) {
468 int initialCount = fontFamilies.count();
468 parseConfigFile(LMP_SYSTEM_FONTS_FILE, fontFamilies); 469 parseConfigFile(LMP_SYSTEM_FONTS_FILE, fontFamilies);
469 470
470 if (0 == fontFamilies.count()) { 471 if (initialCount == fontFamilies.count()) {
471 parseConfigFile(OLD_SYSTEM_FONTS_FILE, fontFamilies); 472 parseConfigFile(OLD_SYSTEM_FONTS_FILE, fontFamilies);
472 } 473 }
473 } 474 }
474 475
475 /** 476 /**
476 * In some versions of Android prior to Android 4.2 (JellyBean MR1 at API 477 * In some versions of Android prior to Android 4.2 (JellyBean MR1 at API
477 * Level 17) the fallback fonts for certain locales were encoded in their own 478 * Level 17) the fallback fonts for certain locales were encoded in their own
478 * XML files with a suffix that identified the locale. We search the provided 479 * XML files with a suffix that identified the locale. We search the provided
479 * directory for those files,add all of their entries to the fallback chain, and 480 * directory for those files,add all of their entries to the fallback chain, and
480 * include the locale as part of each entry. 481 * include the locale as part of each entry.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (NULL != testFallbackConfigFile) { 587 if (NULL != testFallbackConfigFile) {
587 parseConfigFile(testFallbackConfigFile, fallbackFonts); 588 parseConfigFile(testFallbackConfigFile, fallbackFonts);
588 } 589 }
589 590
590 // Append all fallback fonts to system fonts 591 // Append all fallback fonts to system fonts
591 for (int i = 0; i < fallbackFonts.count(); ++i) { 592 for (int i = 0; i < fallbackFonts.count(); ++i) {
592 fallbackFonts[i]->fIsFallbackFont = true; 593 fallbackFonts[i]->fIsFallbackFont = true;
593 *fontFamilies.append() = fallbackFonts[i]; 594 *fontFamilies.append() = fallbackFonts[i];
594 } 595 }
595 } 596 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698