1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "FontCache.h"
#include "AtomicString.h"
#include "CString.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "Logging.h"
#include "NotImplemented.h"
#include "SkPaint.h"
#include "SkTypeface.h"
#include "SkUtils.h"
namespace WebCore {
void FontCache::platformInit()
{
}
const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font,
const UChar* characters,
int length)
{
notImplemented();
return NULL;
}
const AtomicString& FontCache::alternateFamilyName(const AtomicString& familyName)
{
notImplemented();
// This is just to stop GCC emitting a warning about returning a reference
// to a temporary variable
static AtomicString a;
return a;
}
FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
{
return 0;
}
FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& description)
{
static AtomicString arialStr("Arial");
return getCachedFontPlatformData(description, arialStr);
}
void FontCache::getTraitsInFamily(const AtomicString& familyName,
Vector<unsigned>& traitsMasks)
{
notImplemented();
}
FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription,
const AtomicString& family)
{
const char* name = 0;
CString s;
if (family.length() == 0) {
static const struct {
FontDescription::GenericFamilyType mType;
const char* mName;
} gNames[] = {
{ FontDescription::SerifFamily, "serif" },
{ FontDescription::SansSerifFamily, "sans-serif" },
{ FontDescription::MonospaceFamily, "monospace" },
{ FontDescription::CursiveFamily, "cursive" },
{ FontDescription::FantasyFamily, "fantasy" }
};
FontDescription::GenericFamilyType type = fontDescription.genericFamily();
for (unsigned i = 0; i < SK_ARRAY_COUNT(gNames); i++) {
if (type == gNames[i].mType) {
name = gNames[i].mName;
break;
}
}
// if we fall out of the loop, it's ok for name to still be 0
}
else { // convert the name to utf8
s = family.string().utf8();
name = s.data();
}
int style = SkTypeface::kNormal;
if (fontDescription.weight() >= FontWeightBold)
style |= SkTypeface::kBold;
if (fontDescription.italic())
style |= SkTypeface::kItalic;
SkTypeface* tf = SkTypeface::Create(name, (SkTypeface::Style)style);
FontPlatformData* result =
new FontPlatformData(tf,
fontDescription.computedSize(),
(style & SkTypeface::kBold) && !tf->isBold(),
(style & SkTypeface::kItalic) && !tf->isItalic());
tf->unref();
return result;
}
AtomicString FontCache::getGenericFontForScript(UScriptCode script,
const FontDescription&)
{
notImplemented();
return AtomicString("Times New Roman");
}
} // namespace WebCore
|