| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 nextFontData = m_font->glyphDataForCharacter(character, false).fontD
ata; | 620 nextFontData = m_font->glyphDataForCharacter(character, false).fontD
ata; |
| 621 nextScript = uscript_getScript(character, &errorCode); | 621 nextScript = uscript_getScript(character, &errorCode); |
| 622 if (U_FAILURE(errorCode)) | 622 if (U_FAILURE(errorCode)) |
| 623 return false; | 623 return false; |
| 624 if ((nextFontData != currentFontData) || ((currentScript != nextScri
pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre
ntScript)))) | 624 if ((nextFontData != currentFontData) || ((currentScript != nextScri
pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre
ntScript)))) |
| 625 break; | 625 break; |
| 626 if (nextScript == USCRIPT_INHERITED) | 626 if (nextScript == USCRIPT_INHERITED) |
| 627 nextScript = currentScript; | 627 nextScript = currentScript; |
| 628 currentCharacterPosition = iterator.characters(); | 628 currentCharacterPosition = iterator.characters(); |
| 629 } | 629 } |
| 630 unsigned numCharactersOfCurrentRun = iterator.currentCharacter() - start
IndexOfCurrentRun; | 630 addHarfBuzzRun(startIndexOfCurrentRun, iterator.currentCharacter(), curr
entFontData, currentScript); |
| 631 hb_script_t script = hb_icu_script_to_script(currentScript); | |
| 632 m_harfBuzzRuns.append(HarfBuzzRun::create(currentFontData, startIndexOfC
urrentRun, numCharactersOfCurrentRun, m_run.direction(), script)); | |
| 633 currentFontData = nextFontData; | 631 currentFontData = nextFontData; |
| 634 startIndexOfCurrentRun = iterator.currentCharacter(); | 632 startIndexOfCurrentRun = iterator.currentCharacter(); |
| 635 } while (iterator.consume(character, clusterLength)); | 633 } while (iterator.consume(character, clusterLength)); |
| 636 | 634 |
| 637 return !m_harfBuzzRuns.isEmpty(); | 635 return !m_harfBuzzRuns.isEmpty(); |
| 638 } | 636 } |
| 639 | 637 |
| 638 void HarfBuzzShaper::addHarfBuzzRun(unsigned startCharacter, |
| 639 unsigned endCharacter, const SimpleFontData* fontData, |
| 640 UScriptCode script) |
| 641 { |
| 642 ASSERT(endCharacter > startCharacter); |
| 643 ASSERT(script != USCRIPT_INVALID_CODE); |
| 644 return m_harfBuzzRuns.append(HarfBuzzRun::create(fontData, |
| 645 startCharacter, endCharacter - startCharacter, |
| 646 m_run.direction(), hb_icu_script_to_script(script))); |
| 647 } |
| 648 |
| 640 static const uint16_t* toUint16(const UChar* src) | 649 static const uint16_t* toUint16(const UChar* src) |
| 641 { | 650 { |
| 642 // FIXME: This relies on undefined behavior however it works on the | 651 // FIXME: This relies on undefined behavior however it works on the |
| 643 // current versions of all compilers we care about and avoids making | 652 // current versions of all compilers we care about and avoids making |
| 644 // a copy of the string. | 653 // a copy of the string. |
| 645 COMPILE_ASSERT(sizeof(UChar) == sizeof(uint16_t), UChar_is_the_same_size_as_
uint16_t); | 654 COMPILE_ASSERT(sizeof(UChar) == sizeof(uint16_t), UChar_is_the_same_size_as_
uint16_t); |
| 646 return reinterpret_cast<const uint16_t*>(src); | 655 return reinterpret_cast<const uint16_t*>(src); |
| 647 } | 656 } |
| 648 | 657 |
| 649 bool HarfBuzzShaper::shapeHarfBuzzRuns() | 658 bool HarfBuzzShaper::shapeHarfBuzzRuns() |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 if (!foundToX) | 903 if (!foundToX) |
| 895 toX = m_run.rtl() ? 0 : m_totalWidth; | 904 toX = m_run.rtl() ? 0 : m_totalWidth; |
| 896 | 905 |
| 897 // Using floorf() and roundf() as the same as mac port. | 906 // Using floorf() and roundf() as the same as mac port. |
| 898 if (fromX < toX) | 907 if (fromX < toX) |
| 899 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); | 908 return FloatRect(floorf(point.x() + fromX), point.y(), roundf(toX - from
X), height); |
| 900 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); | 909 return FloatRect(floorf(point.x() + toX), point.y(), roundf(fromX - toX), he
ight); |
| 901 } | 910 } |
| 902 | 911 |
| 903 } // namespace WebCore | 912 } // namespace WebCore |
| OLD | NEW |