| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } else { | 358 } else { |
| 359 source = run.characters16(); | 359 source = run.characters16(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 *destinationLength = 0; | 362 *destinationLength = 0; |
| 363 while (position < length) { | 363 while (position < length) { |
| 364 UChar32 character; | 364 UChar32 character; |
| 365 U16_NEXT(source, position, length, character); | 365 U16_NEXT(source, position, length, character); |
| 366 // Don't normalize tabs as they are not treated as spaces for word-end. | 366 // Don't normalize tabs as they are not treated as spaces for word-end. |
| 367 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(
character)) | 367 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(
character)) |
| 368 character = space; | 368 character = spaceCharacter; |
| 369 else if (Character::treatAsSpace(character) && character != characterTab
ulation) | 369 else if (Character::treatAsSpace(character) && character != tabulationCh
aracter) |
| 370 character = space; | 370 character = spaceCharacter; |
| 371 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) | 371 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) |
| 372 character = zeroWidthSpace; | 372 character = zeroWidthSpaceCharacter; |
| 373 | 373 |
| 374 U16_APPEND(destination, *destinationLength, length, character, error); | 374 U16_APPEND(destination, *destinationLength, length, character, error); |
| 375 ASSERT_UNUSED(error, !error); | 375 ASSERT_UNUSED(error, !error); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, const Glyph
Data* emphasisData, | 379 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run, const Glyph
Data* emphasisData, |
| 380 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) | 380 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds) |
| 381 : Shaper(font, run, emphasisData, fallbackFonts, bounds) | 381 : Shaper(font, run, emphasisData, fallbackFonts, bounds) |
| 382 , m_normalizedBufferLength(0) | 382 , m_normalizedBufferLength(0) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 if ((U_GET_GC_MASK(character) & U_GC_M_MASK) | 587 if ((U_GET_GC_MASK(character) & U_GC_M_MASK) |
| 588 && currentFontData->canRenderCombiningCharacterSequence( | 588 && currentFontData->canRenderCombiningCharacterSequence( |
| 589 currentCharacterPosition, | 589 currentCharacterPosition, |
| 590 iterator.glyphEnd() - currentCharacterPosition)) | 590 iterator.glyphEnd() - currentCharacterPosition)) |
| 591 continue; | 591 continue; |
| 592 | 592 |
| 593 nextFontData = font->glyphDataForCharacter(character, false, isSpace
Normalize).fontData; | 593 nextFontData = font->glyphDataForCharacter(character, false, isSpace
Normalize).fontData; |
| 594 nextScript = uscript_getScript(character, &errorCode); | 594 nextScript = uscript_getScript(character, &errorCode); |
| 595 if (U_FAILURE(errorCode)) | 595 if (U_FAILURE(errorCode)) |
| 596 return false; | 596 return false; |
| 597 if (lastCharacter == zeroWidthJoiner) | 597 if (lastCharacter == zeroWidthJoinerCharacter) |
| 598 currentFontData = nextFontData; | 598 currentFontData = nextFontData; |
| 599 if ((nextFontData != currentFontData) || ((currentScript != nextScri
pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre
ntScript)))) | 599 if ((nextFontData != currentFontData) || ((currentScript != nextScri
pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre
ntScript)))) |
| 600 break; | 600 break; |
| 601 currentCharacterPosition = iterator.characters(); | 601 currentCharacterPosition = iterator.characters(); |
| 602 lastCharacter = character; | 602 lastCharacter = character; |
| 603 } | 603 } |
| 604 | 604 |
| 605 CandidateRun run = { character, startIndexOfCurrentRun, static_cast<unsi
gned>(iterator.offset()), currentFontData, currentScript }; | 605 CandidateRun run = { character, startIndexOfCurrentRun, static_cast<unsi
gned>(iterator.offset()), currentFontData, currentScript }; |
| 606 runs->append(run); | 606 runs->append(run); |
| 607 | 607 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 hb_buffer_clear_contents(harfBuzzBuffer.get()); | 847 hb_buffer_clear_contents(harfBuzzBuffer.get()); |
| 848 runCache.moveToBack(cachedResults); | 848 runCache.moveToBack(cachedResults); |
| 849 previousRun = currentRun; | 849 previousRun = currentRun; |
| 850 continue; | 850 continue; |
| 851 } | 851 } |
| 852 runCache.remove(cachedResults); | 852 runCache.remove(cachedResults); |
| 853 } | 853 } |
| 854 | 854 |
| 855 // Add a space as pre-context to the buffer. This prevents showing dotte
d-circle | 855 // Add a space as pre-context to the buffer. This prevents showing dotte
d-circle |
| 856 // for combining marks at the beginning of runs. | 856 // for combining marks at the beginning of runs. |
| 857 static const uint16_t preContext = space; | 857 static const uint16_t preContext = spaceCharacter; |
| 858 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0); | 858 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0); |
| 859 | 859 |
| 860 addToHarfBuzzBufferInternal(harfBuzzBuffer.get(), | 860 addToHarfBuzzBufferInternal(harfBuzzBuffer.get(), |
| 861 fontDescription, m_normalizedBuffer.get(), currentRun->startIndex(), | 861 fontDescription, m_normalizedBuffer.get(), currentRun->startIndex(), |
| 862 currentRun->numCharacters()); | 862 currentRun->numCharacters()); |
| 863 | 863 |
| 864 if (fontDescription.isVerticalAnyUpright()) | 864 if (fontDescription.isVerticalAnyUpright()) |
| 865 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); | 865 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); |
| 866 | 866 |
| 867 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de
stroy); | 867 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de
stroy); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 // possibly invalid from, to arguments. | 1206 // possibly invalid from, to arguments. |
| 1207 if (!foundToX && !foundFromX) | 1207 if (!foundToX && !foundFromX) |
| 1208 fromX = toX = 0; | 1208 fromX = toX = 0; |
| 1209 | 1209 |
| 1210 if (fromX < toX) | 1210 if (fromX < toX) |
| 1211 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); | 1211 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); |
| 1212 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); | 1212 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 } // namespace blink | 1215 } // namespace blink |
| OLD | NEW |