• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "sfntly/table/core/os2_table.h"
18 
19 #include <algorithm>
20 
21 namespace sfntly {
22 /******************************************************************************
23  * Constants
24  ******************************************************************************/
25 const int64_t CodePageRange::kLatin1_1252 = (int64_t)1 << 0;
26 const int64_t CodePageRange::kLatin2_1250 = (int64_t)1 << (int64_t)1;
27 const int64_t CodePageRange::kCyrillic_1251 = (int64_t)1 << 2;
28 const int64_t CodePageRange::kGreek_1253 = (int64_t)1 << 3;
29 const int64_t CodePageRange::kTurkish_1254 = (int64_t)1 << 4;
30 const int64_t CodePageRange::kHebrew_1255 = (int64_t)1 << 5;
31 const int64_t CodePageRange::kArabic_1256 = (int64_t)1 << 6;
32 const int64_t CodePageRange::kWindowsBaltic_1257 = (int64_t)1 << 7;
33 const int64_t CodePageRange::kVietnamese_1258 = (int64_t)1 << 8;
34 const int64_t CodePageRange::kAlternateANSI9 = (int64_t)1 << 9;
35 const int64_t CodePageRange::kAlternateANSI10 = (int64_t)1 << 10;
36 const int64_t CodePageRange::kAlternateANSI11 = (int64_t)1 << 11;
37 const int64_t CodePageRange::kAlternateANSI12 = (int64_t)1 << 12;
38 const int64_t CodePageRange::kAlternateANSI13 = (int64_t)1 << 13;
39 const int64_t CodePageRange::kAlternateANSI14 = (int64_t)1 << 14;
40 const int64_t CodePageRange::kAlternateANSI15 = (int64_t)1 << 15;
41 const int64_t CodePageRange::kThai_874 = (int64_t)1 << 16;
42 const int64_t CodePageRange::kJapanJIS_932 = (int64_t)1 << 17;
43 const int64_t CodePageRange::kChineseSimplified_936 = (int64_t)1 << 18;
44 const int64_t CodePageRange::kKoreanWansung_949 = (int64_t)1 << 19;
45 const int64_t CodePageRange::kChineseTraditional_950 = (int64_t)1 << 20;
46 const int64_t CodePageRange::kKoreanJohab_1361 = (int64_t)1 << 21;
47 const int64_t CodePageRange::kAlternateANSI22 = (int64_t)1 << 22;
48 const int64_t CodePageRange::kAlternateANSI23 = (int64_t)1 << 23;
49 const int64_t CodePageRange::kAlternateANSI24 = (int64_t)1 << 24;
50 const int64_t CodePageRange::kAlternateANSI25 = (int64_t)1 << 25;
51 const int64_t CodePageRange::kAlternateANSI26 = (int64_t)1 << 26;
52 const int64_t CodePageRange::kAlternateANSI27 = (int64_t)1 << 27;
53 const int64_t CodePageRange::kAlternateANSI28 = (int64_t)1 << 28;
54 const int64_t CodePageRange::kMacintoshCharacterSet = (int64_t)1 << 29;
55 const int64_t CodePageRange::kOEMCharacterSet = (int64_t)1 << 30;
56 const int64_t CodePageRange::kSymbolCharacterSet = (int64_t)1 << 31;
57 const int64_t CodePageRange::kReservedForOEM32 = (int64_t)1 << 32;
58 const int64_t CodePageRange::kReservedForOEM33 = (int64_t)1 << 33;
59 const int64_t CodePageRange::kReservedForOEM34 = (int64_t)1 << 34;
60 const int64_t CodePageRange::kReservedForOEM35 = (int64_t)1 << 35;
61 const int64_t CodePageRange::kReservedForOEM36 = (int64_t)1 << 36;
62 const int64_t CodePageRange::kReservedForOEM37 = (int64_t)1 << 37;
63 const int64_t CodePageRange::kReservedForOEM38 = (int64_t)1 << 38;
64 const int64_t CodePageRange::kReservedForOEM39 = (int64_t)1 << 39;
65 const int64_t CodePageRange::kReservedForOEM40 = (int64_t)1 << 40;
66 const int64_t CodePageRange::kReservedForOEM41 = (int64_t)1 << 41;
67 const int64_t CodePageRange::kReservedForOEM42 = (int64_t)1 << 42;
68 const int64_t CodePageRange::kReservedForOEM43 = (int64_t)1 << 43;
69 const int64_t CodePageRange::kReservedForOEM44 = (int64_t)1 << 44;
70 const int64_t CodePageRange::kReservedForOEM45 = (int64_t)1 << 45;
71 const int64_t CodePageRange::kReservedForOEM46 = (int64_t)1 << 46;
72 const int64_t CodePageRange::kReservedForOEM47 = (int64_t)1 << 47;
73 const int64_t CodePageRange::kIBMGreek_869 = (int64_t)1 << 48;
74 const int64_t CodePageRange::kMSDOSRussion_866 = (int64_t)1 << 49;
75 const int64_t CodePageRange::kMSDOSNordic_865 = (int64_t)1 << 50;
76 const int64_t CodePageRange::kArabic_864 = (int64_t)1 << 51;
77 const int64_t CodePageRange::kMSDOSCanadianFrench_863 = (int64_t)1 << 52;
78 const int64_t CodePageRange::kHebrew_862 = (int64_t)1 << 53;
79 const int64_t CodePageRange::kMSDOSIcelandic_861 = (int64_t)1 << 54;
80 const int64_t CodePageRange::kMSDOSPortugese_860 = (int64_t)1 << 55;
81 const int64_t CodePageRange::kIBMTurkish_857 = (int64_t)1 << 56;
82 const int64_t CodePageRange::kIBMCyrillic_855 = (int64_t)1 << 57;
83 const int64_t CodePageRange::kLatin2_852 = (int64_t)1 << 58;
84 const int64_t CodePageRange::kMSDOSBaltic_775 = (int64_t)1 << 59;
85 const int64_t CodePageRange::kGreek_737 = (int64_t)1 << 60;
86 const int64_t CodePageRange::kArabic_708 = (int64_t)1 << 61;
87 const int64_t CodePageRange::kLatin1_850 = (int64_t)1 << 62;
88 const int64_t CodePageRange::kUS_437 = (int64_t)1 << 63;
89 
90 /******************************************************************************
91  * struct UnicodeRange
92  ******************************************************************************/
range(int32_t bit)93 int32_t UnicodeRange::range(int32_t bit) {
94   if (bit < 0 || bit > kLast) {
95     return -1;
96   }
97   return bit;
98 }
99 
100 /******************************************************************************
101  * class OS2Table
102  ******************************************************************************/
~OS2Table()103 OS2Table::~OS2Table() {}
104 
TableVersion()105 int32_t OS2Table::TableVersion() {
106   return data_->ReadUShort(Offset::kVersion);
107 }
108 
XAvgCharWidth()109 int32_t OS2Table::XAvgCharWidth() {
110   return data_->ReadShort(Offset::kXAvgCharWidth);
111 }
112 
UsWeightClass()113 int32_t OS2Table::UsWeightClass() {
114   return data_->ReadUShort(Offset::kUsWeightClass);
115 }
116 
UsWidthClass()117 int32_t OS2Table::UsWidthClass() {
118   return data_->ReadUShort(Offset::kUsWidthClass);
119 }
120 
FsType()121 int32_t OS2Table::FsType() {
122   return data_->ReadUShort(Offset::kFsType);
123 }
124 
YSubscriptXSize()125 int32_t OS2Table::YSubscriptXSize() {
126   return data_->ReadShort(Offset::kYSubscriptXSize);
127 }
128 
YSubscriptYSize()129 int32_t OS2Table::YSubscriptYSize() {
130   return data_->ReadShort(Offset::kYSubscriptYSize);
131 }
132 
YSubscriptXOffset()133 int32_t OS2Table::YSubscriptXOffset() {
134   return data_->ReadShort(Offset::kYSubscriptXOffset);
135 }
136 
YSubscriptYOffset()137 int32_t OS2Table::YSubscriptYOffset() {
138   return data_->ReadShort(Offset::kYSubscriptYOffset);
139 }
140 
YSuperscriptXSize()141 int32_t OS2Table::YSuperscriptXSize() {
142   return data_->ReadShort(Offset::kYSuperscriptXSize);
143 }
144 
YSuperscriptYSize()145 int32_t OS2Table::YSuperscriptYSize() {
146   return data_->ReadShort(Offset::kYSuperscriptYSize);
147 }
148 
YSuperscriptXOffset()149 int32_t OS2Table::YSuperscriptXOffset() {
150   return data_->ReadShort(Offset::kYSuperscriptXOffset);
151 }
152 
YSuperscriptYOffset()153 int32_t OS2Table::YSuperscriptYOffset() {
154   return data_->ReadShort(Offset::kYSuperscriptYOffset);
155 }
156 
YStrikeoutSize()157 int32_t OS2Table::YStrikeoutSize() {
158   return data_->ReadShort(Offset::kYStrikeoutSize);
159 }
160 
YStrikeoutPosition()161 int32_t OS2Table::YStrikeoutPosition() {
162   return data_->ReadShort(Offset::kYStrikeoutPosition);
163 }
164 
SFamilyClass()165 int32_t OS2Table::SFamilyClass() {
166   return data_->ReadShort(Offset::kSFamilyClass);
167 }
168 
Panose(ByteVector * value)169 void OS2Table::Panose(ByteVector* value) {
170   assert(value);
171   value->clear();
172   value->resize(10);
173   data_->ReadBytes(Offset::kPanose, &((*value)[0]), 0, 10);
174 }
175 
UlUnicodeRange1()176 int64_t OS2Table::UlUnicodeRange1() {
177   return data_->ReadULong(Offset::kUlUnicodeRange1);
178 }
179 
UlUnicodeRange2()180 int64_t OS2Table::UlUnicodeRange2() {
181   return data_->ReadULong(Offset::kUlUnicodeRange2);
182 }
183 
UlUnicodeRange3()184 int64_t OS2Table::UlUnicodeRange3() {
185   return data_->ReadULong(Offset::kUlUnicodeRange3);
186 }
187 
UlUnicodeRange4()188 int64_t OS2Table::UlUnicodeRange4() {
189   return data_->ReadULong(Offset::kUlUnicodeRange4);
190 }
191 
AchVendId(ByteVector * b)192 void OS2Table::AchVendId(ByteVector* b) {
193   assert(b);
194   b->clear();
195   b->resize(4);
196   data_->ReadBytes(Offset::kAchVendId, &((*b)[0]), 0, 4);
197 }
198 
FsSelection()199 int32_t OS2Table::FsSelection() {
200   return data_->ReadUShort(Offset::kFsSelection);
201 }
202 
UsFirstCharIndex()203 int32_t OS2Table::UsFirstCharIndex() {
204   return data_->ReadUShort(Offset::kUsFirstCharIndex);
205 }
206 
UsLastCharIndex()207 int32_t OS2Table::UsLastCharIndex() {
208   return data_->ReadUShort(Offset::kUsLastCharIndex);
209 }
210 
STypoAscender()211 int32_t OS2Table::STypoAscender() {
212   return data_->ReadShort(Offset::kSTypoAscender);
213 }
214 
STypoDescender()215 int32_t OS2Table::STypoDescender() {
216   return data_->ReadShort(Offset::kSTypoDescender);
217 }
218 
STypoLineGap()219 int32_t OS2Table::STypoLineGap() {
220   return data_->ReadShort(Offset::kSTypoLineGap);
221 }
222 
UsWinAscent()223 int32_t OS2Table::UsWinAscent() {
224   return data_->ReadUShort(Offset::kUsWinAscent);
225 }
226 
UsWinDescent()227 int32_t OS2Table::UsWinDescent() {
228   return data_->ReadUShort(Offset::kUsWinDescent);
229 }
230 
UlCodePageRange1()231 int64_t OS2Table::UlCodePageRange1() {
232   return data_->ReadULong(Offset::kUlCodePageRange1);
233 }
234 
UlCodePageRange2()235 int64_t OS2Table::UlCodePageRange2() {
236   return data_->ReadULong(Offset::kUlCodePageRange2);
237 }
238 
SxHeight()239 int32_t OS2Table::SxHeight() {
240   return data_->ReadShort(Offset::kSxHeight);
241 }
242 
SCapHeight()243 int32_t OS2Table::SCapHeight() {
244   return data_->ReadShort(Offset::kSCapHeight);
245 }
246 
UsDefaultChar()247 int32_t OS2Table::UsDefaultChar() {
248   return data_->ReadUShort(Offset::kUsDefaultChar);
249 }
250 
UsBreakChar()251 int32_t OS2Table::UsBreakChar() {
252   return data_->ReadUShort(Offset::kUsBreakChar);
253 }
254 
UsMaxContext()255 int32_t OS2Table::UsMaxContext() {
256   return data_->ReadUShort(Offset::kUsMaxContext);
257 }
258 
OS2Table(Header * header,ReadableFontData * data)259 OS2Table::OS2Table(Header* header, ReadableFontData* data)
260     : Table(header, data) {
261 }
262 
263 /******************************************************************************
264  * class OS2Table::Builder
265  ******************************************************************************/
Builder(Header * header,WritableFontData * data)266 OS2Table::Builder::Builder(Header* header, WritableFontData* data)
267     : TableBasedTableBuilder(header, data) {
268 }
269 
Builder(Header * header,ReadableFontData * data)270 OS2Table::Builder::Builder(Header* header, ReadableFontData* data)
271     : TableBasedTableBuilder(header, data) {
272 }
273 
~Builder()274 OS2Table::Builder::~Builder() {}
275 
SubBuildTable(ReadableFontData * data)276 CALLER_ATTACH FontDataTable* OS2Table::Builder::SubBuildTable(
277     ReadableFontData* data) {
278   FontDataTablePtr table = new OS2Table(header(), data);
279   return table.Detach();
280 }
281 
282 CALLER_ATTACH OS2Table::Builder*
CreateBuilder(Header * header,WritableFontData * data)283     OS2Table::Builder::CreateBuilder(Header* header,
284                                      WritableFontData* data) {
285   Ptr<OS2Table::Builder> builder;
286   builder = new OS2Table::Builder(header, data);
287   return builder.Detach();
288 }
289 
TableVersion()290 int32_t OS2Table::Builder::TableVersion() {
291   return InternalReadData()->ReadUShort(Offset::kVersion);
292 }
293 
SetTableVersion(int32_t version)294 void OS2Table::Builder::SetTableVersion(int32_t version) {
295   InternalWriteData()->WriteUShort(Offset::kVersion, version);
296 }
297 
XAvgCharWidth()298 int32_t OS2Table::Builder::XAvgCharWidth() {
299   return InternalReadData()->ReadShort(Offset::kXAvgCharWidth);
300 }
301 
SetXAvgCharWidth(int32_t width)302 void OS2Table::Builder::SetXAvgCharWidth(int32_t width) {
303   InternalWriteData()->WriteShort(Offset::kXAvgCharWidth, width);
304 }
305 
UsWeightClass()306 int32_t OS2Table::Builder::UsWeightClass() {
307   return InternalReadData()->ReadUShort(Offset::kUsWeightClass);
308 }
309 
SetUsWeightClass(int32_t weight)310 void OS2Table::Builder::SetUsWeightClass(int32_t weight) {
311   InternalWriteData()->WriteUShort(Offset::kUsWeightClass, weight);
312 }
313 
UsWidthClass()314 int32_t OS2Table::Builder::UsWidthClass() {
315   return InternalReadData()->ReadUShort(Offset::kUsWidthClass);
316 }
317 
SetUsWidthClass(int32_t width)318 void OS2Table::Builder::SetUsWidthClass(int32_t width) {
319   InternalWriteData()->WriteUShort(Offset::kUsWidthClass, width);
320 }
321 
FsType()322 int32_t OS2Table::Builder::FsType() {
323   return InternalReadData()->ReadUShort(Offset::kFsType);
324 }
325 
SetFsType(int32_t fs_type)326 void OS2Table::Builder::SetFsType(int32_t fs_type) {
327   InternalWriteData()->WriteUShort(Offset::kFsType, fs_type);
328 }
329 
YSubscriptXSize()330 int32_t OS2Table::Builder::YSubscriptXSize() {
331   return InternalReadData()->ReadShort(Offset::kYSubscriptXSize);
332 }
333 
SetYSubscriptXSize(int32_t size)334 void OS2Table::Builder::SetYSubscriptXSize(int32_t size) {
335   InternalWriteData()->WriteShort(Offset::kYSubscriptXSize, size);
336 }
337 
YSubscriptYSize()338 int32_t OS2Table::Builder::YSubscriptYSize() {
339   return InternalReadData()->ReadShort(Offset::kYSubscriptYSize);
340 }
341 
SetYSubscriptYSize(int32_t size)342 void OS2Table::Builder::SetYSubscriptYSize(int32_t size) {
343   InternalWriteData()->WriteShort(Offset::kYSubscriptYSize, size);
344 }
345 
YSubscriptXOffset()346 int32_t OS2Table::Builder::YSubscriptXOffset() {
347   return InternalReadData()->ReadShort(Offset::kYSubscriptXOffset);
348 }
349 
SetYSubscriptXOffset(int32_t offset)350 void OS2Table::Builder::SetYSubscriptXOffset(int32_t offset) {
351   InternalWriteData()->WriteShort(Offset::kYSubscriptXOffset, offset);
352 }
353 
YSubscriptYOffset()354 int32_t OS2Table::Builder::YSubscriptYOffset() {
355   return InternalReadData()->ReadShort(Offset::kYSubscriptYOffset);
356 }
357 
SetYSubscriptYOffset(int32_t offset)358 void OS2Table::Builder::SetYSubscriptYOffset(int32_t offset) {
359   InternalWriteData()->WriteShort(Offset::kYSubscriptYOffset, offset);
360 }
361 
YSuperscriptXSize()362 int32_t OS2Table::Builder::YSuperscriptXSize() {
363   return InternalReadData()->ReadShort(Offset::kYSuperscriptXSize);
364 }
365 
SetYSuperscriptXSize(int32_t size)366 void OS2Table::Builder::SetYSuperscriptXSize(int32_t size) {
367   InternalWriteData()->WriteShort(Offset::kYSuperscriptXSize, size);
368 }
369 
YSuperscriptYSize()370 int32_t OS2Table::Builder::YSuperscriptYSize() {
371   return InternalReadData()->ReadShort(Offset::kYSuperscriptYSize);
372 }
373 
SetYSuperscriptYSize(int32_t size)374 void OS2Table::Builder::SetYSuperscriptYSize(int32_t size) {
375   InternalWriteData()->WriteShort(Offset::kYSuperscriptYSize, size);
376 }
377 
YSuperscriptXOffset()378 int32_t OS2Table::Builder::YSuperscriptXOffset() {
379   return InternalReadData()->ReadShort(Offset::kYSuperscriptXOffset);
380 }
381 
SetYSuperscriptXOffset(int32_t offset)382 void OS2Table::Builder::SetYSuperscriptXOffset(int32_t offset) {
383   InternalWriteData()->WriteShort(Offset::kYSuperscriptXOffset, offset);
384 }
385 
YSuperscriptYOffset()386 int32_t OS2Table::Builder::YSuperscriptYOffset() {
387   return InternalReadData()->ReadShort(Offset::kYSuperscriptYOffset);
388 }
389 
SetYSuperscriptYOffset(int32_t offset)390 void OS2Table::Builder::SetYSuperscriptYOffset(int32_t offset) {
391   InternalWriteData()->WriteShort(Offset::kYSuperscriptYOffset, offset);
392 }
393 
YStrikeoutSize()394 int32_t OS2Table::Builder::YStrikeoutSize() {
395   return InternalReadData()->ReadShort(Offset::kYStrikeoutSize);
396 }
397 
SetYStrikeoutSize(int32_t size)398 void OS2Table::Builder::SetYStrikeoutSize(int32_t size) {
399   InternalWriteData()->WriteShort(Offset::kYStrikeoutSize, size);
400 }
401 
YStrikeoutPosition()402 int32_t OS2Table::Builder::YStrikeoutPosition() {
403   return InternalReadData()->ReadShort(Offset::kYStrikeoutPosition);
404 }
405 
SetYStrikeoutPosition(int32_t position)406 void OS2Table::Builder::SetYStrikeoutPosition(int32_t position) {
407   InternalWriteData()->WriteShort(Offset::kYStrikeoutPosition, position);
408 }
409 
SFamilyClass()410 int32_t OS2Table::Builder::SFamilyClass() {
411   return InternalReadData()->ReadShort(Offset::kSFamilyClass);
412 }
413 
SetSFamilyClass(int32_t family)414 void OS2Table::Builder::SetSFamilyClass(int32_t family) {
415   InternalWriteData()->WriteShort(Offset::kSFamilyClass, family);
416 }
417 
Panose(ByteVector * value)418 void OS2Table::Builder::Panose(ByteVector* value) {
419   assert(value);
420   value->clear();
421   value->resize(Offset::kPanoseLength);
422   InternalReadData()->ReadBytes(Offset::kPanose,
423                                 &((*value)[0]),
424                                 0,
425                                 Offset::kPanoseLength);
426 }
427 
SetPanose(ByteVector * panose)428 void OS2Table::Builder::SetPanose(ByteVector* panose) {
429   assert(panose);
430   if (panose->size() != Offset::kPanoseLength) {
431 #if !defined (SFNTLY_NO_EXCEPTION)
432     throw IllegalArgumentException("Panose bytes must be exactly 10 in length");
433 #endif
434     return;
435   }
436   InternalWriteData()->WriteBytes(Offset::kPanose, panose);
437 }
438 
UlUnicodeRange1()439 int64_t OS2Table::Builder::UlUnicodeRange1() {
440   return InternalReadData()->ReadULong(Offset::kUlUnicodeRange1);
441 }
442 
SetUlUnicodeRange1(int64_t range)443 void OS2Table::Builder::SetUlUnicodeRange1(int64_t range) {
444   InternalWriteData()->WriteULong(Offset::kUlUnicodeRange1, range);
445 }
446 
UlUnicodeRange2()447 int64_t OS2Table::Builder::UlUnicodeRange2() {
448   return InternalReadData()->ReadULong(Offset::kUlUnicodeRange2);
449 }
450 
SetUlUnicodeRange2(int64_t range)451 void OS2Table::Builder::SetUlUnicodeRange2(int64_t range) {
452   InternalWriteData()->WriteULong(Offset::kUlUnicodeRange2, range);
453 }
454 
UlUnicodeRange3()455 int64_t OS2Table::Builder::UlUnicodeRange3() {
456   return InternalReadData()->ReadULong(Offset::kUlUnicodeRange3);
457 }
458 
SetUlUnicodeRange3(int64_t range)459 void OS2Table::Builder::SetUlUnicodeRange3(int64_t range) {
460   InternalWriteData()->WriteULong(Offset::kUlUnicodeRange3, range);
461 }
462 
UlUnicodeRange4()463 int64_t OS2Table::Builder::UlUnicodeRange4() {
464   return InternalReadData()->ReadULong(Offset::kUlUnicodeRange4);
465 }
466 
SetUlUnicodeRange4(int64_t range)467 void OS2Table::Builder::SetUlUnicodeRange4(int64_t range) {
468   InternalWriteData()->WriteULong(Offset::kUlUnicodeRange4, range);
469 }
470 
AchVendId(ByteVector * b)471 void OS2Table::Builder::AchVendId(ByteVector* b) {
472   assert(b);
473   b->clear();
474   b->resize(4);
475   InternalReadData()->ReadBytes(Offset::kAchVendId, &((*b)[0]), 0, 4);
476 }
477 
SetAchVendId(ByteVector * b)478 void OS2Table::Builder::SetAchVendId(ByteVector* b) {
479   assert(b);
480   assert(b->size());
481   InternalWriteData()->WriteBytesPad(Offset::kAchVendId,
482                                      b,
483                                      0,
484                                      std::min<size_t>(
485                                          (size_t)Offset::kAchVendIdLength,
486                                          b->size()),
487                                      static_cast<byte_t>(' '));
488 }
489 
FsSelection()490 int32_t OS2Table::Builder::FsSelection() {
491   return InternalReadData()->ReadUShort(Offset::kFsSelection);
492 }
493 
SetFsSelection(int32_t fs_selection)494 void OS2Table::Builder::SetFsSelection(int32_t fs_selection) {
495   InternalWriteData()->WriteUShort(Offset::kFsSelection, fs_selection);
496 }
497 
UsFirstCharIndex()498 int32_t OS2Table::Builder::UsFirstCharIndex() {
499   return InternalReadData()->ReadUShort(Offset::kUsFirstCharIndex);
500 }
501 
SetUsFirstCharIndex(int32_t first_index)502 void OS2Table::Builder::SetUsFirstCharIndex(int32_t first_index) {
503   InternalWriteData()->WriteUShort(Offset::kUsFirstCharIndex, first_index);
504 }
505 
UsLastCharIndex()506 int32_t OS2Table::Builder::UsLastCharIndex() {
507   return InternalReadData()->ReadUShort(Offset::kUsLastCharIndex);
508 }
509 
SetUsLastCharIndex(int32_t last_index)510 void OS2Table::Builder::SetUsLastCharIndex(int32_t last_index) {
511   InternalWriteData()->WriteUShort(Offset::kUsLastCharIndex, last_index);
512 }
513 
STypoAscender()514 int32_t OS2Table::Builder::STypoAscender() {
515   return InternalReadData()->ReadShort(Offset::kSTypoAscender);
516 }
517 
SetSTypoAscender(int32_t ascender)518 void OS2Table::Builder::SetSTypoAscender(int32_t ascender) {
519   InternalWriteData()->WriteShort(Offset::kSTypoAscender, ascender);
520 }
521 
STypoDescender()522 int32_t OS2Table::Builder::STypoDescender() {
523   return InternalReadData()->ReadShort(Offset::kSTypoDescender);
524 }
525 
SetSTypoDescender(int32_t descender)526 void OS2Table::Builder::SetSTypoDescender(int32_t descender) {
527   InternalWriteData()->WriteShort(Offset::kSTypoDescender, descender);
528 }
529 
STypoLineGap()530 int32_t OS2Table::Builder::STypoLineGap() {
531   return InternalReadData()->ReadShort(Offset::kSTypoLineGap);
532 }
533 
SetSTypoLineGap(int32_t line_gap)534 void OS2Table::Builder::SetSTypoLineGap(int32_t line_gap) {
535   InternalWriteData()->WriteShort(Offset::kSTypoLineGap, line_gap);
536 }
537 
UsWinAscent()538 int32_t OS2Table::Builder::UsWinAscent() {
539   return InternalReadData()->ReadUShort(Offset::kUsWinAscent);
540 }
541 
SetUsWinAscent(int32_t ascent)542 void OS2Table::Builder::SetUsWinAscent(int32_t ascent) {
543   InternalWriteData()->WriteUShort(Offset::kUsWinAscent, ascent);
544 }
545 
UsWinDescent()546 int32_t OS2Table::Builder::UsWinDescent() {
547   return InternalReadData()->ReadUShort(Offset::kUsWinDescent);
548 }
549 
SetUsWinDescent(int32_t descent)550 void OS2Table::Builder::SetUsWinDescent(int32_t descent) {
551   InternalWriteData()->WriteUShort(Offset::kUsWinDescent, descent);
552 }
553 
UlCodePageRange1()554 int64_t OS2Table::Builder::UlCodePageRange1() {
555   return InternalReadData()->ReadULong(Offset::kUlCodePageRange1);
556 }
557 
SetUlCodePageRange1(int64_t range)558 void OS2Table::Builder::SetUlCodePageRange1(int64_t range) {
559   InternalWriteData()->WriteULong(Offset::kUlCodePageRange1, range);
560 }
561 
UlCodePageRange2()562 int64_t OS2Table::Builder::UlCodePageRange2() {
563   return InternalReadData()->ReadULong(Offset::kUlCodePageRange2);
564 }
565 
SetUlCodePageRange2(int64_t range)566 void OS2Table::Builder::SetUlCodePageRange2(int64_t range) {
567   InternalWriteData()->WriteULong(Offset::kUlCodePageRange2, range);
568 }
569 
SxHeight()570 int32_t OS2Table::Builder::SxHeight() {
571   return InternalReadData()->ReadShort(Offset::kSxHeight);
572 }
573 
SetSxHeight(int32_t height)574 void OS2Table::Builder::SetSxHeight(int32_t height) {
575   InternalWriteData()->WriteShort(Offset::kSxHeight, height);
576 }
577 
SCapHeight()578 int32_t OS2Table::Builder::SCapHeight() {
579   return InternalReadData()->ReadShort(Offset::kSCapHeight);
580 }
581 
SetSCapHeight(int32_t height)582 void OS2Table::Builder::SetSCapHeight(int32_t height) {
583   InternalWriteData()->WriteShort(Offset::kSCapHeight, height);
584 }
585 
UsDefaultChar()586 int32_t OS2Table::Builder::UsDefaultChar() {
587   return InternalReadData()->ReadUShort(Offset::kUsDefaultChar);
588 }
589 
SetUsDefaultChar(int32_t default_char)590 void OS2Table::Builder::SetUsDefaultChar(int32_t default_char) {
591   InternalWriteData()->WriteUShort(Offset::kUsDefaultChar, default_char);
592 }
593 
UsBreakChar()594 int32_t OS2Table::Builder::UsBreakChar() {
595   return InternalReadData()->ReadUShort(Offset::kUsBreakChar);
596 }
597 
SetUsBreakChar(int32_t break_char)598 void OS2Table::Builder::SetUsBreakChar(int32_t break_char) {
599   InternalWriteData()->WriteUShort(Offset::kUsBreakChar, break_char);
600 }
601 
UsMaxContext()602 int32_t OS2Table::Builder::UsMaxContext() {
603   return InternalReadData()->ReadUShort(Offset::kUsMaxContext);
604 }
605 
SetUsMaxContext(int32_t max_context)606 void OS2Table::Builder::SetUsMaxContext(int32_t max_context) {
607   InternalWriteData()->WriteUShort(Offset::kUsMaxContext, max_context);
608 }
609 
610 }  // namespace sfntly
611