SkOTTable_EBLC.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright 2014 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_EBLC_DEFINED
  8. #define SkOTTable_EBLC_DEFINED
  9. #include "src/core/SkEndian.h"
  10. #include "src/sfnt/SkOTTableTypes.h"
  11. #include "src/sfnt/SkOTTable_EBDT.h"
  12. #pragma pack(push, 1)
  13. struct SkOTTableEmbeddedBitmapLocation {
  14. static const SK_OT_CHAR TAG0 = 'E';
  15. static const SK_OT_CHAR TAG1 = 'B';
  16. static const SK_OT_CHAR TAG2 = 'L';
  17. static const SK_OT_CHAR TAG3 = 'C';
  18. static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableEmbeddedBitmapLocation>::value;
  19. SK_OT_Fixed version;
  20. static const SK_OT_Fixed version_initial = SkTEndian_SwapBE32(0x00020000);
  21. SK_OT_ULONG numSizes;
  22. struct SbitLineMetrics {
  23. SK_OT_CHAR ascender;
  24. SK_OT_CHAR descender;
  25. SK_OT_BYTE widthMax;
  26. SK_OT_CHAR caretSlopeNumerator;
  27. SK_OT_CHAR caretSlopeDenominator;
  28. SK_OT_CHAR caretOffset;
  29. SK_OT_CHAR minOriginSB;
  30. SK_OT_CHAR minAdvanceSB;
  31. SK_OT_CHAR maxBeforeBL;
  32. SK_OT_CHAR minAfterBL;
  33. SK_OT_CHAR pad1;
  34. SK_OT_CHAR pad2;
  35. };
  36. struct BitmapSizeTable {
  37. SK_OT_ULONG indexSubTableArrayOffset; //offset to indexSubtableArray from beginning of EBLC.
  38. SK_OT_ULONG indexTablesSize; //number of bytes in corresponding index subtables and array
  39. SK_OT_ULONG numberOfIndexSubTables; //an index subtable for each range or format change
  40. SK_OT_ULONG colorRef; //not used; set to 0.
  41. SbitLineMetrics hori; //line metrics for text rendered horizontally
  42. SbitLineMetrics vert; //line metrics for text rendered vertically
  43. SK_OT_USHORT startGlyphIndex; //lowest glyph index for this size
  44. SK_OT_USHORT endGlyphIndex; //highest glyph index for this size
  45. SK_OT_BYTE ppemX; //horizontal pixels per Em
  46. SK_OT_BYTE ppemY; //vertical pixels per Em
  47. struct BitDepth {
  48. enum Value : SK_OT_BYTE {
  49. BW = 1,
  50. Gray4 = 2,
  51. Gray16 = 4,
  52. Gray256 = 8,
  53. };
  54. SK_OT_BYTE value;
  55. } bitDepth; //the Microsoft rasterizer v.1.7 or greater supports
  56. union Flags {
  57. struct Field {
  58. //0-7
  59. SK_OT_BYTE_BITFIELD(
  60. Horizontal, // Horizontal small glyph metrics
  61. Vertical, // Vertical small glyph metrics
  62. Reserved02,
  63. Reserved03,
  64. Reserved04,
  65. Reserved05,
  66. Reserved06,
  67. Reserved07)
  68. } field;
  69. struct Raw {
  70. static const SK_OT_CHAR Horizontal = 1u << 0;
  71. static const SK_OT_CHAR Vertical = 1u << 1;
  72. SK_OT_CHAR value;
  73. } raw;
  74. } flags;
  75. }; //bitmapSizeTable[numSizes];
  76. struct IndexSubTableArray {
  77. SK_OT_USHORT firstGlyphIndex; //first glyph code of this range
  78. SK_OT_USHORT lastGlyphIndex; //last glyph code of this range (inclusive)
  79. SK_OT_ULONG additionalOffsetToIndexSubtable; //add to BitmapSizeTable::indexSubTableArrayOffset to get offset from beginning of 'EBLC'
  80. }; //indexSubTableArray[BitmapSizeTable::numberOfIndexSubTables];
  81. struct IndexSubHeader {
  82. SK_OT_USHORT indexFormat; //format of this indexSubTable
  83. SK_OT_USHORT imageFormat; //format of 'EBDT' image data
  84. SK_OT_ULONG imageDataOffset; //offset to image data in 'EBDT' table
  85. };
  86. // Variable metrics glyphs with 4 byte offsets
  87. struct IndexSubTable1 {
  88. IndexSubHeader header;
  89. //SK_OT_ULONG offsetArray[lastGlyphIndex - firstGlyphIndex + 1 + 1]; //last element points to one past end of last glyph
  90. //glyphData = offsetArray[glyphIndex - firstGlyphIndex] + imageDataOffset
  91. };
  92. // All Glyphs have identical metrics
  93. struct IndexSubTable2 {
  94. IndexSubHeader header;
  95. SK_OT_ULONG imageSize; // all glyphs are of the same size
  96. SkOTTableEmbeddedBitmapData::BigGlyphMetrics bigMetrics; // all glyphs have the same metrics; glyph data may be compressed, byte-aligned, or bit-aligned
  97. };
  98. // Variable metrics glyphs with 2 byte offsets
  99. struct IndexSubTable3 {
  100. IndexSubHeader header;
  101. //SK_OT_USHORT offsetArray[lastGlyphIndex - firstGlyphIndex + 1 + 1]; //last element points to one past end of last glyph, may have extra element to force even number of elements
  102. //glyphData = offsetArray[glyphIndex - firstGlyphIndex] + imageDataOffset
  103. };
  104. // Variable metrics glyphs with sparse glyph codes
  105. struct IndexSubTable4 {
  106. IndexSubHeader header;
  107. SK_OT_ULONG numGlyphs;
  108. struct CodeOffsetPair {
  109. SK_OT_USHORT glyphCode;
  110. SK_OT_USHORT offset; //location in EBDT
  111. }; //glyphArray[numGlyphs+1]
  112. };
  113. // Constant metrics glyphs with sparse glyph codes
  114. struct IndexSubTable5 {
  115. IndexSubHeader header;
  116. SK_OT_ULONG imageSize; //all glyphs have the same data size
  117. SkOTTableEmbeddedBitmapData::BigGlyphMetrics bigMetrics; //all glyphs have the same metrics
  118. SK_OT_ULONG numGlyphs;
  119. //SK_OT_USHORT glyphCodeArray[numGlyphs] //must have even number of entries (set pad to 0)
  120. };
  121. union IndexSubTable {
  122. IndexSubHeader header;
  123. IndexSubTable1 format1;
  124. IndexSubTable2 format2;
  125. IndexSubTable3 format3;
  126. IndexSubTable4 format4;
  127. IndexSubTable5 format5;
  128. };
  129. };
  130. #pragma pack(pop)
  131. #endif