|
Lines 81-92
Font::Font(const FontPlatformData& platformData, bool isCustomFont, bool isLoadi
a/Source/WebCore/platform/graphics/Font.cpp_sec1
|
| 81 |
// Estimates of avgCharWidth and maxCharWidth for platforms that don't support accessing these values from the font. |
81 |
// Estimates of avgCharWidth and maxCharWidth for platforms that don't support accessing these values from the font. |
| 82 |
void Font::initCharWidths() |
82 |
void Font::initCharWidths() |
| 83 |
{ |
83 |
{ |
| 84 |
auto* glyphPageZero = glyphPage(0); |
84 |
auto* glyphPageZero = glyphPage('0' / GlyphPage::size); |
| 85 |
|
85 |
|
| 86 |
// Treat the width of a '0' as the avgCharWidth. |
86 |
// Treat the width of a '0' as the avgCharWidth. |
| 87 |
if (m_avgCharWidth <= 0.f && glyphPageZero) { |
87 |
if (m_avgCharWidth <= 0.f && glyphPageZero) { |
| 88 |
static const UChar32 digitZeroChar = '0'; |
88 |
Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph; |
| 89 |
Glyph digitZeroGlyph = glyphPageZero->glyphDataForCharacter(digitZeroChar).glyph; |
|
|
| 90 |
if (digitZeroGlyph) |
89 |
if (digitZeroGlyph) |
| 91 |
m_avgCharWidth = widthForGlyph(digitZeroGlyph); |
90 |
m_avgCharWidth = widthForGlyph(digitZeroGlyph); |
| 92 |
} |
91 |
} |
|
Lines 102-123
void Font::initCharWidths()
a/Source/WebCore/platform/graphics/Font.cpp_sec2
|
| 102 |
void Font::platformGlyphInit() |
101 |
void Font::platformGlyphInit() |
| 103 |
{ |
102 |
{ |
| 104 |
auto* glyphPageZero = glyphPage(0); |
103 |
auto* glyphPageZero = glyphPage(0); |
| 105 |
if (!glyphPageZero) { |
104 |
auto* glyphPageCharacterZero = glyphPage('0' / GlyphPage::size); |
| 106 |
determinePitch(); |
105 |
auto* glyphPageSpace = glyphPage(space / GlyphPage::size); |
| 107 |
return; |
|
|
| 108 |
} |
| 109 |
|
106 |
|
| 110 |
// Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0, |
107 |
// Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0, |
| 111 |
// are mapped to the ZERO WIDTH SPACE glyph. |
108 |
// are mapped to the ZERO WIDTH SPACE glyph. |
| 112 |
m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph; |
109 |
if (glyphPageZero) |
|
|
110 |
m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph; |
| 113 |
|
111 |
|
| 114 |
// Nasty hack to determine if we should round or ceil space widths. |
112 |
// Nasty hack to determine if we should round or ceil space widths. |
| 115 |
// If the font is monospace or fake monospace we ceil to ensure that |
113 |
// If the font is monospace or fake monospace we ceil to ensure that |
| 116 |
// every character and the space are the same width. Otherwise we round. |
114 |
// every character and the space are the same width. Otherwise we round. |
| 117 |
m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph; |
115 |
if (glyphPageSpace) |
|
|
116 |
m_spaceGlyph = glyphPageSpace->glyphDataForCharacter(space).glyph; |
| 118 |
float width = widthForGlyph(m_spaceGlyph); |
117 |
float width = widthForGlyph(m_spaceGlyph); |
| 119 |
m_spaceWidth = width; |
118 |
m_spaceWidth = width; |
| 120 |
m_zeroGlyph = glyphPageZero->glyphDataForCharacter('0').glyph; |
119 |
if (glyphPageCharacterZero) |
|
|
120 |
m_zeroGlyph = glyphPageCharacterZero->glyphDataForCharacter('0').glyph; |
| 121 |
m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph)); |
121 |
m_fontMetrics.setZeroWidth(widthForGlyph(m_zeroGlyph)); |
| 122 |
determinePitch(); |
122 |
determinePitch(); |
| 123 |
m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width); |
123 |
m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width); |
|
Lines 152-158
static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font&
a/Source/WebCore/platform/graphics/Font.cpp_sec3
|
| 152 |
// FIXME: Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. See <rdar://problem/9823975>. |
152 |
// FIXME: Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. See <rdar://problem/9823975>. |
| 153 |
// Once we have the fix for <rdar://problem/9823975> then remove this code together with Font::shouldNotBeUsedForArabic() |
153 |
// Once we have the fix for <rdar://problem/9823975> then remove this code together with Font::shouldNotBeUsedForArabic() |
| 154 |
// in <rdar://problem/12096835>. |
154 |
// in <rdar://problem/12096835>. |
| 155 |
if (pageNumber == 6 && font.shouldNotBeUsedForArabic()) |
155 |
if (pageNumber >= 0x60 && pageNumber < 0x70 && font.shouldNotBeUsedForArabic()) |
| 156 |
return nullptr; |
156 |
return nullptr; |
| 157 |
#endif |
157 |
#endif |
| 158 |
|
158 |
|
|
Lines 165-195
static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font&
a/Source/WebCore/platform/graphics/Font.cpp_sec4
|
| 165 |
for (unsigned i = 0; i < GlyphPage::size; i++) |
165 |
for (unsigned i = 0; i < GlyphPage::size; i++) |
| 166 |
buffer[i] = start + i; |
166 |
buffer[i] = start + i; |
| 167 |
|
167 |
|
|
|
168 |
static_assert(GlyphPage::size == 16 && !(GlyphPage::size & (GlyphPage::size - 1)), "createAndFillGlyphPage() assumes GlyphPage::size is 16."); |
| 168 |
if (!start) { |
169 |
if (!start) { |
| 169 |
// Control characters must not render at all. |
170 |
// Control characters must not render at all. |
| 170 |
for (unsigned i = 0; i < 0x20; ++i) |
171 |
for (unsigned i = 0; i < 0x10; ++i) |
| 171 |
buffer[i] = zeroWidthSpace; |
|
|
| 172 |
for (unsigned i = 0x7F; i < 0xA0; i++) |
| 173 |
buffer[i] = zeroWidthSpace; |
172 |
buffer[i] = zeroWidthSpace; |
| 174 |
buffer[softHyphen] = zeroWidthSpace; |
|
|
| 175 |
|
| 176 |
// \n, \t, and nonbreaking space must render as a space. |
173 |
// \n, \t, and nonbreaking space must render as a space. |
| 177 |
buffer[(int)'\n'] = ' '; |
174 |
buffer[static_cast<int>('\t')] = space; |
| 178 |
buffer[(int)'\t'] = ' '; |
175 |
buffer[static_cast<int>('\n')] = space; |
| 179 |
buffer[noBreakSpace] = ' '; |
176 |
} else if (pageNumber == 1) { |
|
|
177 |
// Control characters must not render at all. |
| 178 |
for (unsigned i = 0; i < 0x10; ++i) |
| 179 |
buffer[i] = zeroWidthSpace; |
| 180 |
} else if (start == (0x7F & ~(GlyphPage::size - 1))) { |
| 181 |
buffer[0x7F - start] = zeroWidthSpace; |
| 182 |
} else if (pageNumber >= 8 && pageNumber < 10) { |
| 183 |
for (unsigned i = 0; i < GlyphPage::size; ++i) |
| 184 |
buffer[i] = zeroWidthSpace; |
| 185 |
} else if (pageNumber == 10) { |
| 186 |
buffer[softHyphen - start] = zeroWidthSpace; |
| 187 |
buffer[noBreakSpace - start] = space; |
| 180 |
} else if (start == (leftToRightMark & ~(GlyphPage::size - 1))) { |
188 |
} else if (start == (leftToRightMark & ~(GlyphPage::size - 1))) { |
| 181 |
// LRM, RLM, LRE, RLE, ZWNJ, ZWJ, and PDF must not render at all. |
189 |
// LRM, RLM, LRE, RLE, ZWNJ, ZWJ, and PDF must not render at all. |
| 182 |
buffer[leftToRightMark - start] = zeroWidthSpace; |
190 |
buffer[leftToRightMark - start] = zeroWidthSpace; |
| 183 |
buffer[rightToLeftMark - start] = zeroWidthSpace; |
191 |
buffer[rightToLeftMark - start] = zeroWidthSpace; |
|
|
192 |
buffer[zeroWidthNonJoiner - start] = zeroWidthSpace; |
| 193 |
buffer[zeroWidthJoiner - start] = zeroWidthSpace; |
| 194 |
} else if (start == (leftToRightEmbed & ~(GlyphPage::size - 1))) { |
| 184 |
buffer[leftToRightEmbed - start] = zeroWidthSpace; |
195 |
buffer[leftToRightEmbed - start] = zeroWidthSpace; |
| 185 |
buffer[rightToLeftEmbed - start] = zeroWidthSpace; |
196 |
buffer[rightToLeftEmbed - start] = zeroWidthSpace; |
| 186 |
buffer[leftToRightOverride - start] = zeroWidthSpace; |
197 |
buffer[leftToRightOverride - start] = zeroWidthSpace; |
| 187 |
buffer[rightToLeftOverride - start] = zeroWidthSpace; |
198 |
buffer[rightToLeftOverride - start] = zeroWidthSpace; |
|
|
199 |
buffer[popDirectionalFormatting - start] = zeroWidthSpace; |
| 200 |
} else if (start == (leftToRightIsolate & ~(GlyphPage::size - 1))) { |
| 188 |
buffer[leftToRightIsolate - start] = zeroWidthSpace; |
201 |
buffer[leftToRightIsolate - start] = zeroWidthSpace; |
| 189 |
buffer[rightToLeftIsolate - start] = zeroWidthSpace; |
202 |
buffer[rightToLeftIsolate - start] = zeroWidthSpace; |
| 190 |
buffer[zeroWidthNonJoiner - start] = zeroWidthSpace; |
|
|
| 191 |
buffer[zeroWidthJoiner - start] = zeroWidthSpace; |
| 192 |
buffer[popDirectionalFormatting - start] = zeroWidthSpace; |
| 193 |
buffer[popDirectionalIsolate - start] = zeroWidthSpace; |
203 |
buffer[popDirectionalIsolate - start] = zeroWidthSpace; |
| 194 |
buffer[firstStrongIsolate - start] = zeroWidthSpace; |
204 |
buffer[firstStrongIsolate - start] = zeroWidthSpace; |
| 195 |
} else if (start == (objectReplacementCharacter & ~(GlyphPage::size - 1))) { |
205 |
} else if (start == (objectReplacementCharacter & ~(GlyphPage::size - 1))) { |