Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-ot-name-table.hh

Issue 9223010: Update harfbuzz-ng to 1a5a91dc0d8bf4b72a2f22dc6300b06ad7000b79. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't use -M option for 'git diff' to patch correctly Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright © 2011 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
27 #ifndef HB_OT_NAME_TABLE_HH
28 #define HB_OT_NAME_TABLE_HH
29
30 #include "hb-open-type-private.hh"
31
32
33
34 /*
35 * name -- The Naming Table
36 */
37
38 #define HB_OT_TAG_name HB_TAG('n','a','m','e')
39
40
41 struct NameRecord
42 {
43 static int cmp (const NameRecord *a, const NameRecord *b)
44 {
45 int ret;
46 ret = b->platformID.cmp (a->platformID);
47 if (ret) return ret;
48 ret = b->encodingID.cmp (a->encodingID);
49 if (ret) return ret;
50 ret = b->languageID.cmp (a->languageID);
51 if (ret) return ret;
52 ret = b->nameID.cmp (a->nameID);
53 if (ret) return ret;
54 return 0;
55 }
56
57 inline bool sanitize (hb_sanitize_context_t *c, void *base) {
58 TRACE_SANITIZE ();
59 /* We can check from base all the way up to the end of string... */
60 return c->check_struct (this) &&
61 c->check_range ((char *) base, (unsigned int) length + offset);
62 }
63
64 USHORT platformID; /* Platform ID. */
65 USHORT encodingID; /* Platform-specific encoding ID. */
66 USHORT languageID; /* Language ID. */
67 USHORT nameID; /* Name ID. */
68 USHORT length; /* String length (in bytes). */
69 USHORT offset; /* String offset from start of storage area (in bytes). */
70 public:
71 DEFINE_SIZE_STATIC (12);
72 };
73
74 struct name
75 {
76 static const hb_tag_t Tag = HB_OT_TAG_name;
77
78 inline unsigned int get_name (unsigned int platform_id,
79 unsigned int encoding_id,
80 unsigned int language_id,
81 unsigned int name_id,
82 void *buffer,
83 unsigned int buffer_length) const
84 {
85 NameRecord key;
86 key.platformID.set (platform_id);
87 key.encodingID.set (encoding_id);
88 key.languageID.set (language_id);
89 key.nameID.set (name_id);
90 NameRecord *match = (NameRecord *) bsearch (&key, nameRecord, count, sizeof (nameRecord[0]), (hb_compare_func_t) NameRecord::cmp);
91
92 if (!match)
93 return 0;
94
95 unsigned int length = MIN (buffer_length, (unsigned int) match->length);
96 memcpy (buffer, (char *) this + stringOffset + match->offset, length);
97 return length;
98 }
99
100 inline bool sanitize_records (hb_sanitize_context_t *c) {
101 TRACE_SANITIZE ();
102 char *string_pool = (char *) this + stringOffset;
103 unsigned int _count = count;
104 for (unsigned int i = 0; i < _count; i++)
105 if (!nameRecord[i].sanitize (c, string_pool)) return false;
106 return true;
107 }
108
109 inline bool sanitize (hb_sanitize_context_t *c) {
110 TRACE_SANITIZE ();
111 return c->check_struct (this) &&
112 likely (format == 0 || format == 1) &&
113 c->check_array (nameRecord, nameRecord[0].static_size, count) &&
114 sanitize_records (c);
115 }
116
117 /* We only implement format 0 for now. */
118 private:
119 USHORT format; /* Format selector (=0/1). */
120 USHORT count; /* Number of name records. */
121 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. */
123 public:
124 DEFINE_SIZE_ARRAY (6, nameRecord);
125 };
126
127
128
129 #endif /* HB_OT_NAME_TABLE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-maxp-table.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-shape.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698