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 "config.h" | 5 #include "config.h" |
6 #include "platform/fonts/shaping/CachingWordShaper.h" | 6 #include "platform/fonts/shaping/CachingWordShaper.h" |
7 | 7 |
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 verticalMixedFont.update(nullptr); | 196 verticalMixedFont.update(nullptr); |
197 ASSERT_TRUE(verticalMixedFont.canShapeWordByWord()); | 197 ASSERT_TRUE(verticalMixedFont.canShapeWordByWord()); |
198 | 198 |
199 CachingWordShaper shaper(cache.get()); | 199 CachingWordShaper shaper(cache.get()); |
200 FloatRect glyphBounds; | 200 FloatRect glyphBounds; |
201 HashSet<const SimpleFontData*> fallbackFonts; | 201 HashSet<const SimpleFontData*> fallbackFonts; |
202 ASSERT_GT(shaper.width(&verticalMixedFont, textRun, &fallbackFonts, &glyphBo
unds), 0); | 202 ASSERT_GT(shaper.width(&verticalMixedFont, textRun, &fallbackFonts, &glyphBo
unds), 0); |
203 EXPECT_EQ(0u, fallbackFonts.size()); | 203 EXPECT_EQ(0u, fallbackFonts.size()); |
204 } | 204 } |
205 | 205 |
| 206 TEST_F(CachingWordShaperTest, GlyphBoundsWithSpaces) |
| 207 { |
| 208 CachingWordShaper shaper(cache.get()); |
| 209 |
| 210 TextRun periods(reinterpret_cast<const LChar*>(".........."), 10); |
| 211 FloatRect periodsGlyphBounds; |
| 212 float periodsWidth = shaper.width(&font, periods, nullptr, &periodsGlyphBoun
ds); |
| 213 |
| 214 TextRun periodsAndSpaces(reinterpret_cast<const LChar*>(". . . . . . . . . .
"), 19); |
| 215 FloatRect periodsAndSpacesGlyphBounds; |
| 216 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr,
&periodsAndSpacesGlyphBounds); |
| 217 |
| 218 // The total width of periods and spaces should be longer than the width of
periods alone. |
| 219 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); |
| 220 |
| 221 // The glyph bounds of periods and spaces should be longer than the glyph bo
unds of periods alone. |
| 222 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); |
| 223 } |
| 224 |
206 } // namespace blink | 225 } // namespace blink |
OLD | NEW |