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

Side by Side Diff: Source/core/platform/graphics/skia/FontCacheSkia.cpp

Issue 23480016: Switch non-gdi windows font path to use new SkFontMgr (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ASSERT(fontPlatformData); 103 ASSERT(fontPlatformData);
104 return getFontResourceData(fontPlatformData, shouldRetain); 104 return getFontResourceData(fontPlatformData, shouldRetain);
105 } 105 }
106 106
107 void FontCache::getTraitsInFamily(const AtomicString& familyName, 107 void FontCache::getTraitsInFamily(const AtomicString& familyName,
108 Vector<unsigned>& traitsMasks) 108 Vector<unsigned>& traitsMasks)
109 { 109 {
110 notImplemented(); 110 notImplemented();
111 } 111 }
112 112
113 SkTypeface* FontCache::createTypeface(const FontDescription& fontDescription, co nst AtomicString& family, CString& name) 113 void FontCache::getFontNameIncludingFallback(const FontDescription& fontDescript ion, const AtomicString& family, CString& name)
bungeman-chromium 2013/08/31 02:57:24 I really liked the createTypeface abstraction, it
eae 2013/09/03 21:04:14 I agree, I'll add the windows-specific code in her
114 { 114 {
115 name = ""; 115 name = "";
116 116
117 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into 117 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
118 // the fallback name (like "monospace") that fontconfig understands. 118 // the fallback name (like "monospace") that fontconfig understands.
119 if (!family.length() || family.startsWith("-webkit-")) { 119 if (!family.length() || family.startsWith("-webkit-")) {
120 static const struct { 120 static const struct {
121 FontDescription::GenericFamilyType mType; 121 FontDescription::GenericFamilyType mType;
122 const char* mName; 122 const char* mName;
123 } fontDescriptions[] = { 123 } fontDescriptions[] = {
124 { FontDescription::SerifFamily, "serif" }, 124 { FontDescription::SerifFamily, "serif" },
125 { FontDescription::SansSerifFamily, "sans-serif" }, 125 { FontDescription::SansSerifFamily, "sans-serif" },
126 { FontDescription::MonospaceFamily, "monospace" }, 126 { FontDescription::MonospaceFamily, "monospace" },
127 { FontDescription::CursiveFamily, "cursive" }, 127 { FontDescription::CursiveFamily, "cursive" },
128 { FontDescription::FantasyFamily, "fantasy" } 128 { FontDescription::FantasyFamily, "fantasy" }
129 }; 129 };
130 130
131 FontDescription::GenericFamilyType type = fontDescription.genericFamily( ); 131 FontDescription::GenericFamilyType type = fontDescription.genericFamily( );
132 for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) { 132 for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) {
133 if (type == fontDescriptions[i].mType) { 133 if (type == fontDescriptions[i].mType) {
134 name = fontDescriptions[i].mName; 134 name = fontDescriptions[i].mName;
135 break; 135 break;
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 // convert the name to utf8 139 // convert the name to utf8
140 name = family.string().utf8(); 140 name = family.string().utf8();
141 } 141 }
142 }
143
144 #if !OS(WINDOWS)
145 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family)
146 {
147 CString name;
148 getFontNameIncludingFallback(fontDescription, family, name);
142 149
143 int style = SkTypeface::kNormal; 150 int style = SkTypeface::kNormal;
144 if (fontDescription.weight() >= FontWeightBold) 151 if (fontDescription.weight() >= FontWeightBold)
145 style |= SkTypeface::kBold; 152 style |= SkTypeface::kBold;
146 if (fontDescription.italic()) 153 if (fontDescription.italic())
147 style |= SkTypeface::kItalic; 154 style |= SkTypeface::kItalic;
148 155
149 return SkTypeface::CreateFromName(name.data(), static_cast<SkTypeface::Style >(style)); 156 SkTypeface* tf = SkTypeface::CreateFromName(name.data(), static_cast<SkTypef ace::Style>(style));
150 }
151
152 #if !OS(WINDOWS)
153 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family)
154 {
155 CString name;
156 SkTypeface* tf = createTypeface(fontDescription, family, name);
157 if (!tf) 157 if (!tf)
158 return 0; 158 return 0;
159 159
160 FontPlatformData* result = new FontPlatformData(tf, 160 FontPlatformData* result = new FontPlatformData(tf,
161 name.data(), 161 name.data(),
162 fontDescription.computedSize(), 162 fontDescription.computedSize(),
163 fontDescription.weight() >= FontWeightBold && !tf->isBold(), 163 fontDescription.weight() >= FontWeightBold && !tf->isBold(),
164 fontDescription.italic() && !tf->isItalic(), 164 fontDescription.italic() && !tf->isItalic(),
165 fontDescription.orientation()); 165 fontDescription.orientation());
166 tf->unref(); 166 tf->unref();
167 return result; 167 return result;
168 } 168 }
169 #endif // !OS(WINDOWNS) 169 #endif // !OS(WINDOWNS)
170 170
171 } // namespace WebCore 171 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698