Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/opentype/OpenTypeCapsSupportTest.cpp

Issue 1882063002: Add OpenTypeCapsSupport class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@caseMapHbBufferFillerLand
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/fonts/opentype/OpenTypeCapsSupport.h"
6
7 #include "platform/fonts/Font.h"
8 #include "platform/testing/FontTestHelpers.h"
9 #include "platform/testing/UnitTestHelpers.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using blink::testing::createTestFont;
13
14 namespace blink {
15
16 static inline String layoutTestsFontPath(String relativePath)
17 {
18 return testing::blinkRootDir()
19 + String("/LayoutTests/third_party/")
20 + relativePath;
21 }
22
23 TEST(OpenTypeCapsSupportTest, LibertineSmcpC2scSupported)
24 {
25 Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLi bertine_R.woff"), 16);
26 const FontPlatformData& platformData = font.primaryFont()->platformData();
27
28 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::SmallCaps, HB_SCRIPT_LATIN);
29 EXPECT_FALSE(capsSupport.needsRunCaseSplitting());
30 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSame Case));
31 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppe rcaseNeeded));
32 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsSameCase));
33 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsUppercaseNeeded));
34 EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCaps Iterator::SmallCapsSameCase));
35 EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCaps Iterator::SmallCapsUppercaseNeeded));
36 }
37
38 TEST(OpenTypeCapsSupportTest, LibertineIgnoreMissingTitling)
39 {
40 Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLi bertine_R.woff"), 16);
41 const FontPlatformData& platformData = font.primaryFont()->platformData();
42
43 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::TitlingCaps, HB_SCRIPT_LATIN);
44 EXPECT_FALSE(capsSupport.needsRunCaseSplitting());
45 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSame Case));
46 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppe rcaseNeeded));
47 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsSameCase));
48 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsUppercaseNeeded));
49 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsSameCase));
50 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsUppercaseNeeded));
51 }
52
53 TEST(OpenTypeCapsSupportTest, LibertineAllPetiteSynthesis)
54 {
55 Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLi bertine_R.woff"), 16);
56 const FontPlatformData& platformData = font.primaryFont()->platformData();
57
58 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::AllPetiteCaps, HB_SCRIPT_LATIN);
59 EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
60 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSame Case));
61 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppe rcaseNeeded));
62 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsSameCase));
63 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsUppercaseNeeded));
64 EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallC apsIterator::SmallCapsSameCase));
65 EXPECT_EQ(FontDescription::AllSmallCaps, capsSupport.fontFeatureToUse(SmallC apsIterator::SmallCapsUppercaseNeeded));
66 }
67
68 TEST(OpenTypeCapsSupportTest, MEgalopolisSmallCapsSynthetic)
69 {
70 Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/M EgalopolisExtra.woff"), 16);
71 const FontPlatformData& platformData = font.primaryFont()->platformData();
72
73 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::SmallCaps, HB_SCRIPT_LATIN);
74 EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
75 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSame Case));
76 EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUpper caseNeeded));
77 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsSameCase));
78 EXPECT_EQ(CaseMapIntend::UpperCase, capsSupport.needsCaseChange(SmallCapsIte rator::SmallCapsUppercaseNeeded));
79 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsSameCase));
80 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsUppercaseNeeded));
81 }
82
83 TEST(OpenTypeCapsSupportTest, MEgalopolisUnicaseSynthetic)
84 {
85 Font font = createTestFont("MEgalopolis", layoutTestsFontPath("MEgalopolis/M EgalopolisExtra.woff"), 16);
86 const FontPlatformData& platformData = font.primaryFont()->platformData();
87
88 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::Unicase, HB_SCRIPT_LATIN);
89 EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
90 EXPECT_TRUE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSameC ase));
91 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppe rcaseNeeded));
92 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsSameCase));
93 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsUppercaseNeeded));
94 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsSameCase));
95 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsUppercaseNeeded));
96 }
97
98 TEST(OpenTypeCapsSupportTest, LibertineUnicaseFallback)
99 {
100 Font font = createTestFont("Libertine", layoutTestsFontPath("Libertine/LinLi bertine_R.woff"), 16);
101 const FontPlatformData& platformData = font.primaryFont()->platformData();
102
103 OpenTypeCapsSupport capsSupport(platformData.harfBuzzFace(), FontDescription ::Unicase, HB_SCRIPT_LATIN);
104 EXPECT_TRUE(capsSupport.needsRunCaseSplitting());
105 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsSame Case));
106 EXPECT_FALSE(capsSupport.needsSyntheticFont(SmallCapsIterator::SmallCapsUppe rcaseNeeded));
107 EXPECT_EQ(CaseMapIntend::LowerCase, capsSupport.needsCaseChange(SmallCapsIte rator::SmallCapsSameCase));
108 EXPECT_EQ(CaseMapIntend::KeepSameCase, capsSupport.needsCaseChange(SmallCaps Iterator::SmallCapsUppercaseNeeded));
109 EXPECT_EQ(FontDescription::SmallCaps, capsSupport.fontFeatureToUse(SmallCaps Iterator::SmallCapsSameCase));
110 EXPECT_EQ(FontDescription::CapsNormal, capsSupport.fontFeatureToUse(SmallCap sIterator::SmallCapsUppercaseNeeded));
111 }
112
113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698