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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontPlatformData.cpp

Issue 2737533002: Replace subpixel font size heuristics with using OpenType gasp table (Closed)
Patch Set: No subpixel without smoothing, not even for layout tests Created 3 years, 9 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) 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
(...skipping 30 matching lines...) Expand all
41 41
42 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) 42 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
43 : m_typeface(nullptr), 43 : m_typeface(nullptr),
44 m_textSize(0), 44 m_textSize(0),
45 m_syntheticBold(false), 45 m_syntheticBold(false),
46 m_syntheticItalic(false), 46 m_syntheticItalic(false),
47 m_orientation(FontOrientation::Horizontal), 47 m_orientation(FontOrientation::Horizontal),
48 m_isHashTableDeletedValue(true) 48 m_isHashTableDeletedValue(true)
49 #if OS(WIN) 49 #if OS(WIN)
50 , 50 ,
51 m_paintTextFlags(0), 51 m_paintTextFlags(0)
52 m_minSizeForAntiAlias(0),
53 m_minSizeForSubpixel(0)
54 #endif 52 #endif
55 { 53 {
56 } 54 }
57 55
58 FontPlatformData::FontPlatformData() 56 FontPlatformData::FontPlatformData()
59 : m_typeface(nullptr), 57 : m_typeface(nullptr),
60 m_textSize(0), 58 m_textSize(0),
61 m_syntheticBold(false), 59 m_syntheticBold(false),
62 m_syntheticItalic(false), 60 m_syntheticItalic(false),
63 m_orientation(FontOrientation::Horizontal), 61 m_orientation(FontOrientation::Horizontal),
64 m_isHashTableDeletedValue(false) 62 m_isHashTableDeletedValue(false)
65 #if OS(WIN) 63 #if OS(WIN)
66 , 64 ,
67 m_paintTextFlags(0), 65 m_paintTextFlags(0)
68 m_minSizeForAntiAlias(0),
69 m_minSizeForSubpixel(0)
70 #endif 66 #endif
71 { 67 {
72 } 68 }
73 69
74 FontPlatformData::FontPlatformData(float size, 70 FontPlatformData::FontPlatformData(float size,
75 bool syntheticBold, 71 bool syntheticBold,
76 bool syntheticItalic, 72 bool syntheticItalic,
77 FontOrientation orientation) 73 FontOrientation orientation)
78 : m_typeface(nullptr), 74 : m_typeface(nullptr),
79 m_textSize(size), 75 m_textSize(size),
80 m_syntheticBold(syntheticBold), 76 m_syntheticBold(syntheticBold),
81 m_syntheticItalic(syntheticItalic), 77 m_syntheticItalic(syntheticItalic),
82 m_orientation(orientation), 78 m_orientation(orientation),
83 m_isHashTableDeletedValue(false) 79 m_isHashTableDeletedValue(false)
84 #if OS(WIN) 80 #if OS(WIN)
85 , 81 ,
86 m_paintTextFlags(0), 82 m_paintTextFlags(0)
87 m_minSizeForAntiAlias(0),
88 m_minSizeForSubpixel(0)
89 #endif 83 #endif
90 { 84 {
91 } 85 }
92 86
93 FontPlatformData::FontPlatformData(const FontPlatformData& source) 87 FontPlatformData::FontPlatformData(const FontPlatformData& source)
94 : m_typeface(source.m_typeface), 88 : m_typeface(source.m_typeface),
95 #if !OS(WIN) 89 #if !OS(WIN)
96 m_family(source.m_family), 90 m_family(source.m_family),
97 #endif 91 #endif
98 m_textSize(source.m_textSize), 92 m_textSize(source.m_textSize),
99 m_syntheticBold(source.m_syntheticBold), 93 m_syntheticBold(source.m_syntheticBold),
100 m_syntheticItalic(source.m_syntheticItalic), 94 m_syntheticItalic(source.m_syntheticItalic),
101 m_orientation(source.m_orientation), 95 m_orientation(source.m_orientation),
102 #if OS(LINUX) || OS(ANDROID) 96 #if OS(LINUX) || OS(ANDROID)
103 m_style(source.m_style), 97 m_style(source.m_style),
104 #endif 98 #endif
105 m_harfBuzzFace(nullptr), 99 m_harfBuzzFace(nullptr),
106 m_isHashTableDeletedValue(false) 100 m_isHashTableDeletedValue(false)
107 #if OS(WIN) 101 #if OS(WIN)
108 , 102 ,
109 m_paintTextFlags(source.m_paintTextFlags), 103 m_paintTextFlags(source.m_paintTextFlags)
110 m_minSizeForAntiAlias(source.m_minSizeForAntiAlias),
111 m_minSizeForSubpixel(source.m_minSizeForSubpixel)
112 #endif 104 #endif
113 { 105 {
114 } 106 }
115 107
116 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) 108 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
117 : m_typeface(src.m_typeface), 109 : m_typeface(src.m_typeface),
118 #if !OS(WIN) 110 #if !OS(WIN)
119 m_family(src.m_family), 111 m_family(src.m_family),
120 #endif 112 #endif
121 m_textSize(textSize), 113 m_textSize(textSize),
122 m_syntheticBold(src.m_syntheticBold), 114 m_syntheticBold(src.m_syntheticBold),
123 m_syntheticItalic(src.m_syntheticItalic), 115 m_syntheticItalic(src.m_syntheticItalic),
124 m_orientation(src.m_orientation), 116 m_orientation(src.m_orientation),
125 #if OS(LINUX) || OS(ANDROID) 117 #if OS(LINUX) || OS(ANDROID)
126 m_style(FontRenderStyle::querySystem(m_family, 118 m_style(FontRenderStyle::querySystem(m_family,
127 m_textSize, 119 m_textSize,
128 m_typeface->fontStyle())), 120 m_typeface->fontStyle())),
129 #endif 121 #endif
130 m_harfBuzzFace(nullptr), 122 m_harfBuzzFace(nullptr),
131 m_isHashTableDeletedValue(false) 123 m_isHashTableDeletedValue(false)
132 #if OS(WIN) 124 #if OS(WIN)
133 , 125 ,
134 m_paintTextFlags(src.m_paintTextFlags), 126 m_paintTextFlags(src.m_paintTextFlags)
135 m_minSizeForAntiAlias(src.m_minSizeForAntiAlias),
136 m_minSizeForSubpixel(src.m_minSizeForSubpixel)
137 #endif 127 #endif
138 { 128 {
139 #if OS(WIN) 129 #if OS(WIN)
140 querySystemForRenderStyle(); 130 querySystemForRenderStyle();
141 #endif 131 #endif
142 } 132 }
143 133
144 FontPlatformData::FontPlatformData(sk_sp<SkTypeface> tf, 134 FontPlatformData::FontPlatformData(sk_sp<SkTypeface> tf,
145 const char* family, 135 const char* family,
146 float textSize, 136 float textSize,
147 bool syntheticBold, 137 bool syntheticBold,
148 bool syntheticItalic, 138 bool syntheticItalic,
149 FontOrientation orientation) 139 FontOrientation orientation)
150 : m_typeface(std::move(tf)), 140 : m_typeface(std::move(tf)),
151 #if !OS(WIN) 141 #if !OS(WIN)
152 m_family(family), 142 m_family(family),
153 #endif 143 #endif
154 m_textSize(textSize), 144 m_textSize(textSize),
155 m_syntheticBold(syntheticBold), 145 m_syntheticBold(syntheticBold),
156 m_syntheticItalic(syntheticItalic), 146 m_syntheticItalic(syntheticItalic),
157 m_orientation(orientation), 147 m_orientation(orientation),
158 #if OS(LINUX) || OS(ANDROID) 148 #if OS(LINUX) || OS(ANDROID)
159 m_style(FontRenderStyle::querySystem(m_family, 149 m_style(FontRenderStyle::querySystem(m_family,
160 m_textSize, 150 m_textSize,
161 m_typeface->fontStyle())), 151 m_typeface->fontStyle())),
162 #endif 152 #endif
163 m_isHashTableDeletedValue(false) 153 m_isHashTableDeletedValue(false)
164 #if OS(WIN) 154 #if OS(WIN)
165 , 155 ,
166 m_paintTextFlags(0), 156 m_paintTextFlags(0)
167 m_minSizeForAntiAlias(0),
168 m_minSizeForSubpixel(0)
169 #endif 157 #endif
170 { 158 {
171 #if OS(WIN) 159 #if OS(WIN)
172 querySystemForRenderStyle(); 160 querySystemForRenderStyle();
173 #endif 161 #endif
174 } 162 }
175 163
176 FontPlatformData::~FontPlatformData() {} 164 FontPlatformData::~FontPlatformData() {}
177 165
178 #if OS(MACOSX) 166 #if OS(MACOSX)
(...skipping 20 matching lines...) Expand all
199 m_syntheticBold = other.m_syntheticBold; 187 m_syntheticBold = other.m_syntheticBold;
200 m_syntheticItalic = other.m_syntheticItalic; 188 m_syntheticItalic = other.m_syntheticItalic;
201 m_harfBuzzFace = nullptr; 189 m_harfBuzzFace = nullptr;
202 m_orientation = other.m_orientation; 190 m_orientation = other.m_orientation;
203 #if OS(LINUX) || OS(ANDROID) 191 #if OS(LINUX) || OS(ANDROID)
204 m_style = other.m_style; 192 m_style = other.m_style;
205 #endif 193 #endif
206 194
207 #if OS(WIN) 195 #if OS(WIN)
208 m_paintTextFlags = 0; 196 m_paintTextFlags = 0;
209 m_minSizeForAntiAlias = other.m_minSizeForAntiAlias;
210 m_minSizeForSubpixel = other.m_minSizeForSubpixel;
211 #endif 197 #endif
212 198
213 return *this; 199 return *this;
214 } 200 }
215 201
216 bool FontPlatformData::operator==(const FontPlatformData& a) const { 202 bool FontPlatformData::operator==(const FontPlatformData& a) const {
217 // If either of the typeface pointers are null then we test for pointer 203 // If either of the typeface pointers are null then we test for pointer
218 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers. 204 // equality. Otherwise, we call SkTypeface::Equal on the valid pointers.
219 bool typefacesEqual = false; 205 bool typefacesEqual = false;
220 if (!typeface() || !a.typeface()) 206 if (!typeface() || !a.typeface())
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 const size_t tableSize = m_typeface->getTableSize(tag); 335 const size_t tableSize = m_typeface->getTableSize(tag);
350 if (tableSize) { 336 if (tableSize) {
351 Vector<char> tableBuffer(tableSize); 337 Vector<char> tableBuffer(tableSize);
352 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]); 338 m_typeface->getTableData(tag, 0, tableSize, &tableBuffer[0]);
353 buffer = SharedBuffer::adoptVector(tableBuffer); 339 buffer = SharedBuffer::adoptVector(tableBuffer);
354 } 340 }
355 return buffer.release(); 341 return buffer.release();
356 } 342 }
357 343
358 } // namespace blink 344 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698