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/HarfBuzzShaper.h" | 6 #include "platform/fonts/shaping/HarfBuzzShaper.h" |
7 | 7 |
8 #include "platform/fonts/Font.h" | 8 #include "platform/fonts/Font.h" |
9 #include "platform/fonts/FontCache.h" | 9 #include "platform/fonts/FontCache.h" |
10 #include "platform/fonts/GlyphPage.h" | 10 #include "platform/fonts/GlyphPage.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 { "Not-defined Variants", { 0x41, 0xDB40, 0xDDEF }, HB_SCRIPT_LATIN }, | 78 { "Not-defined Variants", { 0x41, 0xDB40, 0xDDEF }, HB_SCRIPT_LATIN }, |
79 }; | 79 }; |
80 for (auto& test : testlist) { | 80 for (auto& test : testlist) { |
81 String str(test.string); | 81 String str(test.string); |
82 TextRun run(str); | 82 TextRun run(str); |
83 HarfBuzzShaper shaper(font, run); | 83 HarfBuzzShaper shaper(font, run); |
84 shaper.shape(); | 84 shaper.shape(); |
85 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()) << test.name; | 85 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()) << test.name; |
86 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script))
<< test.name; | 86 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script))
<< test.name; |
87 EXPECT_EQ(0u, startIndex) << test.name; | 87 EXPECT_EQ(0u, startIndex) << test.name; |
88 // TODO(kojii): HarfBuzzFace does not support UVS yet and numGlyphs beco
mes 2 | 88 if (numGlyphs == 2) { |
89 // EXPECT_EQ(1u, numGlyphs) << test.name; | 89 // If the specified VS is not in the font, it's mapped to .notdef. |
| 90 // then hb_ot_hide_default_ignorables() swaps it to a space with zer
o-advance. |
| 91 // http://lists.freedesktop.org/archives/harfbuzz/2015-May/004888.ht
ml |
| 92 // OpenType recommends Glyph ID 3 for a space; not a hard requiremen
t though. |
| 93 // https://www.microsoft.com/typography/otspec/recom.htm |
| 94 #if !OS(MACOSX) |
| 95 EXPECT_EQ(3u, shaper.glyphForTesting(0, 1)) << test.name; |
| 96 #endif |
| 97 EXPECT_EQ(0.f, shaper.advanceForTesting(0, 1)) << test.name; |
| 98 } else { |
| 99 EXPECT_EQ(1u, numGlyphs) << test.name; |
| 100 } |
90 EXPECT_EQ(test.script, script) << test.name; | 101 EXPECT_EQ(test.script, script) << test.name; |
91 } | 102 } |
92 } | 103 } |
93 | 104 |
94 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon) | 105 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon) |
95 { | 106 { |
96 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 }; | 107 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 }; |
97 TextRun devanagariCommonLatin(devanagariCommonString, 6); | 108 TextRun devanagariCommonLatin(devanagariCommonString, 6); |
98 HarfBuzzShaper shaper(font, devanagariCommonLatin); | 109 HarfBuzzShaper shaper(font, devanagariCommonLatin); |
99 shaper.shape(); | 110 shaper.shape(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 shaper.shape(); | 182 shaper.shape(); |
172 | 183 |
173 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()); | 184 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()); |
174 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script)); | 185 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script)); |
175 EXPECT_EQ(0u, startIndex); | 186 EXPECT_EQ(0u, startIndex); |
176 EXPECT_EQ(3u, numGlyphs); | 187 EXPECT_EQ(3u, numGlyphs); |
177 EXPECT_EQ(HB_SCRIPT_ARABIC, script); | 188 EXPECT_EQ(HB_SCRIPT_ARABIC, script); |
178 } | 189 } |
179 | 190 |
180 } // namespace blink | 191 } // namespace blink |
OLD | NEW |