| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const | 100 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const |
| 101 { | 101 { |
| 102 bool haveGlyphs = false; | 102 bool haveGlyphs = false; |
| 103 | 103 |
| 104 Vector<CGGlyph, 512> glyphs(bufferLength); | 104 Vector<CGGlyph, 512> glyphs(bufferLength); |
| 105 if (!shouldUseCoreText(buffer, bufferLength, this)) { | 105 if (!shouldUseCoreText(buffer, bufferLength, this)) { |
| 106 CGFontGetGlyphsForUnichars(platformData().cgFont(), buffer, glyphs.data(
), bufferLength); | 106 CGFontGetGlyphsForUnichars(platformData().cgFont(), buffer, glyphs.data(
), bufferLength); |
| 107 for (unsigned i = 0; i < length; ++i) { | 107 for (unsigned i = 0; i < length; ++i) { |
| 108 if (!glyphs[i]) { | 108 if (glyphs[i]) { |
| 109 pageToFill->setGlyphDataForIndex(offset + i, 0, 0); | |
| 110 } else { | |
| 111 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); | 109 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); |
| 112 haveGlyphs = true; | 110 haveGlyphs = true; |
| 113 } | 111 } |
| 114 } | 112 } |
| 115 } else if (!platformData().isCompositeFontReference() && platformData().widt
hVariant() != RegularWidth | 113 } else if (!platformData().isCompositeFontReference() && platformData().widt
hVariant() != RegularWidth |
| 116 && CTFontGetGlyphsForCharacters(platformData().ctFont(), buffer, glyphs.
data(), bufferLength)) { | 114 && CTFontGetGlyphsForCharacters(platformData().ctFont(), buffer, glyphs.
data(), bufferLength)) { |
| 117 // When buffer consists of surrogate pairs, CTFontGetGlyphsForCharacters | 115 // When buffer consists of surrogate pairs, CTFontGetGlyphsForCharacters |
| 118 // places the glyphs at indices corresponding to the first character of
each pair. | 116 // places the glyphs at indices corresponding to the first character of
each pair. |
| 119 unsigned glyphStep = bufferLength / length; | 117 unsigned glyphStep = bufferLength / length; |
| 120 for (unsigned i = 0; i < length; ++i) { | 118 for (unsigned i = 0; i < length; ++i) { |
| 121 if (!glyphs[i * glyphStep]) { | 119 if (glyphs[i * glyphStep]) { |
| 122 pageToFill->setGlyphDataForIndex(offset + i, 0, 0); | |
| 123 } else { | |
| 124 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i * glyphSte
p], this); | 120 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i * glyphSte
p], this); |
| 125 haveGlyphs = true; | 121 haveGlyphs = true; |
| 126 } | 122 } |
| 127 } | 123 } |
| 128 } else { | 124 } else { |
| 129 // We ask CoreText for possible vertical variant glyphs | 125 // We ask CoreText for possible vertical variant glyphs |
| 130 RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCop
y(kCFAllocatorDefault, buffer, bufferLength, kCFAllocatorNull)); | 126 RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCop
y(kCFAllocatorDefault, buffer, bufferLength, kCFAllocatorNull)); |
| 131 RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedS
tringCreate(kCFAllocatorDefault, string.get(), getCFStringAttributes(0, hasVerti
calGlyphs() ? Vertical : Horizontal))); | 127 RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedS
tringCreate(kCFAllocatorDefault, string.get(), getCFStringAttributes(0, hasVerti
calGlyphs() ? Vertical : Horizontal))); |
| 132 RetainPtr<CTLineRef> line(AdoptCF, CTLineCreateWithAttributedString(attr
ibutedString.get())); | 128 RetainPtr<CTLineRef> line(AdoptCF, CTLineCreateWithAttributedString(attr
ibutedString.get())); |
| 133 | 129 |
| 134 CFArrayRef runArray = CTLineGetGlyphRuns(line.get()); | 130 CFArrayRef runArray = CTLineGetGlyphRuns(line.get()); |
| 135 CFIndex runCount = CFArrayGetCount(runArray); | 131 CFIndex runCount = CFArrayGetCount(runArray); |
| 136 | 132 |
| 137 // Initialize glyph entries | |
| 138 for (unsigned index = 0; index < length; ++index) | |
| 139 pageToFill->setGlyphDataForIndex(offset + index, 0, 0); | |
| 140 | |
| 141 Vector<CGGlyph, 512> glyphVector; | 133 Vector<CGGlyph, 512> glyphVector; |
| 142 Vector<CFIndex, 512> indexVector; | 134 Vector<CFIndex, 512> indexVector; |
| 143 bool done = false; | 135 bool done = false; |
| 144 | 136 |
| 145 // For the CGFont comparison in the loop, use the CGFont that Core Text
assigns to the CTFont. This may | 137 // For the CGFont comparison in the loop, use the CGFont that Core Text
assigns to the CTFont. This may |
| 146 // be non-CFEqual to platformData().cgFont(). | 138 // be non-CFEqual to platformData().cgFont(). |
| 147 RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(platformData
().ctFont(), 0)); | 139 RetainPtr<CGFontRef> cgFont(AdoptCF, CTFontCopyGraphicsFont(platformData
().ctFont(), 0)); |
| 148 | 140 |
| 149 for (CFIndex r = 0; r < runCount && !done ; ++r) { | 141 for (CFIndex r = 0; r < runCount && !done ; ++r) { |
| 150 // CTLine could map characters over multiple fonts using its own fon
t fallback list. | 142 // CTLine could map characters over multiple fonts using its own fon
t fallback list. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } | 192 } |
| 201 } | 193 } |
| 202 } | 194 } |
| 203 } | 195 } |
| 204 } | 196 } |
| 205 | 197 |
| 206 return haveGlyphs; | 198 return haveGlyphs; |
| 207 } | 199 } |
| 208 | 200 |
| 209 } // namespace WebCore | 201 } // namespace WebCore |
| OLD | NEW |