SkOTTable_head.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright 2012 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkOTTable_head_DEFINED
  8. #define SkOTTable_head_DEFINED
  9. #include "src/core/SkEndian.h"
  10. #include "src/sfnt/SkOTTableTypes.h"
  11. #pragma pack(push, 1)
  12. struct SkOTTableHead {
  13. static const SK_OT_CHAR TAG0 = 'h';
  14. static const SK_OT_CHAR TAG1 = 'e';
  15. static const SK_OT_CHAR TAG2 = 'a';
  16. static const SK_OT_CHAR TAG3 = 'd';
  17. static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableHead>::value;
  18. SK_OT_Fixed version;
  19. static const SK_OT_Fixed version1 = SkTEndian_SwapBE32(0x00010000);
  20. SK_OT_Fixed fontRevision;
  21. static const uint32_t fontChecksum = 0xB1B0AFBA; //checksum of all TT fonts
  22. SK_OT_ULONG checksumAdjustment;
  23. SK_OT_ULONG magicNumber;
  24. static const SK_OT_ULONG magicNumberConst = SkTEndian_SwapBE32(0x5F0F3CF5);
  25. union Flags {
  26. struct Field {
  27. //8-15
  28. SK_OT_BYTE_BITFIELD(
  29. GXMetamorphosis_Apple,
  30. HasStrongRTL_Apple,
  31. HasIndicStyleRearrangement,
  32. AgfaMicroTypeExpressProcessed,
  33. FontConverted,
  34. DesignedForClearType,
  35. LastResort,
  36. Reserved15)
  37. //0-7
  38. SK_OT_BYTE_BITFIELD(
  39. BaselineAtY0,
  40. LeftSidebearingAtX0,
  41. InstructionsDependOnPointSize,
  42. IntegerScaling,
  43. InstructionsAlterAdvanceWidth,
  44. VerticalCenteredGlyphs_Apple,
  45. Reserved06,
  46. RequiresLayout_Apple)
  47. } field;
  48. struct Raw {
  49. static const SK_OT_USHORT BaselineAtY0Mask = SkTEndian_SwapBE16(1 << 0);
  50. static const SK_OT_USHORT LeftSidebearingAtX0Mask = SkTEndian_SwapBE16(1 << 1);
  51. static const SK_OT_USHORT InstructionsDependOnPointSizeMask = SkTEndian_SwapBE16(1 << 2);
  52. static const SK_OT_USHORT IntegerScalingMask = SkTEndian_SwapBE16(1 << 3);
  53. static const SK_OT_USHORT InstructionsAlterAdvanceWidthMask = SkTEndian_SwapBE16(1 << 4);
  54. static const SK_OT_USHORT VerticalCenteredGlyphs_AppleMask = SkTEndian_SwapBE16(1 << 5);
  55. //Reserved
  56. static const SK_OT_USHORT RequiresLayout_AppleMask = SkTEndian_SwapBE16(1 << 7);
  57. static const SK_OT_USHORT GXMetamorphosis_AppleMask = SkTEndian_SwapBE16(1 << 8);
  58. static const SK_OT_USHORT HasStrongRTL_AppleMask = SkTEndian_SwapBE16(1 << 9);
  59. static const SK_OT_USHORT HasIndicStyleRearrangementMask = SkTEndian_SwapBE16(1 << 10);
  60. static const SK_OT_USHORT AgfaMicroTypeExpressProcessedMask = SkTEndian_SwapBE16(1 << 11);
  61. static const SK_OT_USHORT FontConvertedMask = SkTEndian_SwapBE16(1 << 12);
  62. static const SK_OT_USHORT DesignedForClearTypeMask = SkTEndian_SwapBE16(1 << 13);
  63. static const SK_OT_USHORT LastResortMask = SkTEndian_SwapBE16(1 << 14);
  64. //Reserved
  65. SK_OT_USHORT value;
  66. } raw;
  67. } flags;
  68. SK_OT_USHORT unitsPerEm;
  69. SK_OT_LONGDATETIME created;
  70. SK_OT_LONGDATETIME modified;
  71. SK_OT_SHORT xMin;
  72. SK_OT_SHORT yMin;
  73. SK_OT_SHORT xMax;
  74. SK_OT_SHORT yMax;
  75. union MacStyle {
  76. struct Field {
  77. //8-15
  78. SK_OT_BYTE_BITFIELD(
  79. Reserved08,
  80. Reserved09,
  81. Reserved10,
  82. Reserved11,
  83. Reserved12,
  84. Reserved13,
  85. Reserved14,
  86. Reserved15)
  87. //0-7
  88. SK_OT_BYTE_BITFIELD(
  89. Bold,
  90. Italic,
  91. Underline,
  92. Outline,
  93. Shadow,
  94. Condensed,
  95. Extended,
  96. Reserved07)
  97. } field;
  98. struct Raw {
  99. static const SK_OT_USHORT BoldMask = SkTEndian_SwapBE16(1);
  100. static const SK_OT_USHORT ItalicMask = SkTEndian_SwapBE16(1 << 1);
  101. static const SK_OT_USHORT UnderlineMask = SkTEndian_SwapBE16(1 << 2);
  102. static const SK_OT_USHORT OutlineMask = SkTEndian_SwapBE16(1 << 3);
  103. static const SK_OT_USHORT ShadowMask = SkTEndian_SwapBE16(1 << 4);
  104. static const SK_OT_USHORT CondensedMask = SkTEndian_SwapBE16(1 << 5);
  105. static const SK_OT_USHORT ExtendedMask = SkTEndian_SwapBE16(1 << 6);
  106. SK_OT_USHORT value;
  107. } raw;
  108. } macStyle;
  109. SK_OT_USHORT lowestRecPPEM;
  110. struct FontDirectionHint {
  111. enum Value : SK_OT_SHORT {
  112. FullyMixedDirectionalGlyphs = SkTEndian_SwapBE16(0),
  113. OnlyStronglyLTR = SkTEndian_SwapBE16(1),
  114. StronglyLTR = SkTEndian_SwapBE16(2),
  115. OnlyStronglyRTL = static_cast<SK_OT_SHORT>(SkTEndian_SwapBE16((uint16_t)-1)),
  116. StronglyRTL = static_cast<SK_OT_SHORT>(SkTEndian_SwapBE16((uint16_t)-2)),
  117. } value;
  118. } fontDirectionHint;
  119. struct IndexToLocFormat {
  120. enum Value : SK_OT_SHORT {
  121. ShortOffsets = SkTEndian_SwapBE16(0),
  122. LongOffsets = SkTEndian_SwapBE16(1),
  123. } value;
  124. } indexToLocFormat;
  125. struct GlyphDataFormat {
  126. enum Value : SK_OT_SHORT {
  127. CurrentFormat = SkTEndian_SwapBE16(0),
  128. } value;
  129. } glyphDataFormat;
  130. };
  131. #pragma pack(pop)
  132. #include <stddef.h>
  133. static_assert(offsetof(SkOTTableHead, glyphDataFormat) == 52, "SkOTTableHead_glyphDataFormat_not_at_52");
  134. static_assert(sizeof(SkOTTableHead) == 54, "sizeof_SkOTTableHead_not_54");
  135. #endif