... |
... |
@@ -41,35 +41,36 @@ |
41
|
41
|
|
42
|
42
|
|
43
|
43
|
/*
|
44
|
|
- * A helper function to compute FD number (fd_select),
|
45
|
|
- * the offset to the head of the glyph data (off1),
|
46
|
|
- * and the offset to the and of the glyph data (off2).
|
|
44
|
+ * A helper function to compute FD number (`fd_select`), the offset to the
|
|
45
|
+ * head of the glyph data (`off1`), and the offset to the and of the glyph
|
|
46
|
+ * data (`off2`).
|
47
|
47
|
*
|
48
|
|
- * The number how many times cid_get_offset() is invoked
|
49
|
|
- * can be controlled by the number how many non-NULL
|
50
|
|
- * arguments are given. If fd_select is non-NULL but
|
51
|
|
- * off1 and off2 are NULL, cid_get_offset() is invoked
|
52
|
|
- * only for fd_select, off1/off2 are not validated.
|
|
48
|
+ * The number how many times `cid_get_offset` is invoked can be controlled
|
|
49
|
+ * by the number of non-NULL arguments. If `fd_select` is non-NULL but
|
|
50
|
+ * `off1` and `off2` are NULL, `cid_get_offset` is invoked only for
|
|
51
|
+ * `fd_select`; `off1` and `off2` are not validated.
|
53
|
52
|
*
|
54
|
53
|
*/
|
55
|
54
|
FT_LOCAL_DEF( FT_Error )
|
56
|
|
- cid_compute_fd_and_offsets( CID_Face face,
|
57
|
|
- FT_UInt glyph_index,
|
58
|
|
- FT_ULong* fd_select_p,
|
59
|
|
- FT_ULong* off1_p,
|
60
|
|
- FT_ULong* off2_p )
|
|
55
|
+ cid_compute_fd_and_offsets( CID_Face face,
|
|
56
|
+ FT_UInt glyph_index,
|
|
57
|
+ FT_ULong* fd_select_p,
|
|
58
|
+ FT_ULong* off1_p,
|
|
59
|
+ FT_ULong* off2_p )
|
61
|
60
|
{
|
62
|
|
- FT_Error error = FT_Err_Ok;
|
63
|
|
- CID_FaceInfo cid = &face->cid;
|
64
|
|
- FT_Stream stream = face->cid_stream;
|
|
61
|
+ FT_Error error = FT_Err_Ok;
|
|
62
|
+
|
|
63
|
+ CID_FaceInfo cid = &face->cid;
|
|
64
|
+ FT_Stream stream = face->cid_stream;
|
65
|
65
|
FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
|
66
|
|
- FT_Byte* p;
|
67
|
|
- FT_Bool need_frame_exit = 0;
|
68
|
|
- FT_ULong fd_select, off1, off2;
|
|
66
|
+
|
|
67
|
+ FT_Byte* p;
|
|
68
|
+ FT_Bool need_frame_exit = 0;
|
|
69
|
+ FT_ULong fd_select, off1, off2;
|
69
|
70
|
|
70
|
71
|
|
71
|
|
- /* For ordinary fonts read the CID font dictionary index */
|
72
|
|
- /* and charstring offset from the CIDMap. */
|
|
72
|
+ /* For ordinary fonts, read the CID font dictionary index */
|
|
73
|
+ /* and charstring offset from the CIDMap. */
|
73
|
74
|
|
74
|
75
|
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
|
75
|
76
|
glyph_index * entry_len ) ||
|
... |
... |
@@ -78,20 +79,18 @@ |
78
|
79
|
|
79
|
80
|
need_frame_exit = 1;
|
80
|
81
|
|
81
|
|
- p = (FT_Byte*)stream->cursor;
|
|
82
|
+ p = (FT_Byte*)stream->cursor;
|
82
|
83
|
fd_select = cid_get_offset( &p, cid->fd_bytes );
|
83
|
84
|
off1 = cid_get_offset( &p, cid->gd_bytes );
|
84
|
85
|
|
85
|
|
- p += cid->fd_bytes;
|
86
|
|
- off2 = cid_get_offset( &p, cid->gd_bytes );
|
|
86
|
+ p += cid->fd_bytes;
|
|
87
|
+ off2 = cid_get_offset( &p, cid->gd_bytes );
|
87
|
88
|
|
88
|
|
- if (fd_select_p)
|
|
89
|
+ if ( fd_select_p )
|
89
|
90
|
*fd_select_p = fd_select;
|
90
|
|
-
|
91
|
|
- if (off1_p)
|
|
91
|
+ if ( off1_p )
|
92
|
92
|
*off1_p = off1;
|
93
|
|
-
|
94
|
|
- if (off2_p)
|
|
93
|
+ if ( off2_p )
|
95
|
94
|
*off2_p = off2;
|
96
|
95
|
|
97
|
96
|
if ( fd_select >= cid->num_dicts )
|
... |
... |
@@ -101,36 +100,46 @@ |
101
|
100
|
* has no charstring to be rendered, similar to GID = 0xFFFF
|
102
|
101
|
* in TrueType fonts.
|
103
|
102
|
*/
|
104
|
|
- if ( (cid->fd_bytes == 1 && fd_select == 0xFFU ) ||
|
105
|
|
- (cid->fd_bytes == 2 && fd_select == 0xFFFFU ) )
|
|
103
|
+ if ( ( cid->fd_bytes == 1 && fd_select == 0xFFU ) ||
|
|
104
|
+ ( cid->fd_bytes == 2 && fd_select == 0xFFFFU ) )
|
106
|
105
|
{
|
107
|
|
- FT_TRACE1(( "cid_load_glyph: fail for glyph_index=%d, "
|
108
|
|
- "FD number %ld is the max integer fitting into %d byte%s\n",
|
109
|
|
- glyph_index, fd_select, cid->fd_bytes,
|
110
|
|
- cid->fd_bytes == 1 ? "" : "s" ));
|
|
106
|
+ FT_TRACE1(( "cid_load_glyph: fail for glyph index %d:\n",
|
|
107
|
+ glyph_index ));
|
|
108
|
+ FT_TRACE1(( " FD number %ld is the maximum\n",
|
|
109
|
+ fd_select ));
|
|
110
|
+ FT_TRACE1(( " integer fitting into %d byte%s\n",
|
|
111
|
+ cid->fd_bytes, cid->fd_bytes == 1 ? "" : "s" ));
|
111
|
112
|
}
|
112
|
113
|
else
|
113
|
114
|
{
|
114
|
|
- FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, "
|
115
|
|
- "FD number %ld > number of dicts %d\n",
|
116
|
|
- glyph_index, fd_select, cid->num_dicts ));
|
|
115
|
+ FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
|
|
116
|
+ glyph_index ));
|
|
117
|
+ FT_TRACE0(( " FD number %ld is larger\n",
|
|
118
|
+ fd_select ));
|
|
119
|
+ FT_TRACE0(( " than number of dictionaries (%d)\n",
|
|
120
|
+ cid->num_dicts ));
|
117
|
121
|
}
|
|
122
|
+
|
118
|
123
|
error = FT_THROW( Invalid_Offset );
|
119
|
124
|
goto Exit;
|
120
|
125
|
}
|
121
|
126
|
else if ( off2 > stream->size )
|
122
|
127
|
{
|
123
|
|
- FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, "
|
124
|
|
- "end of the glyph data is beyond the data stream\n",
|
|
128
|
+ FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
|
125
|
129
|
glyph_index ));
|
|
130
|
+ FT_TRACE0(( " end of the glyph data\n" ));
|
|
131
|
+ FT_TRACE0(( " is beyond the data stream\n" ));
|
|
132
|
+
|
126
|
133
|
error = FT_THROW( Invalid_Offset );
|
127
|
134
|
goto Exit;
|
128
|
135
|
}
|
129
|
136
|
else if ( off1 > off2 )
|
130
|
137
|
{
|
131
|
|
- FT_TRACE0(( "cid_load_glyph: fail for glyph_index=%d, "
|
132
|
|
- "the end position of glyph data is set before the start position\n",
|
|
138
|
+ FT_TRACE0(( "cid_load_glyph: fail for glyph index %d:\n",
|
133
|
139
|
glyph_index ));
|
|
140
|
+ FT_TRACE0(( " the end position of glyph data\n" ));
|
|
141
|
+ FT_TRACE0(( " is set before the start position\n" ));
|
|
142
|
+
|
134
|
143
|
error = FT_THROW( Invalid_Offset );
|
135
|
144
|
}
|
136
|
145
|
|