1 // Copyright (c) 2009-2017 The OTS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
15 // -----------------------------------------------------------------------------
16 // OpenTypeGLAT_Basic Interface
17 // -----------------------------------------------------------------------------
19 class OpenTypeGLAT_Basic
: public Table
{
21 explicit OpenTypeGLAT_Basic(Font
* font
, uint32_t tag
)
22 : Table(font
, tag
, tag
) { }
24 virtual bool Parse(const uint8_t* data
, size_t length
) = 0;
25 virtual bool Serialize(OTSStream
* out
) = 0;
28 // -----------------------------------------------------------------------------
30 // -----------------------------------------------------------------------------
32 class OpenTypeGLAT_v1
: public OpenTypeGLAT_Basic
{
34 explicit OpenTypeGLAT_v1(Font
* font
, uint32_t tag
)
35 : OpenTypeGLAT_Basic(font
, tag
) { }
37 bool Parse(const uint8_t* data
, size_t length
);
38 bool Serialize(OTSStream
* out
);
41 struct GlatEntry
: public TablePart
<OpenTypeGLAT_v1
> {
42 explicit GlatEntry(OpenTypeGLAT_v1
* parent
)
43 : TablePart
<OpenTypeGLAT_v1
>(parent
) { }
44 bool ParsePart(Buffer
& table
);
45 bool SerializePart(OTSStream
* out
) const;
48 std::vector
<int16_t> attributes
;
51 std::vector
<GlatEntry
> entries
;
54 // -----------------------------------------------------------------------------
56 // -----------------------------------------------------------------------------
58 class OpenTypeGLAT_v2
: public OpenTypeGLAT_Basic
{
60 explicit OpenTypeGLAT_v2(Font
* font
, uint32_t tag
)
61 : OpenTypeGLAT_Basic(font
, tag
) { }
63 bool Parse(const uint8_t* data
, size_t length
);
64 bool Serialize(OTSStream
* out
);
67 struct GlatEntry
: public TablePart
<OpenTypeGLAT_v2
> {
68 explicit GlatEntry(OpenTypeGLAT_v2
* parent
)
69 : TablePart
<OpenTypeGLAT_v2
>(parent
) { }
70 bool ParsePart(Buffer
& table
);
71 bool SerializePart(OTSStream
* out
) const;
74 std::vector
<int16_t> attributes
;
77 std::vector
<GlatEntry
> entries
;
80 // -----------------------------------------------------------------------------
82 // -----------------------------------------------------------------------------
84 class OpenTypeGLAT_v3
: public OpenTypeGLAT_Basic
{
86 explicit OpenTypeGLAT_v3(Font
* font
, uint32_t tag
)
87 : OpenTypeGLAT_Basic(font
, tag
) { }
89 bool Parse(const uint8_t* data
, size_t length
) {
90 return this->Parse(data
, length
, false);
92 bool Serialize(OTSStream
* out
);
95 bool Parse(const uint8_t* data
, size_t length
, bool prevent_decompression
);
96 struct GlyphAttrs
: public TablePart
<OpenTypeGLAT_v3
> {
97 explicit GlyphAttrs(OpenTypeGLAT_v3
* parent
)
98 : TablePart
<OpenTypeGLAT_v3
>(parent
), octabox(parent
) { }
99 bool ParsePart(Buffer
& table
) { return false; }
100 bool ParsePart(Buffer
& table
, const size_t size
);
101 bool SerializePart(OTSStream
* out
) const;
102 struct OctaboxMetrics
: public TablePart
<OpenTypeGLAT_v3
> {
103 explicit OctaboxMetrics(OpenTypeGLAT_v3
* parent
)
104 : TablePart
<OpenTypeGLAT_v3
>(parent
) { }
105 bool ParsePart(Buffer
& table
);
106 bool SerializePart(OTSStream
* out
) const;
107 struct SubboxEntry
: public TablePart
<OpenTypeGLAT_v3
> {
108 explicit SubboxEntry(OpenTypeGLAT_v3
* parent
)
109 : TablePart
<OpenTypeGLAT_v3
>(parent
) { }
110 bool ParsePart(Buffer
& table
);
111 bool SerializePart(OTSStream
* out
) const;
116 uint8_t diag_pos_min
;
117 uint8_t diag_pos_max
;
118 uint8_t diag_neg_min
;
119 uint8_t diag_neg_max
;
121 uint16_t subbox_bitmap
;
122 uint8_t diag_neg_min
;
123 uint8_t diag_neg_max
;
124 uint8_t diag_pos_min
;
125 uint8_t diag_pos_max
;
126 std::vector
<SubboxEntry
> subboxes
;
128 struct GlatEntry
: public TablePart
<OpenTypeGLAT_v3
> {
129 explicit GlatEntry(OpenTypeGLAT_v3
* parent
)
130 : TablePart
<OpenTypeGLAT_v3
>(parent
) { }
131 bool ParsePart(Buffer
& table
);
132 bool SerializePart(OTSStream
* out
) const;
135 std::vector
<int16_t> attributes
;
137 OctaboxMetrics octabox
;
138 std::vector
<GlatEntry
> entries
;
141 uint32_t compHead
; // compression header
142 static const uint32_t SCHEME
= 0xF8000000;
143 static const uint32_t FULL_SIZE
= 0x07FFFFFF;
144 static const uint32_t RESERVED
= 0x07FFFFFE;
145 static const uint32_t OCTABOXES
= 0x00000001;
146 std::vector
<GlyphAttrs
> entries
;
149 // -----------------------------------------------------------------------------
151 // -----------------------------------------------------------------------------
153 class OpenTypeGLAT
: public Table
{
155 explicit OpenTypeGLAT(Font
* font
, uint32_t tag
)
156 : Table(font
, tag
, tag
), font(font
), tag(tag
) { }
157 OpenTypeGLAT(const OpenTypeGLAT
& other
) = delete;
158 OpenTypeGLAT
& operator=(const OpenTypeGLAT
& other
) = delete;
159 ~OpenTypeGLAT() { delete handler
; }
161 bool Parse(const uint8_t* data
, size_t length
);
162 bool Serialize(OTSStream
* out
);
167 OpenTypeGLAT_Basic
* handler
= nullptr;
172 #endif // OTS_GLAT_H_