1 // Copyright 2013 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // Data model and I/O for glyph data within sfnt format files for the purpose of
16 // performing the preprocessing step of the WOFF 2.0 conversion.
18 #ifndef WOFF2_GLYPH_H_
19 #define WOFF2_GLYPH_H_
27 // Represents a parsed simple or composite glyph. The composite glyph data and
28 // instructions are un-parsed and we keep only pointers to the raw data,
29 // therefore the glyph is valid only so long the data from which it was parsed
33 Glyph() : instructions_size(0), composite_data_size(0) {}
42 uint16_t instructions_size
;
43 const uint8_t* instructions_data
;
45 // Data model for simple glyphs.
51 std::vector
<std::vector
<Point
> > contours
;
53 // Data for composite glyphs.
54 const uint8_t* composite_data
;
55 uint32_t composite_data_size
;
56 bool have_instructions
;
59 // Parses the glyph from the given data. Returns false on parsing failure or
60 // buffer overflow. The glyph is valid only so long the input data pointer is
62 bool ReadGlyph(const uint8_t* data
, size_t len
, Glyph
* glyph
);
64 // Stores the glyph into the specified dst buffer. The *dst_size is the buffer
65 // size on entry and is set to the actual (unpadded) stored size on exit.
66 // Returns false on buffer overflow.
67 bool StoreGlyph(const Glyph
& glyph
, uint8_t* dst
, size_t* dst_size
);
71 #endif // WOFF2_GLYPH_H_