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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 HarfBuzzShaper shaper(font, leadingCommon, &fallbackFonts); | 58 HarfBuzzShaper shaper(font, leadingCommon, &fallbackFonts); |
59 RefPtr<ShapeResult> result = shaper.shapeResult(); | 59 RefPtr<ShapeResult> result = shaper.shapeResult(); |
60 | 60 |
61 ASSERT_EQ(1u, result->numberOfRunsForTesting()); | 61 ASSERT_EQ(1u, result->numberOfRunsForTesting()); |
62 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 62 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
63 EXPECT_EQ(0u, startIndex); | 63 EXPECT_EQ(0u, startIndex); |
64 EXPECT_EQ(8u, numGlyphs); | 64 EXPECT_EQ(8u, numGlyphs); |
65 EXPECT_EQ(HB_SCRIPT_LATIN, script); | 65 EXPECT_EQ(HB_SCRIPT_LATIN, script); |
66 } | 66 } |
67 | 67 |
| 68 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsTabOnStart) |
| 69 { |
| 70 TextRun leadingTab(reinterpret_cast<const LChar*>("\t//TEST"), 7); |
| 71 leadingTab.setTabSize(true, TabSize(1)); |
| 72 HarfBuzzShaper shaper(font, leadingTab, &fallbackFonts); |
| 73 RefPtr<ShapeResult> result = shaper.shapeResult(); |
| 74 |
| 75 ASSERT_EQ(2u, result->numberOfRunsForTesting()); |
| 76 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 77 EXPECT_EQ(0u, startIndex); |
| 78 EXPECT_EQ(1u, numGlyphs); |
| 79 |
| 80 ASSERT_TRUE(result->runInfoForTesting(1, startIndex, numGlyphs, script)); |
| 81 EXPECT_EQ(1u, startIndex); |
| 82 EXPECT_EQ(6u, numGlyphs); |
| 83 } |
| 84 |
| 85 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsTabsOnStart) |
| 86 { |
| 87 TextRun leadingTab(reinterpret_cast<const LChar*>("\t\t\tTEST"), 7); |
| 88 leadingTab.setTabSize(true, TabSize(1)); |
| 89 HarfBuzzShaper shaper(font, leadingTab, &fallbackFonts); |
| 90 RefPtr<ShapeResult> result = shaper.shapeResult(); |
| 91 |
| 92 ASSERT_EQ(2u, result->numberOfRunsForTesting()); |
| 93 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 94 EXPECT_EQ(0u, startIndex); |
| 95 EXPECT_EQ(3u, numGlyphs); |
| 96 |
| 97 ASSERT_TRUE(result->runInfoForTesting(1, startIndex, numGlyphs, script)); |
| 98 EXPECT_EQ(3u, startIndex); |
| 99 EXPECT_EQ(4u, numGlyphs); |
| 100 } |
| 101 |
| 102 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsTabsOnEnd) |
| 103 { |
| 104 TextRun trailingTab(reinterpret_cast<const LChar*>("TEST\t\t\t"), 7); |
| 105 trailingTab.setTabSize(true, TabSize(1)); |
| 106 HarfBuzzShaper shaper(font, trailingTab, &fallbackFonts); |
| 107 RefPtr<ShapeResult> result = shaper.shapeResult(); |
| 108 |
| 109 ASSERT_EQ(2u, result->numberOfRunsForTesting()); |
| 110 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 111 EXPECT_EQ(0u, startIndex); |
| 112 EXPECT_EQ(4u, numGlyphs); |
| 113 |
| 114 ASSERT_TRUE(result->runInfoForTesting(1, startIndex, numGlyphs, script)); |
| 115 EXPECT_EQ(4u, startIndex); |
| 116 EXPECT_EQ(3u, numGlyphs); |
| 117 } |
| 118 |
| 119 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsTabsAfterSpaces) |
| 120 { |
| 121 TextRun tabsAfterSpaces(reinterpret_cast<const LChar*>("TEST \t\t\tTEST"),
13); |
| 122 tabsAfterSpaces.setTabSize(true, TabSize(1)); |
| 123 HarfBuzzShaper shaper(font, tabsAfterSpaces, &fallbackFonts); |
| 124 RefPtr<ShapeResult> result = shaper.shapeResult(); |
| 125 |
| 126 ASSERT_EQ(3u, result->numberOfRunsForTesting()); |
| 127 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 128 EXPECT_EQ(0u, startIndex); |
| 129 EXPECT_EQ(6u, numGlyphs); |
| 130 |
| 131 ASSERT_TRUE(result->runInfoForTesting(1, startIndex, numGlyphs, script)); |
| 132 EXPECT_EQ(6u, startIndex); |
| 133 EXPECT_EQ(3u, numGlyphs); |
| 134 |
| 135 ASSERT_TRUE(result->runInfoForTesting(2, startIndex, numGlyphs, script)); |
| 136 EXPECT_EQ(9u, startIndex); |
| 137 EXPECT_EQ(4u, numGlyphs); |
| 138 } |
| 139 |
| 140 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsTabsInMid) |
| 141 { |
| 142 TextRun tabsInMid(reinterpret_cast<const LChar*>("TEST\t\t\tTEST"), 11); |
| 143 tabsInMid.setTabSize(true, TabSize(1)); |
| 144 HarfBuzzShaper shaper(font, tabsInMid, &fallbackFonts); |
| 145 RefPtr<ShapeResult> result = shaper.shapeResult(); |
| 146 |
| 147 ASSERT_EQ(3u, result->numberOfRunsForTesting()); |
| 148 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 149 EXPECT_EQ(0u, startIndex); |
| 150 EXPECT_EQ(4u, numGlyphs); |
| 151 |
| 152 ASSERT_TRUE(result->runInfoForTesting(1, startIndex, numGlyphs, script)); |
| 153 EXPECT_EQ(4u, startIndex); |
| 154 EXPECT_EQ(3u, numGlyphs); |
| 155 |
| 156 ASSERT_TRUE(result->runInfoForTesting(2, startIndex, numGlyphs, script)); |
| 157 EXPECT_EQ(7u, startIndex); |
| 158 EXPECT_EQ(4u, numGlyphs); |
| 159 } |
| 160 |
68 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsUnicodeVariants) | 161 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsUnicodeVariants) |
69 { | 162 { |
70 struct { | 163 struct { |
71 const char* name; | 164 const char* name; |
72 UChar string[4]; | 165 UChar string[4]; |
73 hb_script_t script; | 166 hb_script_t script; |
74 } testlist[] = { | 167 } testlist[] = { |
75 { "Standard Variants text style", { 0x30, 0xFE0E }, HB_SCRIPT_COMMON }, | 168 { "Standard Variants text style", { 0x30, 0xFE0E }, HB_SCRIPT_COMMON }, |
76 { "Standard Variants emoji style", { 0x203C, 0xFE0F }, HB_SCRIPT_COMMON
}, | 169 { "Standard Variants emoji style", { 0x203C, 0xFE0F }, HB_SCRIPT_COMMON
}, |
77 { "Standard Variants of Ideograph", { 0x4FAE, 0xFE00 }, HB_SCRIPT_HAN }, | 170 { "Standard Variants of Ideograph", { 0x4FAE, 0xFE00 }, HB_SCRIPT_HAN }, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 RefPtr<ShapeResult> result = shaper.shapeResult(); | 277 RefPtr<ShapeResult> result = shaper.shapeResult(); |
185 | 278 |
186 ASSERT_EQ(1u, result->numberOfRunsForTesting()); | 279 ASSERT_EQ(1u, result->numberOfRunsForTesting()); |
187 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 280 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
188 EXPECT_EQ(0u, startIndex); | 281 EXPECT_EQ(0u, startIndex); |
189 EXPECT_EQ(3u, numGlyphs); | 282 EXPECT_EQ(3u, numGlyphs); |
190 EXPECT_EQ(HB_SCRIPT_ARABIC, script); | 283 EXPECT_EQ(HB_SCRIPT_ARABIC, script); |
191 } | 284 } |
192 | 285 |
193 } // namespace blink | 286 } // namespace blink |
OLD | NEW |