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

Side by Side Diff: tools/sk_tool_utils_font.cpp

Issue 1163283002: update portable fonts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rewrite aaxfermodes.cpp to reduce test area Created 5 years, 6 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 | « tools/sk_tool_utils.cpp ('k') | tools/test_font_index.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 2014 Google Inc. 2 * Copyright 2014 Google Inc.
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 "Resources.h" 8 #include "Resources.h"
9 #include "SkFontMgr.h"
9 #include "SkOSFile.h" 10 #include "SkOSFile.h"
10 #include "SkTestScalerContext.h" 11 #include "SkTestScalerContext.h"
11 #include "SkThread.h" 12 #include "SkThread.h"
12 #include "SkUtils.h" 13 #include "SkUtils.h"
13 #include "sk_tool_utils.h" 14 #include "sk_tool_utils.h"
14 15
15 namespace sk_tool_utils { 16 namespace sk_tool_utils {
16 17
17 #include "test_font_data.cpp" 18 #include "test_font_monospace.cpp"
19 #include "test_font_sans_serif.cpp"
20 #include "test_font_serif.cpp"
21 #include "test_font_index.cpp"
18 22
19 static void release_portable_typefaces() { 23 static void release_portable_typefaces() {
20 // We'll clean this up in our own tests, but disable for clients. 24 // We'll clean this up in our own tests, but disable for clients.
21 // Chrome seems to have funky multi-process things going on in unit tests th at 25 // Chrome seems to have funky multi-process things going on in unit tests th at
22 // makes this unsafe to delete when the main process atexit()s. 26 // makes this unsafe to delete when the main process atexit()s.
23 // SkLazyPtr does the same sort of thing. 27 // SkLazyPtr does the same sort of thing.
24 #if SK_DEVELOPER 28 #if SK_DEVELOPER
25 for (int index = 0; index < gTestFontsCount; ++index) { 29 for (int index = 0; index < gTestFontsCount; ++index) {
26 SkTestFontData& fontData = gTestFonts[index]; 30 SkTestFontData& fontData = gTestFonts[index];
27 SkSafeUnref(fontData.fFontCache); 31 SkSafeUnref(fontData.fFontCache);
28 } 32 }
29 #endif 33 #endif
30 } 34 }
31 35
32 SK_DECLARE_STATIC_MUTEX(gTestFontMutex); 36 SK_DECLARE_STATIC_MUTEX(gTestFontMutex);
33 37
34 SkTypeface* create_font(const char* name, SkTypeface::Style style) { 38 SkTypeface* create_font(const char* name, SkTypeface::Style style) {
35 SkTestFontData* fontData = NULL; 39 SkTestFontData* fontData = NULL;
36 const SubFont* sub; 40 const SubFont* sub;
37 if (name) { 41 if (name) {
38 for (int index = 0; index < gSubFontsCount; ++index) { 42 for (int index = 0; index < gSubFontsCount; ++index) {
39 sub = &gSubFonts[index]; 43 sub = &gSubFonts[index];
40 if (!strcmp(name, sub->fName) && sub->fStyle == style) { 44 if (!strcmp(name, sub->fName) && sub->fStyle == style) {
41 fontData = &sub->fFont; 45 fontData = &sub->fFont;
42 break; 46 break;
43 } 47 }
44 } 48 }
45 if (!fontData) { 49 if (!fontData) {
50 // Once all legacy callers to portable fonts are converted, replace this with
51 // SK_CRASH();
46 SkDebugf("missing %s %d\n", name, style); 52 SkDebugf("missing %s %d\n", name, style);
47 return SkTypeface::CreateFromName(name, style); 53 // If we called SkTypeface::CreateFromName() here we'd recurse infin itely,
54 // so we reimplement its core logic here inline without the recursiv e aspect.
55 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
56 return fm->legacyCreateTypeface(name, style);
48 } 57 }
49 } else { 58 } else {
50 sub = &gSubFonts[gDefaultFontIndex]; 59 sub = &gSubFonts[gDefaultFontIndex];
51 fontData = &sub->fFont; 60 fontData = &sub->fFont;
52 } 61 }
53 SkTestFont* font; 62 SkTestFont* font;
54 { 63 {
55 SkAutoMutexAcquire ac(gTestFontMutex); 64 SkAutoMutexAcquire ac(gTestFontMutex);
56 if (fontData->fFontCache) { 65 if (fontData->fFontCache) {
57 font = SkSafeRef(fontData->fFontCache); 66 font = SkSafeRef(fontData->fFontCache);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 break; 178 break;
170 } 179 }
171 } 180 }
172 fprintf(out, ";\n"); 181 fprintf(out, ";\n");
173 } 182 }
174 fclose(out); 183 fclose(out);
175 } 184 }
176 #endif 185 #endif
177 186
178 } 187 }
OLDNEW
« no previous file with comments | « tools/sk_tool_utils.cpp ('k') | tools/test_font_index.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698