2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkOTTable_EBLC_DEFINED
9 #define SkOTTable_EBLC_DEFINED
12 #include "SkOTTable_EBDT.h"
13 #include "SkOTTableTypes.h"
14 #include "SkTypedEnum.h"
18 struct SkOTTableEmbeddedBitmapLocation {
19 static const SK_OT_CHAR TAG0 = 'E';
20 static const SK_OT_CHAR TAG1 = 'B';
21 static const SK_OT_CHAR TAG2 = 'L';
22 static const SK_OT_CHAR TAG3 = 'C';
23 static const SK_OT_ULONG TAG = SkOTTableTAG<SkOTTableEmbeddedBitmapLocation>::value;
26 static const SK_OT_Fixed version_initial = SkTEndian_SwapBE32(0x00020000);
30 struct SbitLineMetrics {
34 SK_OT_CHAR caretSlopeNumerator;
35 SK_OT_CHAR caretSlopeDenominator;
36 SK_OT_CHAR caretOffset;
37 SK_OT_CHAR minOriginSB;
38 SK_OT_CHAR minAdvanceSB;
39 SK_OT_CHAR maxBeforeBL;
40 SK_OT_CHAR minAfterBL;
45 struct BitmapSizeTable {
46 SK_OT_ULONG indexSubTableArrayOffset; //offset to indexSubtableArray from beginning of EBLC.
47 SK_OT_ULONG indexTablesSize; //number of bytes in corresponding index subtables and array
48 SK_OT_ULONG numberOfIndexSubTables; //an index subtable for each range or format change
49 SK_OT_ULONG colorRef; //not used; set to 0.
50 SbitLineMetrics hori; //line metrics for text rendered horizontally
51 SbitLineMetrics vert; //line metrics for text rendered vertically
52 SK_OT_USHORT startGlyphIndex; //lowest glyph index for this size
53 SK_OT_USHORT endGlyphIndex; //highest glyph index for this size
54 SK_OT_BYTE ppemX; //horizontal pixels per Em
55 SK_OT_BYTE ppemY; //vertical pixels per Em
57 SK_TYPED_ENUM(Value, SK_OT_BYTE,
65 } bitDepth; //the Microsoft rasterizer v.1.7 or greater supports
70 Horizontal, // Horizontal small glyph metrics
71 Vertical, // Vertical small glyph metrics
80 static const SK_OT_CHAR Horizontal = 1u << 0;
81 static const SK_OT_CHAR Vertical = 1u << 1;
85 }; //bitmapSizeTable[numSizes];
87 struct IndexSubTableArray {
88 SK_OT_USHORT firstGlyphIndex; //first glyph code of this range
89 SK_OT_USHORT lastGlyphIndex; //last glyph code of this range (inclusive)
90 SK_OT_ULONG additionalOffsetToIndexSubtable; //add to BitmapSizeTable::indexSubTableArrayOffset to get offset from beginning of 'EBLC'
91 }; //indexSubTableArray[BitmapSizeTable::numberOfIndexSubTables];
93 struct IndexSubHeader {
94 SK_OT_USHORT indexFormat; //format of this indexSubTable
95 SK_OT_USHORT imageFormat; //format of 'EBDT' image data
96 SK_OT_ULONG imageDataOffset; //offset to image data in 'EBDT' table
99 // Variable metrics glyphs with 4 byte offsets
100 struct IndexSubTable1 {
101 IndexSubHeader header;
102 //SK_OT_ULONG offsetArray[lastGlyphIndex - firstGlyphIndex + 1 + 1]; //last element points to one past end of last glyph
103 //glyphData = offsetArray[glyphIndex - firstGlyphIndex] + imageDataOffset
106 // All Glyphs have identical metrics
107 struct IndexSubTable2 {
108 IndexSubHeader header;
109 SK_OT_ULONG imageSize; // all glyphs are of the same size
110 SkOTTableEmbeddedBitmapData::BigGlyphMetrics bigMetrics; // all glyphs have the same metrics; glyph data may be compressed, byte-aligned, or bit-aligned
113 // Variable metrics glyphs with 2 byte offsets
114 struct IndexSubTable3 {
115 IndexSubHeader header;
116 //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
117 //glyphData = offsetArray[glyphIndex - firstGlyphIndex] + imageDataOffset
120 // Variable metrics glyphs with sparse glyph codes
121 struct IndexSubTable4 {
122 IndexSubHeader header;
123 SK_OT_ULONG numGlyphs;
124 struct CodeOffsetPair {
125 SK_OT_USHORT glyphCode;
126 SK_OT_USHORT offset; //location in EBDT
127 }; //glyphArray[numGlyphs+1]
130 // Constant metrics glyphs with sparse glyph codes
131 struct IndexSubTable5 {
132 IndexSubHeader header;
133 SK_OT_ULONG imageSize; //all glyphs have the same data size
134 SkOTTableEmbeddedBitmapData::BigGlyphMetrics bigMetrics; //all glyphs have the same metrics
135 SK_OT_ULONG numGlyphs;
136 //SK_OT_USHORT glyphCodeArray[numGlyphs] //must have even number of entries (set pad to 0)
139 union IndexSubTable {
140 IndexSubHeader header;
141 IndexSubTable1 format1;
142 IndexSubTable2 format2;
143 IndexSubTable3 format3;
144 IndexSubTable4 format4;
145 IndexSubTable5 format5;