| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 HarfBuzzShaper shaper(font, leadingCommon); | 60 HarfBuzzShaper shaper(font, leadingCommon); |
| 61 shaper.shape(); | 61 shaper.shape(); |
| 62 | 62 |
| 63 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); | 63 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); |
| 64 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); | 64 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); |
| 65 ASSERT_EQ(startIndex, 0u); | 65 ASSERT_EQ(startIndex, 0u); |
| 66 ASSERT_EQ(numGlyphs, 8u); | 66 ASSERT_EQ(numGlyphs, 8u); |
| 67 ASSERT_EQ(script, HB_SCRIPT_LATIN); | 67 ASSERT_EQ(script, HB_SCRIPT_LATIN); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsUnicodeVariants) | |
| 71 { | |
| 72 struct { | |
| 73 const char* name; | |
| 74 UChar string[4]; | |
| 75 hb_script_t script; | |
| 76 } testlist[] = { | |
| 77 { "Standard Variants text style", { 0x30, 0xFE0E }, HB_SCRIPT_COMMON }, | |
| 78 { "Standard Variants emoji style", { 0x203C, 0xFE0F }, HB_SCRIPT_COMMON
}, | |
| 79 { "Standard Variants of Ideograph", { 0x4FAE, 0xFE00 }, HB_SCRIPT_HAN }, | |
| 80 { "Ideographic Variants", { 0x3402, 0xDB40, 0xDD00 }, HB_SCRIPT_HAN }, | |
| 81 { "Not-defined Variants", { 0x41, 0xDB40, 0xDDEF }, HB_SCRIPT_LATIN }, | |
| 82 }; | |
| 83 for (auto& test : testlist) { | |
| 84 TextRun run(test.string, wcslen((const wchar_t*)test.string)); | |
| 85 HarfBuzzShaper shaper(font, run); | |
| 86 shaper.shape(); | |
| 87 EXPECT_EQ(1u, shaper.numberOfRunsForTesting()) << test.name; | |
| 88 ASSERT_TRUE(shaper.runInfoForTesting(0, startIndex, numGlyphs, script))
<< test.name; | |
| 89 EXPECT_EQ(0u, startIndex) << test.name; | |
| 90 // TODO(kojii): HarfBuzzFace does not support UVS yet and numGlyphs beco
mes 2 | |
| 91 // EXPECT_EQ(1u, numGlyphs) << test.name; | |
| 92 EXPECT_EQ(test.script, script) << test.name; | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon) | 70 TEST_F(HarfBuzzShaperTest, ResolveCandidateRunsDevanagariCommon) |
| 97 { | 71 { |
| 98 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 }; | 72 UChar devanagariCommonString[] = { 0x915, 0x94d, 0x930, 0x28, 0x20, 0x29 }; |
| 99 TextRun devanagariCommonLatin(devanagariCommonString, 6); | 73 TextRun devanagariCommonLatin(devanagariCommonString, 6); |
| 100 HarfBuzzShaper shaper(font, devanagariCommonLatin); | 74 HarfBuzzShaper shaper(font, devanagariCommonLatin); |
| 101 shaper.shape(); | 75 shaper.shape(); |
| 102 | 76 |
| 103 ASSERT_EQ(shaper.numberOfRunsForTesting(), 2u); | 77 ASSERT_EQ(shaper.numberOfRunsForTesting(), 2u); |
| 104 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); | 78 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); |
| 105 ASSERT_EQ(startIndex, 0u); | 79 ASSERT_EQ(startIndex, 0u); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 shaper.shape(); | 147 shaper.shape(); |
| 174 | 148 |
| 175 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); | 149 ASSERT_EQ(shaper.numberOfRunsForTesting(), 1u); |
| 176 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); | 150 ASSERT_EQ(shaper.runInfoForTesting(0, startIndex, numGlyphs, script), true); |
| 177 ASSERT_EQ(startIndex, 0u); | 151 ASSERT_EQ(startIndex, 0u); |
| 178 ASSERT_EQ(numGlyphs, 3u); | 152 ASSERT_EQ(numGlyphs, 3u); |
| 179 ASSERT_EQ(script, HB_SCRIPT_ARABIC); | 153 ASSERT_EQ(script, HB_SCRIPT_ARABIC); |
| 180 } | 154 } |
| 181 | 155 |
| 182 } | 156 } |
| OLD | NEW |