... |
... |
@@ -104,26 +104,17 @@ THE SOFTWARE. |
104
|
104
|
pcf_cmap_char_index( FT_CMap pcfcmap, /* PCF_CMap */
|
105
|
105
|
FT_UInt32 charcode )
|
106
|
106
|
{
|
107
|
|
- PCF_CMap cmap = (PCF_CMap)pcfcmap;
|
108
|
|
- PCF_Enc enc = cmap->enc;
|
109
|
|
- FT_UShort charcodeRow;
|
110
|
|
- FT_UShort charcodeCol;
|
|
107
|
+ PCF_Enc enc = ( (PCF_CMap)pcfcmap )->enc;
|
|
108
|
+ FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
|
|
109
|
+ FT_UInt32 j = ( charcode & 0xFF ) - enc->firstCol;
|
|
110
|
+ FT_UInt32 h = enc->lastRow - enc->firstRow + 1;
|
|
111
|
+ FT_UInt32 w = enc->lastCol - enc->firstCol + 1;
|
111
|
112
|
|
112
|
113
|
|
113
|
|
- if ( charcode > (FT_UInt32)( enc->lastRow * 256 + enc->lastCol ) ||
|
114
|
|
- charcode < (FT_UInt32)( enc->firstRow * 256 + enc->firstCol ) )
|
|
114
|
+ if ( i >= h || j >= w )
|
115
|
115
|
return 0;
|
116
|
116
|
|
117
|
|
- charcodeRow = (FT_UShort)( charcode >> 8 );
|
118
|
|
- charcodeCol = (FT_UShort)( charcode & 0xFF );
|
119
|
|
-
|
120
|
|
- if ( charcodeCol < enc->firstCol ||
|
121
|
|
- charcodeCol > enc->lastCol )
|
122
|
|
- return 0;
|
123
|
|
-
|
124
|
|
- return (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) *
|
125
|
|
- ( enc->lastCol - enc->firstCol + 1 ) +
|
126
|
|
- charcodeCol - enc->firstCol];
|
|
117
|
+ return (FT_UInt)enc->offset[i * w + j];
|
127
|
118
|
}
|
128
|
119
|
|
129
|
120
|
|
... |
... |
@@ -131,42 +122,30 @@ THE SOFTWARE. |
131
|
122
|
pcf_cmap_char_next( FT_CMap pcfcmap, /* PCF_CMap */
|
132
|
123
|
FT_UInt32 *acharcode )
|
133
|
124
|
{
|
134
|
|
- PCF_CMap cmap = (PCF_CMap)pcfcmap;
|
135
|
|
- PCF_Enc enc = cmap->enc;
|
136
|
|
- FT_UInt32 charcode = *acharcode;
|
137
|
|
- FT_UShort charcodeRow;
|
138
|
|
- FT_UShort charcodeCol;
|
|
125
|
+ PCF_Enc enc = ( (PCF_CMap)pcfcmap )->enc;
|
|
126
|
+ FT_UInt32 charcode = *acharcode + 1;
|
|
127
|
+ FT_UInt32 i = ( charcode >> 8 ) - enc->firstRow;
|
|
128
|
+ FT_UInt32 j = ( charcode & 0xFF ) - enc->firstCol;
|
|
129
|
+ FT_UInt32 h = enc->lastRow - enc->firstRow + 1;
|
|
130
|
+ FT_UInt32 w = enc->lastCol - enc->firstCol + 1;
|
139
|
131
|
FT_UInt result = 0;
|
140
|
132
|
|
141
|
133
|
|
142
|
|
- while ( charcode < (FT_UInt32)( enc->lastRow * 256 + enc->lastCol ) )
|
143
|
|
- {
|
144
|
|
- charcode++;
|
145
|
|
-
|
146
|
|
- if ( charcode < (FT_UInt32)( enc->firstRow * 256 + enc->firstCol ) )
|
147
|
|
- charcode = (FT_UInt32)( enc->firstRow * 256 + enc->firstCol );
|
148
|
|
-
|
149
|
|
- charcodeRow = (FT_UShort)( charcode >> 8 );
|
150
|
|
- charcodeCol = (FT_UShort)( charcode & 0xFF );
|
|
134
|
+ if ( (FT_Int32)i < 0 )
|
|
135
|
+ i = 0;
|
|
136
|
+ if ( (FT_Int32)j < 0 )
|
|
137
|
+ j = 0;
|
151
|
138
|
|
152
|
|
- if ( charcodeCol < enc->firstCol )
|
153
|
|
- charcodeCol = enc->firstCol;
|
154
|
|
- else if ( charcodeCol > enc->lastCol )
|
|
139
|
+ for ( ; i < h; i++, j = 0 )
|
|
140
|
+ for ( ; j < w; j++ )
|
155
|
141
|
{
|
156
|
|
- charcodeRow++;
|
157
|
|
- charcodeCol = enc->firstCol;
|
|
142
|
+ result = (FT_UInt)enc->offset[i * w + j];
|
|
143
|
+ if ( result != 0xFFFFU )
|
|
144
|
+ goto Exit;
|
158
|
145
|
}
|
159
|
146
|
|
160
|
|
- charcode = (FT_UInt32)( charcodeRow * 256 + charcodeCol );
|
161
|
|
-
|
162
|
|
- result = (FT_UInt)enc->offset[( charcodeRow - enc->firstRow ) *
|
163
|
|
- ( enc->lastCol - enc->firstCol + 1 ) +
|
164
|
|
- charcodeCol - enc->firstCol];
|
165
|
|
- if ( result != 0xFFFFU )
|
166
|
|
- break;
|
167
|
|
- }
|
168
|
|
-
|
169
|
|
- *acharcode = charcode;
|
|
147
|
+ Exit:
|
|
148
|
+ *acharcode = ( ( i + enc->firstRow ) << 8 ) | ( j + enc->firstCol );
|
170
|
149
|
|
171
|
150
|
return result;
|
172
|
151
|
}
|