OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 m_platformData.setupPaint(&paint); | 253 m_platformData.setupPaint(&paint); |
254 | 254 |
255 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 255 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
256 SkScalar width = paint.measureText(&glyph, 2); | 256 SkScalar width = paint.measureText(&glyph, 2); |
257 if (!paint.isSubpixelText()) | 257 if (!paint.isSubpixelText()) |
258 width = SkScalarRoundToInt(width); | 258 width = SkScalarRoundToInt(width); |
259 return SkScalarToFloat(width); | 259 return SkScalarToFloat(width); |
260 } | 260 } |
261 | 261 |
262 #if USE(HARFBUZZ) | |
263 bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
, size_t length) const | 262 bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters
, size_t length) const |
264 { | 263 { |
265 if (!m_combiningCharacterSequenceSupport) | 264 if (!m_combiningCharacterSequenceSupport) |
266 m_combiningCharacterSequenceSupport = adoptPtr(new HashMap<String, bool>
); | 265 m_combiningCharacterSequenceSupport = adoptPtr(new HashMap<String, bool>
); |
267 | 266 |
268 WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequen
ceSupport->add(String(characters, length), false); | 267 WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequen
ceSupport->add(String(characters, length), false); |
269 if (!addResult.isNewEntry) | 268 if (!addResult.isNewEntry) |
270 return addResult.storedValue->value; | 269 return addResult.storedValue->value; |
271 | 270 |
272 UErrorCode error = U_ZERO_ERROR; | 271 UErrorCode error = U_ZERO_ERROR; |
273 Vector<UChar, 4> normalizedCharacters(length); | 272 Vector<UChar, 4> normalizedCharacters(length); |
274 int32_t normalizedLength = unorm_normalize(characters, length, UNORM_NFC, UN
ORM_UNICODE_3_2, &normalizedCharacters[0], length, &error); | 273 int32_t normalizedLength = unorm_normalize(characters, length, UNORM_NFC, UN
ORM_UNICODE_3_2, &normalizedCharacters[0], length, &error); |
275 // Can't render if we have an error or no composition occurred. | 274 // Can't render if we have an error or no composition occurred. |
276 if (U_FAILURE(error) || (static_cast<size_t>(normalizedLength) == length)) | 275 if (U_FAILURE(error) || (static_cast<size_t>(normalizedLength) == length)) |
277 return false; | 276 return false; |
278 | 277 |
279 SkPaint paint; | 278 SkPaint paint; |
280 m_platformData.setupPaint(&paint); | 279 m_platformData.setupPaint(&paint); |
281 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); | 280 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); |
282 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { | 281 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { |
283 addResult.storedValue->value = true; | 282 addResult.storedValue->value = true; |
284 return true; | 283 return true; |
285 } | 284 } |
286 return false; | 285 return false; |
287 } | 286 } |
288 #endif | |
289 | 287 |
290 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const | 288 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const |
291 { | 289 { |
292 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) { | 290 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) { |
293 SkDebugf("%s last char is high-surrogate", __FUNCTION__); | 291 SkDebugf("%s last char is high-surrogate", __FUNCTION__); |
294 return false; | 292 return false; |
295 } | 293 } |
296 | 294 |
297 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length); | 295 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length); |
298 | 296 |
299 uint16_t* glyphs = glyphStorage.get(); | 297 uint16_t* glyphs = glyphStorage.get(); |
300 SkTypeface* typeface = platformData().typeface(); | 298 SkTypeface* typeface = platformData().typeface(); |
301 typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length)
; | 299 typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length)
; |
302 | 300 |
303 bool haveGlyphs = false; | 301 bool haveGlyphs = false; |
304 for (unsigned i = 0; i < length; i++) { | 302 for (unsigned i = 0; i < length; i++) { |
305 if (glyphs[i]) { | 303 if (glyphs[i]) { |
306 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); | 304 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); |
307 haveGlyphs = true; | 305 haveGlyphs = true; |
308 } | 306 } |
309 } | 307 } |
310 | 308 |
311 return haveGlyphs; | 309 return haveGlyphs; |
312 } | 310 } |
313 | 311 |
314 } // namespace blink | 312 } // namespace blink |
OLD | NEW |