OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2011,2012 Google, Inc. | 2 * Copyright © 2011,2012 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (ret) return ret; | 49 if (ret) return ret; |
50 ret = b->encodingID.cmp (a->encodingID); | 50 ret = b->encodingID.cmp (a->encodingID); |
51 if (ret) return ret; | 51 if (ret) return ret; |
52 ret = b->languageID.cmp (a->languageID); | 52 ret = b->languageID.cmp (a->languageID); |
53 if (ret) return ret; | 53 if (ret) return ret; |
54 ret = b->nameID.cmp (a->nameID); | 54 ret = b->nameID.cmp (a->nameID); |
55 if (ret) return ret; | 55 if (ret) return ret; |
56 return 0; | 56 return 0; |
57 } | 57 } |
58 | 58 |
59 inline bool sanitize (hb_sanitize_context_t *c, void *base) { | 59 inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 60 { |
60 TRACE_SANITIZE (this); | 61 TRACE_SANITIZE (this); |
61 /* We can check from base all the way up to the end of string... */ | 62 /* We can check from base all the way up to the end of string... */ |
62 return TRACE_RETURN (c->check_struct (this) && c->check_range ((char *) base
, (unsigned int) length + offset)); | 63 return TRACE_RETURN (c->check_struct (this) && c->check_range ((char *) base
, (unsigned int) length + offset)); |
63 } | 64 } |
64 | 65 |
65 USHORT platformID; /* Platform ID. */ | 66 USHORT platformID; /* Platform ID. */ |
66 USHORT encodingID; /* Platform-specific encoding ID. */ | 67 USHORT encodingID; /* Platform-specific encoding ID. */ |
67 USHORT languageID; /* Language ID. */ | 68 USHORT languageID; /* Language ID. */ |
68 USHORT nameID; /* Name ID. */ | 69 USHORT nameID; /* Name ID. */ |
69 USHORT length; /* String length (in bytes). */ | 70 USHORT length; /* String length (in bytes). */ |
(...skipping 24 matching lines...) Expand all Loading... |
94 return 0; | 95 return 0; |
95 | 96 |
96 unsigned int length = MIN (buffer_length, (unsigned int) match->length); | 97 unsigned int length = MIN (buffer_length, (unsigned int) match->length); |
97 memcpy (buffer, (char *) this + stringOffset + match->offset, length); | 98 memcpy (buffer, (char *) this + stringOffset + match->offset, length); |
98 return length; | 99 return length; |
99 } | 100 } |
100 | 101 |
101 inline unsigned int get_size (void) const | 102 inline unsigned int get_size (void) const |
102 { return min_size + count * nameRecord[0].min_size; } | 103 { return min_size + count * nameRecord[0].min_size; } |
103 | 104 |
104 inline bool sanitize_records (hb_sanitize_context_t *c) { | 105 inline bool sanitize_records (hb_sanitize_context_t *c) const { |
105 TRACE_SANITIZE (this); | 106 TRACE_SANITIZE (this); |
106 char *string_pool = (char *) this + stringOffset; | 107 char *string_pool = (char *) this + stringOffset; |
107 unsigned int _count = count; | 108 unsigned int _count = count; |
108 for (unsigned int i = 0; i < _count; i++) | 109 for (unsigned int i = 0; i < _count; i++) |
109 if (!nameRecord[i].sanitize (c, string_pool)) return TRACE_RETURN (false); | 110 if (!nameRecord[i].sanitize (c, string_pool)) return TRACE_RETURN (false); |
110 return TRACE_RETURN (true); | 111 return TRACE_RETURN (true); |
111 } | 112 } |
112 | 113 |
113 inline bool sanitize (hb_sanitize_context_t *c) { | 114 inline bool sanitize (hb_sanitize_context_t *c) const |
| 115 { |
114 TRACE_SANITIZE (this); | 116 TRACE_SANITIZE (this); |
115 return TRACE_RETURN (c->check_struct (this) && | 117 return TRACE_RETURN (c->check_struct (this) && |
116 likely (format == 0 || format == 1) && | 118 likely (format == 0 || format == 1) && |
117 c->check_array (nameRecord, nameRecord[0].static_size,
count) && | 119 c->check_array (nameRecord, nameRecord[0].static_size,
count) && |
118 sanitize_records (c)); | 120 sanitize_records (c)); |
119 } | 121 } |
120 | 122 |
121 /* We only implement format 0 for now. */ | 123 /* We only implement format 0 for now. */ |
122 USHORT format; /* Format selector (=0/1). */ | 124 USHORT format; /* Format selector (=0/1). */ |
123 USHORT count; /* Number of name records. */ | 125 USHORT count; /* Number of name records. */ |
124 Offset<> stringOffset; /* Offset to start of string storage (fr
om start of table). */ | 126 Offset<> stringOffset; /* Offset to start of string storage (fr
om start of table). */ |
125 NameRecord nameRecord[VAR]; /* The name records where count is the n
umber of records. */ | 127 NameRecord nameRecord[VAR]; /* The name records where count is the n
umber of records. */ |
126 public: | 128 public: |
127 DEFINE_SIZE_ARRAY (6, nameRecord); | 129 DEFINE_SIZE_ARRAY (6, nameRecord); |
128 }; | 130 }; |
129 | 131 |
130 | 132 |
131 } /* namespace OT */ | 133 } /* namespace OT */ |
132 | 134 |
133 | 135 |
134 #endif /* HB_OT_NAME_TABLE_HH */ | 136 #endif /* HB_OT_NAME_TABLE_HH */ |
OLD | NEW |