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

Side by Side Diff: webkit/port/platform/graphics/chromium/FontCacheLinux.cpp

Issue 10414: Use Skia to render fonts (Closed)
Patch Set: Created 12 years, 1 month 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 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "FontCache.h" 6 #include "FontCache.h"
7 7
8 #include "AtomicString.h" 8 #include "AtomicString.h"
9 #include "CString.h"
9 #include "FontDescription.h" 10 #include "FontDescription.h"
10 #include "FontPlatformData.h" 11 #include "FontPlatformData.h"
11 #include "Logging.h" 12 #include "Logging.h"
12 #include "NotImplemented.h" 13 #include "NotImplemented.h"
13 14
15 #include "SkPaint.h"
16 #include "SkTypeface.h"
17 #include "SkUtils.h"
18
14 namespace WebCore { 19 namespace WebCore {
15 20
16 void FontCache::platformInit() 21 void FontCache::platformInit()
17 { 22 {
18 if (!FontPlatformData::init())
19 ASSERT_NOT_REACHED();
20 } 23 }
21 24
22 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, 25 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
23 const UChar* character s, 26 const UChar* character s,
24 int length) 27 int length)
25 { 28 {
26 notImplemented(); 29 notImplemented();
27 return NULL; 30 return NULL;
28 } 31 }
29 32
(...skipping 21 matching lines...) Expand all
51 54
52 void FontCache::getTraitsInFamily(const AtomicString& familyName, 55 void FontCache::getTraitsInFamily(const AtomicString& familyName,
53 Vector<unsigned>& traitsMasks) 56 Vector<unsigned>& traitsMasks)
54 { 57 {
55 notImplemented(); 58 notImplemented();
56 } 59 }
57 60
58 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription, 61 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD escription,
59 const AtomicString& family) 62 const AtomicString& family)
60 { 63 {
61 return new FontPlatformData(fontDescription, family); 64 const char* name = 0;
65 CString s;
66
67 if (family.length() == 0) {
68 static const struct {
69 FontDescription::GenericFamilyType mType;
70 const char* mName;
71 } gNames[] = {
72 { FontDescription::SerifFamily, "serif" },
73 { FontDescription::SansSerifFamily, "sans-serif" },
74 { FontDescription::MonospaceFamily, "monospace" },
75 { FontDescription::CursiveFamily, "cursive" },
76 { FontDescription::FantasyFamily, "fantasy" }
77 };
78
79 FontDescription::GenericFamilyType type = fontDescription.genericFamily( );
80 for (unsigned i = 0; i < SK_ARRAY_COUNT(gNames); i++) {
81 if (type == gNames[i].mType) {
82 name = gNames[i].mName;
83 break;
84 }
85 }
86 // if we fall out of the loop, it's ok for name to still be 0
87 }
88 else { // convert the name to utf8
89 s = family.string().utf8();
90 name = s.data();
91 }
92
93 int style = SkTypeface::kNormal;
94 if (fontDescription.weight() >= FontWeightBold)
95 style |= SkTypeface::kBold;
96 if (fontDescription.italic())
97 style |= SkTypeface::kItalic;
98
99 SkTypeface* tf = SkTypeface::Create(name, (SkTypeface::Style)style);
100
101 FontPlatformData* result =
102 new FontPlatformData(tf,
103 fontDescription.computedSize(),
104 (style & SkTypeface::kBold) && !tf->isBold(),
105 (style & SkTypeface::kItalic) && !tf->isItalic());
106 tf->unref();
107 return result;
62 } 108 }
63 109
64 AtomicString FontCache::getGenericFontForScript(UScriptCode script, 110 AtomicString FontCache::getGenericFontForScript(UScriptCode script,
65 const FontDescription&) 111 const FontDescription&)
66 { 112 {
67 notImplemented(); 113 notImplemented();
68 return AtomicString(); 114 return AtomicString();
69 } 115 }
70 116
71 } // namespace WebCore 117 } // namespace WebCore
OLDNEW
« no previous file with comments | « skia/ports/SkFontHost_FreeType.cpp ('k') | webkit/port/platform/graphics/chromium/FontLinux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698