OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007,2008,2009 Red Hat, Inc. | 2 * Copyright © 2007,2008,2009 Red Hat, Inc. |
3 * Copyright (C) 2010 Google, Inc. | 3 * Copyright © 2010 Google, Inc. |
4 * | 4 * |
5 * This is part of HarfBuzz, a text shaping library. | 5 * This is part of HarfBuzz, a text shaping library. |
6 * | 6 * |
7 * Permission is hereby granted, without written agreement and without | 7 * Permission is hereby granted, without written agreement and without |
8 * license or royalty fees, to use, copy, modify, and distribute this | 8 * license or royalty fees, to use, copy, modify, and distribute this |
9 * software and its documentation for any purpose, provided that the | 9 * software and its documentation for any purpose, provided that the |
10 * above copyright notice and the following two paragraphs appear in | 10 * above copyright notice and the following two paragraphs appear in |
11 * all copies of this software. | 11 * all copies of this software. |
12 * | 12 * |
13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
(...skipping 17 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "hb-ot-layout-private.hh" | 32 #include "hb-ot-layout-private.hh" |
33 | 33 |
34 #include "hb-open-type-private.hh" | 34 #include "hb-open-type-private.hh" |
35 | 35 |
36 | 36 |
37 #define NO_CONTEXT ((unsigned int) 0x110000) | 37 #define NO_CONTEXT ((unsigned int) 0x110000) |
38 #define NOT_COVERED ((unsigned int) 0x110000) | 38 #define NOT_COVERED ((unsigned int) 0x110000) |
39 #define MAX_NESTING_LEVEL 8 | 39 #define MAX_NESTING_LEVEL 8 |
40 | 40 |
41 HB_BEGIN_DECLS | |
42 HB_END_DECLS | |
43 | 41 |
44 | 42 |
45 /* | 43 /* |
46 * | 44 * |
47 * OpenType Layout Common Table Formats | 45 * OpenType Layout Common Table Formats |
48 * | 46 * |
49 */ | 47 */ |
50 | 48 |
51 | 49 |
52 /* | 50 /* |
(...skipping 29 matching lines...) Expand all Loading... |
82 * for Record types. Instead, we return the correct Null(Tag) | 80 * for Record types. Instead, we return the correct Null(Tag) |
83 * here. */ | 81 * here. */ |
84 if (unlikely (i >= this->len)) return Null(Tag); | 82 if (unlikely (i >= this->len)) return Null(Tag); |
85 return (*this)[i].tag; | 83 return (*this)[i].tag; |
86 } | 84 } |
87 inline unsigned int get_tags (unsigned int start_offset, | 85 inline unsigned int get_tags (unsigned int start_offset, |
88 unsigned int *record_count /* IN/OUT */, | 86 unsigned int *record_count /* IN/OUT */, |
89 hb_tag_t *record_tags /* OUT */) const | 87 hb_tag_t *record_tags /* OUT */) const |
90 { | 88 { |
91 if (record_count) { | 89 if (record_count) { |
92 const Record<Type> *array = this->sub_array (start_offset, record_count); | 90 const Record<Type> *arr = this->sub_array (start_offset, record_count); |
93 unsigned int count = *record_count; | 91 unsigned int count = *record_count; |
94 for (unsigned int i = 0; i < count; i++) | 92 for (unsigned int i = 0; i < count; i++) |
95 » record_tags[i] = array[i].tag; | 93 » record_tags[i] = arr[i].tag; |
96 } | 94 } |
97 return this->len; | 95 return this->len; |
98 } | 96 } |
99 inline bool find_index (hb_tag_t tag, unsigned int *index) const | 97 inline bool find_index (hb_tag_t tag, unsigned int *index) const |
100 { | 98 { |
101 int i = this->search (tag); | 99 int i = this->search (tag); |
102 if (i != -1) { | 100 if (i != -1) { |
103 if (index) *index = i; | 101 if (index) *index = i; |
104 return true; | 102 return true; |
105 } else { | 103 } else { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 DEFINE_NULL_DATA (RangeRecord, "\000\001"); | 141 DEFINE_NULL_DATA (RangeRecord, "\000\001"); |
144 | 142 |
145 | 143 |
146 struct IndexArray : ArrayOf<Index> | 144 struct IndexArray : ArrayOf<Index> |
147 { | 145 { |
148 inline unsigned int get_indexes (unsigned int start_offset, | 146 inline unsigned int get_indexes (unsigned int start_offset, |
149 unsigned int *_count /* IN/OUT */, | 147 unsigned int *_count /* IN/OUT */, |
150 unsigned int *_indexes /* OUT */) const | 148 unsigned int *_indexes /* OUT */) const |
151 { | 149 { |
152 if (_count) { | 150 if (_count) { |
153 const USHORT *array = this->sub_array (start_offset, _count); | 151 const USHORT *arr = this->sub_array (start_offset, _count); |
154 unsigned int count = *_count; | 152 unsigned int count = *_count; |
155 for (unsigned int i = 0; i < count; i++) | 153 for (unsigned int i = 0; i < count; i++) |
156 » _indexes[i] = array[i]; | 154 » _indexes[i] = arr[i]; |
157 } | 155 } |
158 return this->len; | 156 return this->len; |
159 } | 157 } |
160 }; | 158 }; |
161 | 159 |
162 | 160 |
163 struct Script; | 161 struct Script; |
164 struct LangSys; | 162 struct LangSys; |
165 struct Feature; | 163 struct Feature; |
166 | 164 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 }; | 517 }; |
520 | 518 |
521 | 519 |
522 /* | 520 /* |
523 * Device Tables | 521 * Device Tables |
524 */ | 522 */ |
525 | 523 |
526 struct Device | 524 struct Device |
527 { | 525 { |
528 | 526 |
529 inline hb_position_t get_x_delta (hb_ot_layout_context_t *c) const | 527 inline hb_position_t get_x_delta (hb_font_t *font) const |
530 { return get_delta (c->font->x_ppem, c->font->x_scale); } | 528 { return get_delta (font->x_ppem, font->x_scale); } |
531 | 529 |
532 inline hb_position_t get_y_delta (hb_ot_layout_context_t *c) const | 530 inline hb_position_t get_y_delta (hb_font_t *font) const |
533 { return get_delta (c->font->y_ppem, c->font->y_scale); } | 531 { return get_delta (font->y_ppem, font->y_scale); } |
534 | 532 |
535 inline int get_delta (unsigned int ppem, unsigned int scale) const | 533 inline int get_delta (unsigned int ppem, int scale) const |
536 { | 534 { |
537 if (!ppem) return 0; | 535 if (!ppem) return 0; |
538 | 536 |
539 int pixels = get_delta_pixels (ppem); | 537 int pixels = get_delta_pixels (ppem); |
540 | 538 |
541 if (!pixels) return 0; | 539 if (!pixels) return 0; |
542 | 540 |
543 /* pixels is at most in the -8..7 range. So 64-bit arithmetic is | |
544 * not really necessary here. A simple cast to int may just work | |
545 * as well. But since this code is not reached that often and | |
546 * for the sake of correctness, we do a 64bit operation. */ | |
547 return pixels * (int64_t) scale / ppem; | 541 return pixels * (int64_t) scale / ppem; |
548 } | 542 } |
549 | 543 |
550 | 544 |
551 inline int get_delta_pixels (unsigned int ppem_size) const | 545 inline int get_delta_pixels (unsigned int ppem_size) const |
552 { | 546 { |
553 unsigned int f = deltaFormat; | 547 unsigned int f = deltaFormat; |
554 if (unlikely (f < 1 || f > 3)) | 548 if (unlikely (f < 1 || f > 3)) |
555 return 0; | 549 return 0; |
556 | 550 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 * 1 Signed 2-bit value, 8 values per
uint16 | 585 * 1 Signed 2-bit value, 8 values per
uint16 |
592 * 2 Signed 4-bit value, 4 values per
uint16 | 586 * 2 Signed 4-bit value, 4 values per
uint16 |
593 * 3 Signed 8-bit value, 2 values per
uint16 | 587 * 3 Signed 8-bit value, 2 values per
uint16 |
594 */ | 588 */ |
595 USHORT deltaValue[VAR]; /* Array of compressed data */ | 589 USHORT deltaValue[VAR]; /* Array of compressed data */ |
596 public: | 590 public: |
597 DEFINE_SIZE_ARRAY (6, deltaValue); | 591 DEFINE_SIZE_ARRAY (6, deltaValue); |
598 }; | 592 }; |
599 | 593 |
600 | 594 |
601 HB_BEGIN_DECLS | |
602 HB_END_DECLS | |
603 | 595 |
604 #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ | 596 #endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ |
OLD | NEW |