OLD | NEW |
1 // Copyright 2015 Google Inc. All Rights Reserved. | 1 // Copyright 2015 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } else { | 42 } else { |
43 out->push_back(253); | 43 out->push_back(253); |
44 out->push_back(value >> 8); | 44 out->push_back(value >> 8); |
45 out->push_back(value & 0xff); | 45 out->push_back(value & 0xff); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 void Store255UShort(int val, size_t* offset, uint8_t* dst) { | 49 void Store255UShort(int val, size_t* offset, uint8_t* dst) { |
50 std::vector<uint8_t> packed; | 50 std::vector<uint8_t> packed; |
51 Write255UShort(&packed, val); | 51 Write255UShort(&packed, val); |
52 for (uint8_t val : packed) { | 52 for (uint8_t packed_byte : packed) { |
53 dst[(*offset)++] = val; | 53 dst[(*offset)++] = packed_byte; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 // Based on section 6.1.1 of MicroType Express draft spec | 57 // Based on section 6.1.1 of MicroType Express draft spec |
58 bool Read255UShort(Buffer* buf, unsigned int* value) { | 58 bool Read255UShort(Buffer* buf, unsigned int* value) { |
59 static const int kWordCode = 253; | 59 static const int kWordCode = 253; |
60 static const int kOneMoreByteCode2 = 254; | 60 static const int kOneMoreByteCode2 = 254; |
61 static const int kOneMoreByteCode1 = 255; | 61 static const int kOneMoreByteCode1 = 255; |
62 static const int kLowestUCode = 253; | 62 static const int kLowestUCode = 253; |
63 uint8_t code = 0; | 63 uint8_t code = 0; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 int b = static_cast<int>((len >> (7 * (size - i - 1))) & 0x7f); | 128 int b = static_cast<int>((len >> (7 * (size - i - 1))) & 0x7f); |
129 if (i < size - 1) { | 129 if (i < size - 1) { |
130 b |= 0x80; | 130 b |= 0x80; |
131 } | 131 } |
132 dst[(*offset)++] = b; | 132 dst[(*offset)++] = b; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 } // namespace woff2 | 136 } // namespace woff2 |
137 | 137 |
OLD | NEW |