OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/fonts/shaping/CachingWordShaper.h" | 5 #include "platform/fonts/shaping/CachingWordShaper.h" |
6 | 6 |
7 #include "platform/fonts/CharacterRange.h" | 7 #include "platform/fonts/CharacterRange.h" |
8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
9 #include "platform/fonts/GlyphBuffer.h" | 9 #include "platform/fonts/GlyphBuffer.h" |
10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" | 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 ASSERT_EQ(referenceGlyphBuffer.glyphAt(1), glyphBuffer.glyphAt(1)); | 131 ASSERT_EQ(referenceGlyphBuffer.glyphAt(1), glyphBuffer.glyphAt(1)); |
132 ASSERT_EQ(referenceGlyphBuffer.glyphAt(2), glyphBuffer.glyphAt(2)); | 132 ASSERT_EQ(referenceGlyphBuffer.glyphAt(2), glyphBuffer.glyphAt(2)); |
133 } | 133 } |
134 | 134 |
135 // Tests that filling a glyph buffer for a specific range returns the same | 135 // Tests that filling a glyph buffer for a specific range returns the same |
136 // results when shaping word by word as when shaping the full run in one go. | 136 // results when shaping word by word as when shaping the full run in one go. |
137 TEST_F(CachingWordShaperTest, CommonAccentRightToLeftFillGlyphBuffer) { | 137 TEST_F(CachingWordShaperTest, CommonAccentRightToLeftFillGlyphBuffer) { |
138 // "[] []" with an accent mark over the last square bracket. | 138 // "[] []" with an accent mark over the last square bracket. |
139 const UChar str[] = {0x5B, 0x5D, 0x20, 0x5B, 0x301, 0x5D, 0x0}; | 139 const UChar str[] = {0x5B, 0x5D, 0x20, 0x5B, 0x301, 0x5D, 0x0}; |
140 TextRun textRun(str, 6); | 140 TextRun textRun(str, 6); |
141 textRun.setDirection(RTL); | 141 textRun.setDirection(TextDirection::Rtl); |
142 | 142 |
143 CachingWordShaper shaper(cache.get()); | 143 CachingWordShaper shaper(cache.get()); |
144 GlyphBuffer glyphBuffer; | 144 GlyphBuffer glyphBuffer; |
145 shaper.fillGlyphBuffer(&font, textRun, fallbackFonts, &glyphBuffer, 1, 6); | 145 shaper.fillGlyphBuffer(&font, textRun, fallbackFonts, &glyphBuffer, 1, 6); |
146 | 146 |
147 std::unique_ptr<ShapeCache> referenceCache = WTF::makeUnique<ShapeCache>(); | 147 std::unique_ptr<ShapeCache> referenceCache = WTF::makeUnique<ShapeCache>(); |
148 CachingWordShaper referenceShaper(referenceCache.get()); | 148 CachingWordShaper referenceShaper(referenceCache.get()); |
149 GlyphBuffer referenceGlyphBuffer; | 149 GlyphBuffer referenceGlyphBuffer; |
150 font.setCanShapeWordByWordForTesting(false); | 150 font.setCanShapeWordByWordForTesting(false); |
151 referenceShaper.fillGlyphBuffer(&font, textRun, fallbackFonts, | 151 referenceShaper.fillGlyphBuffer(&font, textRun, fallbackFonts, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // The total width of periods and spaces should be longer than the width of | 452 // The total width of periods and spaces should be longer than the width of |
453 // periods alone. | 453 // periods alone. |
454 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); | 454 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); |
455 | 455 |
456 // The glyph bounds of periods and spaces should be longer than the glyph | 456 // The glyph bounds of periods and spaces should be longer than the glyph |
457 // bounds of periods alone. | 457 // bounds of periods alone. |
458 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); | 458 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); |
459 } | 459 } |
460 | 460 |
461 } // namespace blink | 461 } // namespace blink |
OLD | NEW |