| /* |
| * Copyright 2011 Google Inc. All Rights Reserved. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| #ifndef TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_OS2_TABLE_H_ |
| #define TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_OS2_TABLE_H_ |
| |
| #include "sfntly/port/refcount.h" |
| #include "sfntly/table.h" |
| |
| namespace sfntly { |
| |
| struct WeightClass { |
| enum { |
| kThin = 100, |
| kExtraLight = 200, |
| kUltraLight = 200, |
| kLight = 300, |
| kNormal = 400, |
| kRegular = 400, |
| kMedium = 500, |
| kSemiBold = 600, |
| kDemiBold = 600, |
| kBold = 700, |
| kExtraBold = 800, |
| kUltraBold = 800, |
| kBlack = 900, |
| kHeavy = 900 |
| }; |
| }; |
| |
| struct WidthClass { |
| enum { |
| kUltraCondensed = 1, |
| kExtraCondensed = 2, |
| kCondensed = 3, |
| kSemiCondensed = 4, |
| kMedium = 5, |
| kNormal = 5, |
| kSemiExpanded = 6, |
| kExpanded = 7, |
| kExtraExpanded = 8, |
| kUltraExpanded = 9 |
| }; |
| }; |
| |
| struct EmbeddingFlags { |
| enum { |
| kReserved0 = 1 << 0, |
| kRestrictedLicenseEmbedding = 1 << 1, |
| kPreviewAndPrintEmbedding = 1 << 2, |
| kEditableEmbedding = 1 << 3, |
| kReserved4 = 1 << 4, |
| kReserved5 = 1 << 5, |
| kReserved6 = 1 << 6, |
| kReserved7 = 1 << 7, |
| kNoSubsetting = 1 << 8, |
| kBitmapEmbeddingOnly = 1 << 9, |
| kReserved10 = 1 << 10, |
| kReserved11 = 1 << 11, |
| kReserved12 = 1 << 12, |
| kReserved13 = 1 << 13, |
| kReserved14 = 1 << 14, |
| kReserved15 = 1 << 15 |
| }; |
| }; |
| |
| struct UnicodeRange { |
| enum { |
| // This enum relies on the ordering of the data matching the ordinal numbers |
| // of the properties. |
| kBasicLatin, |
| kLatin1Supplement, |
| kLatinExtendedA, |
| kLatinExtendedB, |
| kIPAExtensions, |
| kSpacingModifierLetters, |
| kCombiningDiacriticalMarks, |
| kGreekAndCoptic, |
| kCoptic, |
| kCyrillic, |
| kArmenian, |
| kHebrew, |
| kVai, |
| kArabic, |
| kNKo, |
| kDevanagari, |
| kBengali, |
| kGurmukhi, |
| kGujarati, |
| kOriya, |
| kTamil, |
| kTelugu, |
| kKannada, |
| kMalayalam, |
| kThai, |
| kLao, |
| kGeorgian, |
| kBalinese, |
| kHangulJamo, |
| kLatinExtendedAdditional, |
| kGreekExtended, |
| kGeneralPunctuation, |
| kSuperscriptsAndSubscripts, |
| kCurrencySymbols, |
| kNumberForms, |
| kArrows, |
| kMathematicalOperators, |
| kMiscTechnical, |
| kControlPictures, |
| kOCR, |
| kEnclosedAlphanumerics, |
| kBoxDrawing, |
| kBlockElements, |
| kGeometricShapes, |
| kMiscSymbols, |
| kDingbats, |
| kCJKSymbolsAndPunctuation, |
| kHiragana, |
| kKatakana, |
| kBopomofo, |
| kHangulCompatibilityJamo, |
| kPhagspa, |
| kEnclosedCJKLettersAndMonths, |
| kCJKCompatibility, |
| kHangulSyllables, |
| kNonPlane0, |
| kPhoenician, |
| kCJKUnifiedIdeographs, |
| kPrivateUseAreaPlane0, |
| kCJKStrokes, |
| kAlphabeticPresentationForms, |
| kArabicPresentationFormsA, |
| kCombiningHalfMarks, |
| kVerticalForms, |
| kSmallFormVariants, |
| kArabicPresentationFormsB, |
| kHalfwidthAndFullwidthForms, |
| kSpecials, |
| kTibetan, |
| kSyriac, |
| kThaana, |
| kSinhala, |
| kMyanmar, |
| kEthiopic, |
| kCherokee, |
| kUnifiedCanadianAboriginalSyllabics, |
| kOgham, |
| kRunic, |
| kKhmer, |
| kMongolian, |
| kBraillePatterns, |
| kYiSyllables, |
| kTagalog, |
| kOldItalic, |
| kGothic, |
| kDeseret, |
| kMusicalSymbols, |
| kMathematicalAlphanumericSymbols, |
| kPrivateUsePlane15And16, |
| kVariationSelectors, |
| kTags, |
| kLimbu, |
| kTaiLe, |
| kNewTaiLue, |
| kBuginese, |
| kGlagolitic, |
| kTifnagh, |
| kYijingHexagramSymbols, |
| kSylotiNagari, |
| kLinearB, |
| kAncientGreekNumbers, |
| kUgaritic, |
| kOldPersian, |
| kShavian, |
| kOsmanya, |
| kCypriotSyllabary, |
| kKharoshthi, |
| kTaiXuanJingSymbols, |
| kCuneiform, |
| kCountingRodNumerals, |
| kSudanese, |
| kLepcha, |
| kOlChiki, |
| kSaurashtra, |
| kKayahLi, |
| kRejang, |
| kCharm, |
| kAncientSymbols, |
| kPhaistosDisc, |
| kCarian, |
| kDominoTiles, |
| kReserved123, |
| kReserved124, |
| kReserved125, |
| kReserved126, |
| kReserved127, |
| kLast = kReserved127 |
| }; |
| |
| int32_t range(int32_t bit); |
| // UNIMPLEMENTED: EnumSet<UnicodeRange> asSet(long range1, long range2, |
| // long range3, long range4) |
| }; |
| |
| struct FsSelection { |
| enum { |
| kITALIC = 1 << 0, |
| kUNDERSCORE = 1 << 1, |
| kNEGATIVE = 1 << 2, |
| kOUTLINED = 1 << 3, |
| kSTRIKEOUT = 1 << 4, |
| kBOLD = 1 << 5, |
| kREGULAR = 1 << 6, |
| kUSE_TYPO_METRICS = 1 << 7, |
| kWWS = 1 << 8, |
| kOBLIQUE = 1 << 9 |
| }; |
| }; |
| |
| // C++ port only: C++ does not support 64-bit enums until C++0x. For better |
| // portability, we need to use static const int64_t instead. |
| struct CodePageRange { |
| static const int64_t kLatin1_1252; |
| static const int64_t kLatin2_1250; |
| static const int64_t kCyrillic_1251; |
| static const int64_t kGreek_1253; |
| static const int64_t kTurkish_1254; |
| static const int64_t kHebrew_1255; |
| static const int64_t kArabic_1256; |
| static const int64_t kWindowsBaltic_1257; |
| static const int64_t kVietnamese_1258; |
| static const int64_t kAlternateANSI9; |
| static const int64_t kAlternateANSI10; |
| static const int64_t kAlternateANSI11; |
| static const int64_t kAlternateANSI12; |
| static const int64_t kAlternateANSI13; |
| static const int64_t kAlternateANSI14; |
| static const int64_t kAlternateANSI15; |
| static const int64_t kThai_874; |
| static const int64_t kJapanJIS_932; |
| static const int64_t kChineseSimplified_936; |
| static const int64_t kKoreanWansung_949; |
| static const int64_t kChineseTraditional_950; |
| static const int64_t kKoreanJohab_1361; |
| static const int64_t kAlternateANSI22; |
| static const int64_t kAlternateANSI23; |
| static const int64_t kAlternateANSI24; |
| static const int64_t kAlternateANSI25; |
| static const int64_t kAlternateANSI26; |
| static const int64_t kAlternateANSI27; |
| static const int64_t kAlternateANSI28; |
| static const int64_t kMacintoshCharacterSet; |
| static const int64_t kOEMCharacterSet; |
| static const int64_t kSymbolCharacterSet; |
| static const int64_t kReservedForOEM32; |
| static const int64_t kReservedForOEM33; |
| static const int64_t kReservedForOEM34; |
| static const int64_t kReservedForOEM35; |
| static const int64_t kReservedForOEM36; |
| static const int64_t kReservedForOEM37; |
| static const int64_t kReservedForOEM38; |
| static const int64_t kReservedForOEM39; |
| static const int64_t kReservedForOEM40; |
| static const int64_t kReservedForOEM41; |
| static const int64_t kReservedForOEM42; |
| static const int64_t kReservedForOEM43; |
| static const int64_t kReservedForOEM44; |
| static const int64_t kReservedForOEM45; |
| static const int64_t kReservedForOEM46; |
| static const int64_t kReservedForOEM47; |
| static const int64_t kIBMGreek_869; |
| static const int64_t kMSDOSRussion_866; |
| static const int64_t kMSDOSNordic_865; |
| static const int64_t kArabic_864; |
| static const int64_t kMSDOSCanadianFrench_863; |
| static const int64_t kHebrew_862; |
| static const int64_t kMSDOSIcelandic_861; |
| static const int64_t kMSDOSPortugese_860; |
| static const int64_t kIBMTurkish_857; |
| static const int64_t kIBMCyrillic_855; |
| static const int64_t kLatin2_852; |
| static const int64_t kMSDOSBaltic_775; |
| static const int64_t kGreek_737; |
| static const int64_t kArabic_708; |
| static const int64_t kLatin1_850; |
| static const int64_t kUS_437; |
| }; |
| |
| class OS2Table : public Table, public RefCounted<OS2Table> { |
| private: |
| struct Offset { |
| enum { |
| kVersion = 0, |
| kXAvgCharWidth = 2, |
| kUsWeightClass = 4, |
| kUsWidthClass = 6, |
| kFsType = 8, |
| kYSubscriptXSize = 10, |
| kYSubscriptYSize = 12, |
| kYSubscriptXOffset = 14, |
| kYSubscriptYOffset = 16, |
| kYSuperscriptXSize = 18, |
| kYSuperscriptYSize = 20, |
| kYSuperscriptXOffset = 22, |
| kYSuperscriptYOffset = 24, |
| kYStrikeoutSize = 26, |
| kYStrikeoutPosition = 28, |
| kSFamilyClass = 30, |
| kPanose = 32, |
| kUlUnicodeRange1 = 42, |
| kUlUnicodeRange2 = 46, |
| kUlUnicodeRange3 = 50, |
| kUlUnicodeRange4 = 54, |
| kAchVendId = 58, |
| kFsSelection = 62, |
| kUsFirstCharIndex = 64, |
| kUsLastCharIndex = 66, |
| kSTypoAscender = 68, |
| kSTypoDescender = 70, |
| kSTypoLineGap = 72, |
| kUsWinAscent = 74, |
| kUsWinDescent = 76, |
| kUlCodePageRange1 = 78, |
| kUlCodePageRange2 = 82, |
| kSxHeight = 86, |
| kSCapHeight = 88, |
| kUsDefaultChar = 90, |
| kUsBreakChar = 92, |
| kUsMaxContext = 94 |
| }; |
| }; |
| |
| OS2Table(Header* header, ReadableFontData* data); |
| |
| public: |
| ~OS2Table(); |
| |
| int32_t version(); |
| int32_t xAvgCharWidth(); |
| int32_t usWeightClass(); |
| int32_t usWidthClass(); |
| // UNIMPLEMENTED: public EnumSet<EmbeddingFlags> fsType() |
| int32_t fsType(); |
| int32_t ySubscriptXSize(); |
| int32_t ySubscriptYSize(); |
| int32_t ySubscriptXOffset(); |
| int32_t ySubscriptYOffset(); |
| int32_t ySuperscriptXSize(); |
| int32_t ySuperscriptYSize(); |
| int32_t ySuperscriptXOffset(); |
| int32_t ySuperscriptYOffset(); |
| int32_t yStrikeoutSize(); |
| int32_t yStrikeoutPosition(); |
| int32_t sFamilyClass(); |
| void panose(ByteVector* value); |
| int64_t ulUnicodeRange1(); |
| int64_t ulUnicodeRange2(); |
| int64_t ulUnicodeRange3(); |
| int64_t ulUnicodeRange4(); |
| // UNIMPLEMENTED: public EnumSet<UnicodeRange> ulUnicodeRange() |
| void achVendId(ByteVector* b); |
| // UNIMPLEMENTED: public EnumSet<FsSelection> fsSelection() |
| int32_t fsSelection(); |
| int32_t usFirstCharIndex(); |
| int32_t usLastCharIndex(); |
| int32_t sTypoAscender(); |
| int32_t sTypoDecender(); |
| int32_t sTypoLineGap(); |
| int32_t usWinAscent(); |
| int32_t usWinDescent(); |
| int64_t ulCodePageRange1(); |
| int64_t ulCodePageRange2(); |
| // UNIMPLEMENTED: public EnumSet<CodePageRange> ulCodePageRange() |
| int64_t ulCodePageRange(); |
| int32_t sxHeight(); |
| int32_t sCapHeight(); |
| int32_t usDefaultChar(); |
| int32_t usBreakChar(); |
| int32_t usMaxContext(); |
| |
| public: |
| class Builder : public Table::TableBasedTableBuilder, |
| public RefCounted<Builder> { |
| public: |
| Builder(FontDataTableBuilderContainer* font_builder, Header* header, |
| WritableFontData* data); |
| virtual ~Builder(); |
| virtual CALLER_ATTACH FontDataTable* subBuildTable(ReadableFontData* data); |
| }; |
| }; |
| |
| } // namespace sfntly |
| |
| #endif // TYPOGRAPHY_FONT_SFNTLY_SRC_SFNTLY_OS2_TABLE_H_ |