michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkOTTable_head_DEFINED michael@0: #define SkOTTable_head_DEFINED michael@0: michael@0: #include "SkEndian.h" michael@0: #include "SkOTTableTypes.h" michael@0: #include "SkTypedEnum.h" michael@0: michael@0: #pragma pack(push, 1) michael@0: michael@0: struct SkOTTableHead { michael@0: static const SK_OT_CHAR TAG0 = 'h'; michael@0: static const SK_OT_CHAR TAG1 = 'e'; michael@0: static const SK_OT_CHAR TAG2 = 'a'; michael@0: static const SK_OT_CHAR TAG3 = 'd'; michael@0: static const SK_OT_ULONG TAG = SkOTTableTAG::value; michael@0: michael@0: SK_OT_Fixed version; michael@0: static const SK_OT_Fixed version1 = SkTEndian_SwapBE32(0x00010000); michael@0: SK_OT_Fixed fontRevision; michael@0: static const uint32_t fontChecksum = 0xB1B0AFBA; //checksum of all TT fonts michael@0: SK_OT_ULONG checksumAdjustment; michael@0: SK_OT_ULONG magicNumber; michael@0: static const SK_OT_ULONG magicNumberConst = SkTEndian_SwapBE32(0x5F0F3CF5); michael@0: union Flags { michael@0: struct Field { michael@0: //8-15 michael@0: SK_OT_BYTE_BITFIELD( michael@0: GXMetamorphosis_Apple, michael@0: HasStrongRTL_Apple, michael@0: HasIndicStyleRearrangement, michael@0: AgfaMicroTypeExpressProcessed, michael@0: FontConverted, michael@0: DesignedForClearType, michael@0: LastResort, michael@0: Reserved15) michael@0: //0-7 michael@0: SK_OT_BYTE_BITFIELD( michael@0: BaselineAtY0, michael@0: LeftSidebearingAtX0, michael@0: InstructionsDependOnPointSize, michael@0: IntegerScaling, michael@0: InstructionsAlterAdvanceWidth, michael@0: VerticalCenteredGlyphs_Apple, michael@0: Reserved06, michael@0: RequiresLayout_Apple) michael@0: } field; michael@0: struct Raw { michael@0: static const SK_OT_USHORT BaselineAtY0Mask = SkTEndian_SwapBE16(1 << 0); michael@0: static const SK_OT_USHORT LeftSidebearingAtX0Mask = SkTEndian_SwapBE16(1 << 1); michael@0: static const SK_OT_USHORT InstructionsDependOnPointSizeMask = SkTEndian_SwapBE16(1 << 2); michael@0: static const SK_OT_USHORT IntegerScalingMask = SkTEndian_SwapBE16(1 << 3); michael@0: static const SK_OT_USHORT InstructionsAlterAdvanceWidthMask = SkTEndian_SwapBE16(1 << 4); michael@0: static const SK_OT_USHORT VerticalCenteredGlyphs_AppleMask = SkTEndian_SwapBE16(1 << 5); michael@0: //Reserved michael@0: static const SK_OT_USHORT RequiresLayout_AppleMask = SkTEndian_SwapBE16(1 << 7); michael@0: michael@0: static const SK_OT_USHORT GXMetamorphosis_AppleMask = SkTEndian_SwapBE16(1 << 8); michael@0: static const SK_OT_USHORT HasStrongRTL_AppleMask = SkTEndian_SwapBE16(1 << 9); michael@0: static const SK_OT_USHORT HasIndicStyleRearrangementMask = SkTEndian_SwapBE16(1 << 10); michael@0: static const SK_OT_USHORT AgfaMicroTypeExpressProcessedMask = SkTEndian_SwapBE16(1 << 11); michael@0: static const SK_OT_USHORT FontConvertedMask = SkTEndian_SwapBE16(1 << 12); michael@0: static const SK_OT_USHORT DesignedForClearTypeMask = SkTEndian_SwapBE16(1 << 13); michael@0: static const SK_OT_USHORT LastResortMask = SkTEndian_SwapBE16(1 << 14); michael@0: //Reserved michael@0: SK_OT_USHORT value; michael@0: } raw; michael@0: } flags; michael@0: SK_OT_USHORT unitsPerEm; michael@0: SK_OT_LONGDATETIME created; michael@0: SK_OT_LONGDATETIME modified; michael@0: SK_OT_SHORT xMin; michael@0: SK_OT_SHORT yMin; michael@0: SK_OT_SHORT xMax; michael@0: SK_OT_SHORT yMax; michael@0: union MacStyle { michael@0: struct Field { michael@0: //8-15 michael@0: SK_OT_BYTE_BITFIELD( michael@0: Reserved08, michael@0: Reserved09, michael@0: Reserved10, michael@0: Reserved11, michael@0: Reserved12, michael@0: Reserved13, michael@0: Reserved14, michael@0: Reserved15) michael@0: //0-7 michael@0: SK_OT_BYTE_BITFIELD( michael@0: Bold, michael@0: Italic, michael@0: Underline, michael@0: Outline, michael@0: Shadow, michael@0: Condensed, michael@0: Extended, michael@0: Reserved07) michael@0: } field; michael@0: struct Raw { michael@0: static const SK_OT_USHORT BoldMask = SkTEndian_SwapBE16(1); michael@0: static const SK_OT_USHORT ItalicMask = SkTEndian_SwapBE16(1 << 1); michael@0: static const SK_OT_USHORT UnderlineMask = SkTEndian_SwapBE16(1 << 2); michael@0: static const SK_OT_USHORT OutlineMask = SkTEndian_SwapBE16(1 << 3); michael@0: static const SK_OT_USHORT ShadowMask = SkTEndian_SwapBE16(1 << 4); michael@0: static const SK_OT_USHORT CondensedMask = SkTEndian_SwapBE16(1 << 5); michael@0: static const SK_OT_USHORT ExtendedMask = SkTEndian_SwapBE16(1 << 6); michael@0: michael@0: SK_OT_USHORT value; michael@0: } raw; michael@0: } macStyle; michael@0: SK_OT_USHORT lowestRecPPEM; michael@0: struct FontDirectionHint { michael@0: SK_TYPED_ENUM(Value, SK_OT_SHORT, michael@0: ((FullyMixedDirectionalGlyphs, SkTEndian_SwapBE16(0))) michael@0: ((OnlyStronglyLTR, SkTEndian_SwapBE16(1))) michael@0: ((StronglyLTR, SkTEndian_SwapBE16(2))) michael@0: ((OnlyStronglyRTL, static_cast(SkTEndian_SwapBE16((uint16_t)-1)))) michael@0: ((StronglyRTL, static_cast(SkTEndian_SwapBE16((uint16_t)-2)))) michael@0: SK_SEQ_END, michael@0: (value)SK_SEQ_END) michael@0: } fontDirectionHint; michael@0: struct IndexToLocFormat { michael@0: SK_TYPED_ENUM(Value, SK_OT_SHORT, michael@0: ((ShortOffsets, SkTEndian_SwapBE16(0))) michael@0: ((LongOffsets, SkTEndian_SwapBE16(1))) michael@0: SK_SEQ_END, michael@0: (value)SK_SEQ_END) michael@0: } indexToLocFormat; michael@0: struct GlyphDataFormat { michael@0: SK_TYPED_ENUM(Value, SK_OT_SHORT, michael@0: ((CurrentFormat, SkTEndian_SwapBE16(0))) michael@0: SK_SEQ_END, michael@0: (value)SK_SEQ_END) michael@0: } glyphDataFormat; michael@0: }; michael@0: michael@0: #pragma pack(pop) michael@0: michael@0: michael@0: #include michael@0: SK_COMPILE_ASSERT(offsetof(SkOTTableHead, glyphDataFormat) == 52, SkOTTableHead_glyphDataFormat_not_at_52); michael@0: SK_COMPILE_ASSERT(sizeof(SkOTTableHead) == 54, sizeof_SkOTTableHead_not_54); michael@0: michael@0: #endif