OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2011 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. |
11 * | 11 * |
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ret = b->languageID.cmp (a->languageID); | 50 ret = b->languageID.cmp (a->languageID); |
51 if (ret) return ret; | 51 if (ret) return ret; |
52 ret = b->nameID.cmp (a->nameID); | 52 ret = b->nameID.cmp (a->nameID); |
53 if (ret) return ret; | 53 if (ret) return ret; |
54 return 0; | 54 return 0; |
55 } | 55 } |
56 | 56 |
57 inline bool sanitize (hb_sanitize_context_t *c, void *base) { | 57 inline bool sanitize (hb_sanitize_context_t *c, void *base) { |
58 TRACE_SANITIZE (); | 58 TRACE_SANITIZE (); |
59 /* We can check from base all the way up to the end of string... */ | 59 /* We can check from base all the way up to the end of string... */ |
60 return c->check_struct (this) && | 60 return TRACE_RETURN (c->check_struct (this) && c->check_range ((char *) base
, (unsigned int) length + offset)); |
61 » c->check_range ((char *) base, (unsigned int) length + offset); | |
62 } | 61 } |
63 | 62 |
64 USHORT platformID; /* Platform ID. */ | 63 USHORT platformID; /* Platform ID. */ |
65 USHORT encodingID; /* Platform-specific encoding ID. */ | 64 USHORT encodingID; /* Platform-specific encoding ID. */ |
66 USHORT languageID; /* Language ID. */ | 65 USHORT languageID; /* Language ID. */ |
67 USHORT nameID; /* Name ID. */ | 66 USHORT nameID; /* Name ID. */ |
68 USHORT length; /* String length (in bytes). */ | 67 USHORT length; /* String length (in bytes). */ |
69 USHORT offset; /* String offset from start of storage area (in
bytes). */ | 68 USHORT offset; /* String offset from start of storage area (in
bytes). */ |
70 public: | 69 public: |
71 DEFINE_SIZE_STATIC (12); | 70 DEFINE_SIZE_STATIC (12); |
(...skipping 23 matching lines...) Expand all Loading... |
95 unsigned int length = MIN (buffer_length, (unsigned int) match->length); | 94 unsigned int length = MIN (buffer_length, (unsigned int) match->length); |
96 memcpy (buffer, (char *) this + stringOffset + match->offset, length); | 95 memcpy (buffer, (char *) this + stringOffset + match->offset, length); |
97 return length; | 96 return length; |
98 } | 97 } |
99 | 98 |
100 inline bool sanitize_records (hb_sanitize_context_t *c) { | 99 inline bool sanitize_records (hb_sanitize_context_t *c) { |
101 TRACE_SANITIZE (); | 100 TRACE_SANITIZE (); |
102 char *string_pool = (char *) this + stringOffset; | 101 char *string_pool = (char *) this + stringOffset; |
103 unsigned int _count = count; | 102 unsigned int _count = count; |
104 for (unsigned int i = 0; i < _count; i++) | 103 for (unsigned int i = 0; i < _count; i++) |
105 if (!nameRecord[i].sanitize (c, string_pool)) return false; | 104 if (!nameRecord[i].sanitize (c, string_pool)) return TRACE_RETURN (false); |
106 return true; | 105 return TRACE_RETURN (true); |
107 } | 106 } |
108 | 107 |
109 inline bool sanitize (hb_sanitize_context_t *c) { | 108 inline bool sanitize (hb_sanitize_context_t *c) { |
110 TRACE_SANITIZE (); | 109 TRACE_SANITIZE (); |
111 return c->check_struct (this) && | 110 return TRACE_RETURN (c->check_struct (this) && |
112 » likely (format == 0 || format == 1) && | 111 » » » likely (format == 0 || format == 1) && |
113 » c->check_array (nameRecord, nameRecord[0].static_size, count) && | 112 » » » c->check_array (nameRecord, nameRecord[0].static_size,
count) && |
114 » sanitize_records (c); | 113 » » » sanitize_records (c)); |
115 } | 114 } |
116 | 115 |
117 /* We only implement format 0 for now. */ | 116 /* We only implement format 0 for now. */ |
118 private: | 117 private: |
119 USHORT format; /* Format selector (=0/1). */ | 118 USHORT format; /* Format selector (=0/1). */ |
120 USHORT count; /* Number of name records. */ | 119 USHORT count; /* Number of name records. */ |
121 Offset stringOffset; /* Offset to start of string storage (fr
om start of table). */ | 120 Offset stringOffset; /* Offset to start of string storage (fr
om start of table). */ |
122 NameRecord nameRecord[VAR]; /* The name records where count is the n
umber of records. */ | 121 NameRecord nameRecord[VAR]; /* The name records where count is the n
umber of records. */ |
123 public: | 122 public: |
124 DEFINE_SIZE_ARRAY (6, nameRecord); | 123 DEFINE_SIZE_ARRAY (6, nameRecord); |
125 }; | 124 }; |
126 | 125 |
127 | 126 |
128 | 127 |
129 #endif /* HB_OT_NAME_TABLE_HH */ | 128 #endif /* HB_OT_NAME_TABLE_HH */ |
OLD | NEW |