Changeset 215081 in webkit
- Timestamp:
- Apr 6, 2017 5:59:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r215079 r215081 1 2017-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Make FontWithFeatures test font pass OTS 4 https://bugs.webkit.org/show_bug.cgi?id=169788 5 6 Reviewed by Tim Horton. 7 8 Updated font to the one which passes the tests. 9 10 * css3/resources/FontWithFeatures.otf: 11 1 12 2017-04-06 Jiewen Tan <jiewen_tan@apple.com> 2 13 -
trunk/Tools/ChangeLog
r215080 r215081 1 2017-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Make FontWithFeatures test font pass OTS 4 https://bugs.webkit.org/show_bug.cgi?id=169788 5 6 Reviewed by Tim Horton. 7 8 OTS, or the OpenType Sanitizer, is a check which tells if fonts are properly formed. 9 Previously, our FontWithFeatures test font did not pass this check. This patch updates 10 the font to pass the checks. Now, we can use this font on other platforms, and 11 contribute the font to the W3C for testing the CSS Fonts level 3 spec. 12 13 * FontWithFeatures/FontWithFeatures/FontCreator.cpp: 14 (Generator::appendCFFTable): 15 (Generator::Feature::operator<): 16 (Generator::appendGSUBTable): 17 (Generator::appendOS2Table): 18 (Generator::appendFormat4CMAPTable): 19 (Generator::appendHEADTable): 20 (Generator::appendHHEATable): 21 (Generator::NameRecord::operator<): 22 (Generator::appendNameSubtable): 23 (Generator::appendNAMETable): 24 1 25 2017-04-06 Alexey Proskuryakov <ap@apple.com> 2 26 -
trunk/Tools/FontWithFeatures/FontWithFeatures/FontCreator.cpp
r190848 r215081 613 613 append32(clampTo<int32_t>(0)); // Bounding box x 614 614 result.push_back(operand32Bit); 615 append32(clampTo<int32_t>( 0)); // Bounding box y615 append32(clampTo<int32_t>(-1)); // Bounding box y 616 616 result.push_back(operand32Bit); 617 617 append32(clampTo<int32_t>(unitsPerEm)); // Bounding box max x … … 822 822 } 823 823 824 struct Feature { 825 bool operator<(const Feature& o) const 826 { 827 return tag < o.tag; 828 } 829 830 std::array<char, 5> tag; 831 uint16_t glyphToReplace; 832 }; 833 824 834 void appendGSUBTable() 825 835 { 826 std::vector<std::array<char, 5>> features {{"liga"}, {"clig"}, {"dlig"}, {"hlig"}, {"calt"}, {"subs"}, {"sups"}, {"smcp"}, {"c2sc"}, {"pcap"}, {"c2pc"}, {"unic"}, {"titl"}, {"lnum"}, {"onum"}, {"pnum"}, {"tnum"}, {"frac"}, {"afrc"}, {"ordn"}, {"zero"}, {"hist"}, {"jp78"}, {"jp83"}, {"jp90"}, {"jp04"}, {"smpl"}, {"trad"}, {"fwid"}, {"pwid"}, {"ruby"}}; 836 std::vector<Feature> features {{{"liga"}, 3}, {{"clig"}, 4}, {{"dlig"}, 5}, {{"hlig"}, 6}, {{"calt"}, 7}, {{"subs"}, 8}, {{"sups"}, 9}, {{"smcp"}, 10}, {{"c2sc"}, 11}, {{"pcap"}, 12}, {{"c2pc"}, 13}, {{"unic"}, 14}, {{"titl"}, 15}, {{"lnum"}, 16}, {{"onum"}, 17}, {{"pnum"}, 18}, {{"tnum"}, 19}, {{"frac"}, 20}, {{"afrc"}, 21}, {{"ordn"}, 22}, {{"zero"}, 23}, {{"hist"}, 24}, {{"jp78"}, 25}, {{"jp83"}, 26}, {{"jp90"}, 27}, {{"jp04"}, 28}, {{"smpl"}, 29}, {{"trad"}, 30}, {{"fwid"}, 31}, {{"pwid"}, 32}, {{"ruby"}, 33}}; 837 std::sort(features.begin(), features.end()); 827 838 auto tableLocation = result.size(); 828 839 auto headerSize = 10; … … 851 862 for (unsigned i = 0; i < features.size(); ++i) { 852 863 auto& code = features[i]; 853 append32BitCode(code. data()); // Feature name864 append32BitCode(code.tag.data()); // Feature name 854 865 append16(featureListSize + featureTableSize * i); // Offset of feature table, relative to beginning of FeatureList table 855 866 } … … 881 892 882 893 for (unsigned i = 0; i < features.size(); ++i) 883 appendSubstitutionSubtable(subtableRecordLocations[i], 3 + i, 1);894 appendSubstitutionSubtable(subtableRecordLocations[i], features[i].glyphToReplace, 1); 884 895 } 885 896 … … 914 925 append16(0xFFFF); // Last unicode index 915 926 append16(clampTo<int16_t>(unitsPerEm)); // Typographical ascender 916 append16(clampTo<int16_t>( 1)); // Typographical descender927 append16(clampTo<int16_t>(-1)); // Typographical descender 917 928 append16(clampTo<int16_t>(unitsPerEm / 10)); // Typographical line gap 918 929 append16(clampTo<uint16_t>(unitsPerEm)); // Windows-specific ascent 919 append16(clampTo<uint16_t>( 1)); // Windows-specific descent930 append16(clampTo<uint16_t>(0)); // Windows-specific descent 920 931 append32(0xFF10FC07); // Bitmask for supported codepages (Part 1). Report all pages as supported. 921 932 append32(0x0000FFFF); // Bitmask for supported codepages (Part 2). Report all pages as supported. … … 980 991 append16(0); // idRangeOffset 981 992 append16(0); 993 append16(0); 982 994 983 995 // Fonts strive to hold 2^16 glyphs, but with the current encoding scheme, we write 8 bytes per codepoint into this subtable. … … 1025 1037 append32(0); // Last half of modification date 1026 1038 append16(clampTo<int16_t>(0)); // bounding box x 1027 append16(clampTo<int16_t>( 0)); // bounding box y1039 append16(clampTo<int16_t>(-1)); // bounding box y 1028 1040 append16(clampTo<int16_t>(unitsPerEm)); // bounding box max x 1029 1041 append16(clampTo<int16_t>(unitsPerEm)); // bounding box max y … … 1039 1051 append32(0x00010000); // Version 1040 1052 append16(clampTo<int16_t>(unitsPerEm)); // ascent 1041 append16(clampTo<int16_t>( 1)); // descent1053 append16(clampTo<int16_t>(-1)); // descent 1042 1054 // WebKit SVG font rendering has hard coded the line gap to be 1/10th of the font size since 2008 (see r29719). 1043 1055 append16(clampTo<int16_t>(unitsPerEm / 10)); // line gap … … 1083 1095 } 1084 1096 1085 void appendNameSubtable(const std::string& s, uint16_t nameIdentifier) 1097 struct NameRecord { 1098 bool operator<(const NameRecord& o) const 1099 { 1100 return nameIdentifier < o.nameIdentifier; 1101 } 1102 1103 uint16_t nameIdentifier; 1104 std::string value; 1105 }; 1106 1107 void appendNameSubtable(const NameRecord& nameRecord) 1086 1108 { 1087 1109 append16(0); // Unicode 1088 1110 append16(3); // Unicode version 2.0 or later 1089 1111 append16(0); // Language 1090 append16(name Identifier); // Name identifier1091 append16( s.length() * 2); // Code units get 2 bytes each1112 append16(nameRecord.nameIdentifier); // Name identifier 1113 append16(nameRecord.value.length() * 2); // Code units get 2 bytes each 1092 1114 append16(m_nameOffset); // Offset into name data 1093 m_nameOffset += s.size() * 2; // Code units get 2 bytes each1115 m_nameOffset += nameRecord.value.size() * 2; // Code units get 2 bytes each 1094 1116 } 1095 1117 … … 1110 1132 append16(6 + 12 * numberOfRecords); // Offset in bytes to the beginning of name character strings 1111 1133 1112 appendNameSubtable(familyName, 1); // 1: Font Family. 1113 appendNameSubtable(familyName, 2); // 2: Font Subfamily. 1114 appendNameSubtable(familyName, 3); // 3: Unique subfamily identification. 1115 appendNameSubtable(familyName, 4); // 4: Full name of the font. 1116 appendNameSubtable(version, 5); // 5: Version of the name table. 1117 appendNameSubtable(familyName, 6); // 6: PostScript name of the font. 1134 std::vector<NameRecord> nameRecords = { { 1, familyName }, { 2, familyName }, { 3, familyName }, { 4, familyName }, { 5, version }, { 6, familyName } }; 1118 1135 for (FeatureType& type : featureDescription) { 1119 appendNameSubtable(type.name, m_baseStringIndex + type.stringIndex);1136 nameRecords.push_back({ static_cast<uint16_t>(m_baseStringIndex + type.stringIndex), type.name }); 1120 1137 for (FeatureSelector& selector : type.selectors) 1121 appendNameSubtable(selector.name, m_baseStringIndex + selector.stringIndex); 1122 } 1123 1124 append2ByteASCIIString(familyName); 1125 append2ByteASCIIString(familyName); 1126 append2ByteASCIIString(familyName); 1127 append2ByteASCIIString(familyName); 1128 append2ByteASCIIString(version); 1129 append2ByteASCIIString(familyName); 1130 for (FeatureType& type : featureDescription) { 1131 append2ByteASCIIString(type.name); 1132 for (FeatureSelector& selector : type.selectors) 1133 append2ByteASCIIString(selector.name); 1134 } 1138 nameRecords.push_back({ static_cast<uint16_t>(m_baseStringIndex + selector.stringIndex), selector.name }); 1139 } 1140 std::sort(nameRecords.begin(), nameRecords.end()); 1141 1142 for (auto& nameRecord : nameRecords) 1143 appendNameSubtable(nameRecord); 1144 1145 for (auto& nameRecord : nameRecords) 1146 append2ByteASCIIString(nameRecord.value); 1135 1147 } 1136 1148
Note: See TracChangeset
for help on using the changeset viewer.