OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Brent Fulgham | 2 * Copyright (C) 2011 Brent Fulgham |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 * | 18 * |
19 */ | 19 */ |
20 | 20 |
21 #include "config.h" | 21 #include "config.h" |
22 #include "platform/fonts/FontPlatformData.h" | 22 #include "platform/fonts/FontPlatformData.h" |
23 | 23 |
24 #include "SkTypeface.h" | |
25 #include "platform/fonts/harfbuzz/HarfBuzzFace.h" | |
26 #include "wtf/HashMap.h" | 24 #include "wtf/HashMap.h" |
27 #include "wtf/text/StringHash.h" | 25 #include "wtf/text/StringHash.h" |
28 #include "wtf/text/WTFString.h" | 26 #include "wtf/text/WTFString.h" |
29 | 27 |
30 #if OS(MACOSX) | 28 #if OS(MACOSX) |
31 #include "platform/fonts/harfbuzz/HarfBuzzFace.h" | 29 #include "platform/fonts/harfbuzz/HarfBuzzFace.h" |
32 #endif | 30 #endif |
33 | 31 |
34 using namespace std; | |
35 | |
36 namespace blink { | 32 namespace blink { |
37 | 33 |
38 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) | 34 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) |
39 : m_textSize(0) | 35 : m_syntheticBold(false) |
40 , m_syntheticBold(false) | 36 , m_syntheticOblique(false) |
41 , m_syntheticItalic(false) | |
42 , m_orientation(Horizontal) | 37 , m_orientation(Horizontal) |
| 38 , m_size(0) |
| 39 , m_widthVariant(RegularWidth) |
| 40 #if OS(MACOSX) |
| 41 , m_font(hashTableDeletedFontValue()) |
| 42 #endif |
43 , m_isColorBitmapFont(false) | 43 , m_isColorBitmapFont(false) |
44 , m_isCompositeFontReference(false) | 44 , m_isCompositeFontReference(false) |
45 , m_widthVariant(RegularWidth) | |
46 #if OS(MACOSX) | |
47 , m_font(nullptr) | |
48 #endif | |
49 , m_isHashTableDeletedValue(true) | |
50 { | 45 { |
51 } | 46 } |
52 | 47 |
53 FontPlatformData::FontPlatformData() | 48 FontPlatformData::FontPlatformData() |
54 : m_textSize(0) | 49 : m_syntheticBold(false) |
55 , m_syntheticBold(false) | 50 , m_syntheticOblique(false) |
56 , m_syntheticItalic(false) | |
57 , m_orientation(Horizontal) | 51 , m_orientation(Horizontal) |
| 52 , m_size(0) |
| 53 , m_widthVariant(RegularWidth) |
| 54 #if OS(MACOSX) |
| 55 , m_font(0) |
| 56 #endif |
58 , m_isColorBitmapFont(false) | 57 , m_isColorBitmapFont(false) |
59 , m_isCompositeFontReference(false) | 58 , m_isCompositeFontReference(false) |
60 , m_widthVariant(RegularWidth) | |
61 #if OS(MACOSX) | |
62 , m_font(nullptr) | |
63 #endif | |
64 , m_isHashTableDeletedValue(false) | |
65 { | 59 { |
66 } | 60 } |
67 | 61 |
68 FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheti
cItalic, FontOrientation orientation, FontWidthVariant widthVariant) | 62 FontPlatformData::FontPlatformData(float size, bool syntheticBold, bool syntheti
cOblique, FontOrientation orientation, FontWidthVariant widthVariant) |
69 : m_textSize(size) | 63 : m_syntheticBold(syntheticBold) |
70 , m_syntheticBold(syntheticBold) | 64 , m_syntheticOblique(syntheticOblique) |
71 , m_syntheticItalic(syntheticItalic) | |
72 , m_orientation(orientation) | 65 , m_orientation(orientation) |
| 66 , m_size(size) |
| 67 , m_widthVariant(widthVariant) |
| 68 #if OS(MACOSX) |
| 69 , m_font(0) |
| 70 #endif |
73 , m_isColorBitmapFont(false) | 71 , m_isColorBitmapFont(false) |
74 , m_isCompositeFontReference(false) | 72 , m_isCompositeFontReference(false) |
75 , m_widthVariant(widthVariant) | |
76 #if OS(MACOSX) | |
77 , m_font(nullptr) | |
78 #endif | |
79 , m_isHashTableDeletedValue(false) | |
80 { | 73 { |
81 } | 74 } |
82 | 75 |
83 #if OS(MACOSX) | 76 #if OS(MACOSX) |
84 FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticB
old, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVa
riant) | 77 FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticB
old, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthV
ariant) |
85 : m_textSize(size) | 78 : m_syntheticBold(syntheticBold) |
86 , m_syntheticBold(syntheticBold) | 79 , m_syntheticOblique(syntheticOblique) |
87 , m_syntheticItalic(syntheticItalic) | |
88 , m_orientation(orientation) | 80 , m_orientation(orientation) |
| 81 , m_size(size) |
| 82 , m_widthVariant(widthVariant) |
| 83 , m_font(0) |
| 84 , m_cgFont(cgFont) |
89 , m_isColorBitmapFont(false) | 85 , m_isColorBitmapFont(false) |
90 , m_isCompositeFontReference(false) | 86 , m_isCompositeFontReference(false) |
91 , m_widthVariant(widthVariant) | |
92 , m_font(nullptr) | |
93 , m_cgFont(cgFont) | |
94 , m_isHashTableDeletedValue(false) | |
95 { | 87 { |
96 } | 88 } |
97 #endif | 89 #endif |
98 | 90 |
99 FontPlatformData::FontPlatformData(const FontPlatformData& source) | 91 FontPlatformData::FontPlatformData(const FontPlatformData& source) |
100 : m_textSize(source.m_textSize) | 92 : m_syntheticBold(source.m_syntheticBold) |
101 , m_syntheticBold(source.m_syntheticBold) | 93 , m_syntheticOblique(source.m_syntheticOblique) |
102 , m_syntheticItalic(source.m_syntheticItalic) | |
103 , m_orientation(source.m_orientation) | 94 , m_orientation(source.m_orientation) |
| 95 , m_size(source.m_size) |
| 96 , m_widthVariant(source.m_widthVariant) |
104 , m_isColorBitmapFont(source.m_isColorBitmapFont) | 97 , m_isColorBitmapFont(source.m_isColorBitmapFont) |
105 , m_isCompositeFontReference(source.m_isCompositeFontReference) | 98 , m_isCompositeFontReference(source.m_isCompositeFontReference) |
106 , m_widthVariant(source.m_widthVariant) | |
107 , m_isHashTableDeletedValue(false) | |
108 { | 99 { |
109 platformDataInit(source); | 100 platformDataInit(source); |
110 } | 101 } |
111 | 102 |
112 const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe
r) | 103 const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& othe
r) |
113 { | 104 { |
114 // Check for self-assignment. | 105 // Check for self-assignment. |
115 if (this == &other) | 106 if (this == &other) |
116 return *this; | 107 return *this; |
117 | 108 |
118 m_syntheticBold = other.m_syntheticBold; | 109 m_syntheticBold = other.m_syntheticBold; |
119 m_syntheticItalic = other.m_syntheticItalic; | 110 m_syntheticOblique = other.m_syntheticOblique; |
120 m_orientation = other.m_orientation; | 111 m_orientation = other.m_orientation; |
121 m_textSize = other.m_textSize; | 112 m_size = other.m_size; |
122 m_widthVariant = other.m_widthVariant; | 113 m_widthVariant = other.m_widthVariant; |
123 m_isColorBitmapFont = other.m_isColorBitmapFont; | 114 m_isColorBitmapFont = other.m_isColorBitmapFont; |
124 m_isCompositeFontReference = other.m_isCompositeFontReference; | 115 m_isCompositeFontReference = other.m_isCompositeFontReference; |
125 | 116 |
126 return platformDataAssign(other); | 117 return platformDataAssign(other); |
127 } | 118 } |
128 | 119 |
129 bool FontPlatformData::operator==(const FontPlatformData& a) const | |
130 { | |
131 | |
132 return platformIsEqual(a) | |
133 && m_textSize == a.m_textSize | |
134 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue | |
135 && m_syntheticBold == a.m_syntheticBold | |
136 && m_syntheticItalic == a.m_syntheticItalic | |
137 && m_orientation == a.m_orientation | |
138 #if !OS(MACOSX) | |
139 && m_style == a.m_style | |
140 #endif | |
141 && m_isColorBitmapFont == a.m_isColorBitmapFont | |
142 && m_isCompositeFontReference == a.m_isCompositeFontReference | |
143 && m_widthVariant == a.m_widthVariant; | |
144 } | |
145 | |
146 | |
147 } // namespace blink | 120 } // namespace blink |
OLD | NEW |