/src/woff2/src/woff2_common.h
Line | Count | Source |
1 | | /* Copyright 2014 Google Inc. All Rights Reserved. |
2 | | |
3 | | Distributed under MIT license. |
4 | | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 | | */ |
6 | | |
7 | | /* Common definition for WOFF2 encoding/decoding */ |
8 | | |
9 | | #ifndef WOFF2_WOFF2_COMMON_H_ |
10 | | #define WOFF2_WOFF2_COMMON_H_ |
11 | | |
12 | | #include <stddef.h> |
13 | | #include <inttypes.h> |
14 | | |
15 | | #include <string> |
16 | | |
17 | | namespace woff2 { |
18 | | |
19 | | static const uint32_t kWoff2Signature = 0x774f4632; // "wOF2" |
20 | | |
21 | | // Leave the first byte open to store flag_byte |
22 | | const unsigned int kWoff2FlagsTransform = 1 << 8; |
23 | | |
24 | | // TrueType Collection ID string: 'ttcf' |
25 | | static const uint32_t kTtcFontFlavor = 0x74746366; |
26 | | |
27 | | static const size_t kSfntHeaderSize = 12; |
28 | | static const size_t kSfntEntrySize = 16; |
29 | | |
30 | | struct Point { |
31 | | int x; |
32 | | int y; |
33 | | bool on_curve; |
34 | | }; |
35 | | |
36 | | struct Table { |
37 | | uint32_t tag; |
38 | | uint32_t flags; |
39 | | uint32_t src_offset; |
40 | | uint32_t src_length; |
41 | | |
42 | | uint32_t transform_length; |
43 | | |
44 | | uint32_t dst_offset; |
45 | | uint32_t dst_length; |
46 | | const uint8_t* dst_data; |
47 | | |
48 | 8.40M | bool operator<(const Table& other) const { |
49 | 8.40M | return tag < other.tag; |
50 | 8.40M | } |
51 | | }; |
52 | | |
53 | | |
54 | | // Size of the collection header. 0 if version indicates this isn't a |
55 | | // collection. Ref http://www.microsoft.com/typography/otspec/otff.htm, |
56 | | // True Type Collections |
57 | | size_t CollectionHeaderSize(uint32_t header_version, uint32_t num_fonts); |
58 | | |
59 | | // Compute checksum over size bytes of buf |
60 | | uint32_t ComputeULongSum(const uint8_t* buf, size_t size); |
61 | | |
62 | | } // namespace woff2 |
63 | | |
64 | | #endif // WOFF2_WOFF2_COMMON_H_ |