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

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

Issue 21353004: Use Skia for font selection on windows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
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 28 matching lines...) Expand all
39 #include "wtf/Assertions.h" 39 #include "wtf/Assertions.h"
40 #include "wtf/text/AtomicString.h" 40 #include "wtf/text/AtomicString.h"
41 #include "wtf/text/CString.h" 41 #include "wtf/text/CString.h"
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 void FontCache::platformInit() 45 void FontCache::platformInit()
46 { 46 {
47 } 47 }
48 48
49 #if !OS(WINDOWS)
49 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacter(const Font& font, UChar32 c) 50 PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacter(const Font& font, UChar32 c)
50 { 51 {
51 icu::Locale locale = icu::Locale::getDefault(); 52 icu::Locale locale = icu::Locale::getDefault();
52 FontCache::SimpleFontFamily family; 53 FontCache::SimpleFontFamily family;
53 FontCache::getFontFamilyForCharacter(c, locale.getLanguage(), &family); 54 FontCache::getFontFamilyForCharacter(c, locale.getLanguage(), &family);
54 if (family.name.isEmpty()) 55 if (family.name.isEmpty())
55 return 0; 56 return 0;
56 57
57 AtomicString atomicFamily(family.name); 58 AtomicString atomicFamily(family.name);
58 // Changes weight and/or italic of given FontDescription depends on 59 // Changes weight and/or italic of given FontDescription depends on
(...skipping 17 matching lines...) Expand all
76 77
77 FontPlatformData* substitutePlatformData = getFontResourcePlatformData(descr iption, atomicFamily, DoNotRetain); 78 FontPlatformData* substitutePlatformData = getFontResourcePlatformData(descr iption, atomicFamily, DoNotRetain);
78 if (!substitutePlatformData) 79 if (!substitutePlatformData)
79 return 0; 80 return 0;
80 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); 81 FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
81 platformData.setFakeBold(shouldSetFakeBold); 82 platformData.setFakeBold(shouldSetFakeBold);
82 platformData.setFakeItalic(shouldSetFakeItalic); 83 platformData.setFakeItalic(shouldSetFakeItalic);
83 return getFontResourceData(&platformData, DoNotRetain); 84 return getFontResourceData(&platformData, DoNotRetain);
84 } 85 }
85 86
87 #endif // !OS(WINDOWNS)
88
86 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& fon t) 89 PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& fon t)
87 { 90 {
88 return 0; 91 return 0;
89 } 92 }
90 93
91 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri ption& description, ShouldRetain shouldRetain) 94 PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescri ption& description, ShouldRetain shouldRetain)
92 { 95 {
93 const FontPlatformData* fontPlatformData = getFallbackFontData(description); 96 const FontPlatformData* fontPlatformData = getFallbackFontData(description);
94 if (!fontPlatformData) { 97 if (!fontPlatformData) {
95 // we should at least have Arial; this is the SkFontHost_fontconfig last resort fallback 98 // we should at least have Arial; this is the SkFontHost_fontconfig last resort fallback
96 DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial", AtomicString ::ConstructFromLiteral)); 99 DEFINE_STATIC_LOCAL(const AtomicString, arialStr, ("Arial", AtomicString ::ConstructFromLiteral));
97 fontPlatformData = getFontResourcePlatformData(description, arialStr); 100 fontPlatformData = getFontResourcePlatformData(description, arialStr);
98 } 101 }
99 102
100 ASSERT(fontPlatformData); 103 ASSERT(fontPlatformData);
101 return getFontResourceData(fontPlatformData, shouldRetain); 104 return getFontResourceData(fontPlatformData, shouldRetain);
102 } 105 }
103 106
104 void FontCache::getTraitsInFamily(const AtomicString& familyName, 107 void FontCache::getTraitsInFamily(const AtomicString& familyName,
105 Vector<unsigned>& traitsMasks) 108 Vector<unsigned>& traitsMasks)
106 { 109 {
107 notImplemented(); 110 notImplemented();
108 } 111 }
109 112
110 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, 113 SkTypeface* FontCache::createTypeface(const FontDescription& fontDescription, co nst AtomicString& family)
111 const AtomicString& family)
112 { 114 {
113 const char* name = 0; 115 const char* name = 0;
114 CString s; 116 CString s;
115 117
116 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into 118 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
117 // the fallback name (like "monospace") that fontconfig understands. 119 // the fallback name (like "monospace") that fontconfig understands.
118 if (!family.length() || family.startsWith("-webkit-")) { 120 if (!family.length() || family.startsWith("-webkit-")) {
119 static const struct { 121 static const struct {
120 FontDescription::GenericFamilyType mType; 122 FontDescription::GenericFamilyType mType;
121 const char* mName; 123 const char* mName;
(...skipping 19 matching lines...) Expand all
141 s = family.string().utf8(); 143 s = family.string().utf8();
142 name = s.data(); 144 name = s.data();
143 } 145 }
144 146
145 int style = SkTypeface::kNormal; 147 int style = SkTypeface::kNormal;
146 if (fontDescription.weight() >= FontWeightBold) 148 if (fontDescription.weight() >= FontWeightBold)
147 style |= SkTypeface::kBold; 149 style |= SkTypeface::kBold;
148 if (fontDescription.italic()) 150 if (fontDescription.italic())
149 style |= SkTypeface::kItalic; 151 style |= SkTypeface::kItalic;
150 152
151 SkTypeface* tf = SkTypeface::CreateFromName(name, static_cast<SkTypeface::St yle>(style)); 153 return SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style ));
154 }
155
156 #if !OS(WINDOWS)
157 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family)
158 {
159 SkTypeface* tf = createTypeface(fontDescription, family);
152 if (!tf) 160 if (!tf)
153 return 0; 161 return 0;
154 162
155 FontPlatformData* result = 163 SkString name;
156 new FontPlatformData(tf, 164 tf->getFamilyName(&name);
157 name, 165
158 fontDescription.computedSize(), 166 FontPlatformData* result = new FontPlatformData(tf,
159 (style & SkTypeface::kBold) && !tf->isBold(), 167 name.c_str(),
160 (style & SkTypeface::kItalic) && !tf->isItalic(), 168 fontDescription.computedSize(),
161 fontDescription.orientation()); 169 fontDescription.weight() >= FontWeightBold && !tf->isBold(),
170 fontDescription.italic() && !tf->isItalic(),
171 fontDescription.orientation());
162 tf->unref(); 172 tf->unref();
163 return result; 173 return result;
164 } 174 }
175 #endif // !OS(WINDOWNS)
165 176
166 } // namespace WebCore 177 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698