| 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 segmentRange.script, | 670 segmentRange.script, |
| 671 !fallbackIterator->hasNext())) | 671 !fallbackIterator->hasNext())) |
| 672 DLOG(ERROR) << "Shape result extraction failed."; | 672 DLOG(ERROR) << "Shape result extraction failed."; |
| 673 | 673 |
| 674 hb_buffer_reset(harfBuzzBuffer.get()); | 674 hb_buffer_reset(harfBuzzBuffer.get()); |
| 675 } | 675 } |
| 676 } | 676 } |
| 677 return result.release(); | 677 return result.release(); |
| 678 } | 678 } |
| 679 | 679 |
| 680 PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters(const Font* f
ont, | |
| 681 const TextRun& textRun, float positionOffset, unsigned count) | |
| 682 { | |
| 683 const SimpleFontData* fontData = font->primaryFont(); | |
| 684 std::unique_ptr<ShapeResult::RunInfo> run = wrapUnique(new ShapeResult::RunI
nfo(fontData, | |
| 685 // Tab characters are always LTR or RTL, not TTB, even when isVerticalAn
yUpright(). | |
| 686 textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR, | |
| 687 HB_SCRIPT_COMMON, 0, count, count)); | |
| 688 float position = textRun.xPos() + positionOffset; | |
| 689 float startPosition = position; | |
| 690 for (unsigned i = 0; i < count; i++) { | |
| 691 float advance = font->tabWidth(*fontData, textRun.getTabSize(), position
); | |
| 692 run->m_glyphData[i].characterIndex = i; | |
| 693 run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0); | |
| 694 position += advance; | |
| 695 } | |
| 696 run->m_width = position - startPosition; | |
| 697 | |
| 698 RefPtr<ShapeResult> result = ShapeResult::create(font, count, textRun.direct
ion()); | |
| 699 result->m_width = run->m_width; | |
| 700 result->m_numGlyphs = count; | |
| 701 ASSERT(result->m_numGlyphs == count); // no overflow | |
| 702 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright
(); | |
| 703 result->m_runs.append(std::move(run)); | |
| 704 return result.release(); | |
| 705 } | |
| 706 | |
| 707 | |
| 708 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |