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

Side by Side Diff: Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 235553003: Support sideloaded fonts for DirectWrite (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add ForTesting, iterator name Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/FontCache.h ('k') | Source/platform/fonts/win/FontCacheSkiaWin.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 (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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // convert the name to utf8 117 // convert the name to utf8
118 name = family.utf8(); 118 name = family.utf8();
119 } 119 }
120 120
121 int style = SkTypeface::kNormal; 121 int style = SkTypeface::kNormal;
122 if (fontDescription.weight() >= FontWeightBold) 122 if (fontDescription.weight() >= FontWeightBold)
123 style |= SkTypeface::kBold; 123 style |= SkTypeface::kBold;
124 if (fontDescription.style()) 124 if (fontDescription.style())
125 style |= SkTypeface::kItalic; 125 style |= SkTypeface::kItalic;
126 126
127 #if OS(WIN)
128 if (s_sideloadedFonts) {
129 HashMap<String, SkTypeface*>::iterator sideloadedFont = s_sideloadedFont s->find(name.data());
130 if (sideloadedFont != s_sideloadedFonts->end()) {
131 return adoptRef(sideloadedFont->value);
132 }
133 }
127 // FIXME: Use SkFontStyle and matchFamilyStyle instead of legacyCreateTypefa ce. 134 // FIXME: Use SkFontStyle and matchFamilyStyle instead of legacyCreateTypefa ce.
128 #if OS(WIN)
129 if (m_fontManager) 135 if (m_fontManager)
130 return adoptRef(m_fontManager->legacyCreateTypeface(name.data(), style)) ; 136 return adoptRef(m_fontManager->legacyCreateTypeface(name.data(), style)) ;
131 #endif 137 #endif
132 138
133 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style))); 139 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style)));
134 } 140 }
135 141
136 #if !OS(WIN) 142 #if !OS(WIN)
137 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family, float fontSize) 143 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, const AtomicString& family, float fontSize)
138 { 144 {
139 CString name; 145 CString name;
140 RefPtr<SkTypeface> tf(createTypeface(fontDescription, family, name)); 146 RefPtr<SkTypeface> tf(createTypeface(fontDescription, family, name));
141 if (!tf) 147 if (!tf)
142 return 0; 148 return 0;
143 149
144 FontPlatformData* result = new FontPlatformData(tf, 150 FontPlatformData* result = new FontPlatformData(tf,
145 name.data(), 151 name.data(),
146 fontSize, 152 fontSize,
147 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes cription.isSyntheticBold(), 153 (fontDescription.weight() >= FontWeightBold && !tf->isBold()) || fontDes cription.isSyntheticBold(),
148 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe ticItalic(), 154 (fontDescription.style() && !tf->isItalic()) || fontDescription.isSynthe ticItalic(),
149 fontDescription.orientation(), 155 fontDescription.orientation(),
150 fontDescription.useSubpixelPositioning()); 156 fontDescription.useSubpixelPositioning());
151 return result; 157 return result;
152 } 158 }
153 #endif // !OS(WIN) 159 #endif // !OS(WIN)
154 160
155 } // namespace WebCore 161 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontCache.h ('k') | Source/platform/fonts/win/FontCacheSkiaWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698