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