* include/freetype/internal/psaux.h (PS_Parser_FuncsRec): New member function `to_bytes'. * src/psaux/psauxmod.c (ps_parser_funcs): New member `ps_parser_to_bytes'. (psaux_module_class): Increase version to 0x20000L. * src/psaux/psobjs.c (IS_T1_LINESPACE): Add \f. (IS_T1_NULLSPACE): New macro. (IS_T1_SPACE): Add it. (skip_spaces, skip_alpha): New functions. (ps_parser_skip_spaces, ps_parser_skip_alpha): Use them. (ps_tobytes, ps_parser_to_bytes): New functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
diff --git a/ChangeLog b/ChangeLog
index 56e393a..4dcb854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-07-23 YAMANO-UCHI Hidetoshi <mer@din.or.jp>
+
+ * include/freetype/internal/psaux.h (PS_Parser_FuncsRec): New
+ member function `to_bytes'.
+
+ * src/psaux/psauxmod.c (ps_parser_funcs): New member
+ `ps_parser_to_bytes'.
+ (psaux_module_class): Increase version to 0x20000L.
+
+ * src/psaux/psobjs.c (IS_T1_LINESPACE): Add \f.
+ (IS_T1_NULLSPACE): New macro.
+ (IS_T1_SPACE): Add it.
+ (skip_spaces, skip_alpha): New functions.
+ (ps_parser_skip_spaces, ps_parser_skip_alpha): Use them.
+ (ps_tobytes, ps_parser_to_bytes): New functions.
+
2003-07-07 Werner Lemberg <wl@gnu.org>
* builds/freetype.mk (DOC_DIR): New variable.
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 1e5b7f2..71e0331 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -352,6 +352,12 @@ FT_BEGIN_HEADER
FT_Fixed
(*to_fixed)( PS_Parser parser,
FT_Int power_ten );
+ FT_Error
+ (*to_bytes)( PS_Parser parser,
+ FT_Byte* bytes,
+ FT_Int max_bytes,
+ FT_Int* pnum_bytes );
+
FT_Int
(*to_coord_array)( PS_Parser parser,
FT_Int max_coords,
diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c
index fa0c4aa..d602417 100644
--- a/src/psaux/psauxmod.c
+++ b/src/psaux/psauxmod.c
@@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript module implementation (body). */
/* */
-/* Copyright 2000-2001, 2002 by */
+/* Copyright 2000-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,6 +42,7 @@
ps_parser_skip_alpha,
ps_parser_to_int,
ps_parser_to_fixed,
+ ps_parser_to_bytes,
ps_parser_to_coord_array,
ps_parser_to_fixed_array,
ps_parser_to_token,
@@ -104,7 +105,7 @@
0,
sizeof( FT_ModuleRec ),
"psaux",
- 0x10000L,
+ 0x20000L,
0x20000L,
&psaux_interface, /* module-specific interface */
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 09bfb47..c88e3e4 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -266,18 +266,24 @@
/*************************************************************************/
/*************************************************************************/
-
+ /* In the PostScript Language Reference Manual (PLRM) the following */
+ /* characters are called `white-space characters'. */
#define IS_T1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' )
-#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' )
+#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' || (c) == '\f' )
+#define IS_T1_NULLSPACE( c ) ( (c) == '\0' )
-#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || IS_T1_LINESPACE( c ) )
+ /* According to the PLRM all white-space characters are equivalent, */
+ /* except in comments and strings. */
+#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || \
+ IS_T1_LINESPACE( c ) || \
+ IS_T1_NULLSPACE( c ) )
- FT_LOCAL_DEF( void )
- ps_parser_skip_spaces( PS_Parser parser )
+ static void
+ skip_spaces( FT_Byte** acur,
+ FT_Byte* limit )
{
- FT_Byte* cur = parser->cursor;
- FT_Byte* limit = parser->limit;
+ FT_Byte* cur = *acur;
while ( cur < limit )
@@ -289,15 +295,16 @@
break;
cur++;
}
- parser->cursor = cur;
+
+ *acur = cur;
}
- FT_LOCAL_DEF( void )
- ps_parser_skip_alpha( PS_Parser parser )
+ static void
+ skip_alpha( FT_Byte** acur,
+ FT_Byte* limit )
{
- FT_Byte* cur = parser->cursor;
- FT_Byte* limit = parser->limit;
+ FT_Byte* cur = *acur;
while ( cur < limit )
@@ -309,7 +316,22 @@
break;
cur++;
}
- parser->cursor = cur;
+
+ *acur = cur;
+ }
+
+
+ FT_LOCAL_DEF( void )
+ ps_parser_skip_spaces( PS_Parser parser )
+ {
+ skip_spaces( &parser->cursor, parser->limit );
+ }
+
+
+ FT_LOCAL_DEF( void )
+ ps_parser_skip_alpha( PS_Parser parser )
+ {
+ skip_alpha( &parser->cursor, parser->limit );
}
@@ -531,6 +553,69 @@
}
+ /* <...>: hexadecimal string */
+ static FT_Error
+ ps_tobytes( FT_Byte** cursor,
+ FT_Byte* limit,
+ FT_Int max_bytes,
+ FT_Byte* bytes,
+ FT_Int* pnum_bytes )
+ {
+ FT_Error error = PSaux_Err_Ok;
+
+ FT_Byte* cur = *cursor;
+ FT_Int n = 0;
+ FT_Byte b;
+
+
+ skip_spaces( &cur, limit );
+
+ if ( *cur != '<' )
+ {
+ error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ cur++;
+
+ for ( ; cur < limit; n++ )
+ {
+ FT_Byte* cur2 = cur;
+
+
+ if ( n + 1 > max_bytes * 2 )
+ goto Exit;
+
+ /* All white-space charcters are ignored. */
+ skip_spaces( &cur, limit );
+
+ b = T1Radix( 16, &cur, cur + 1 );
+
+ if ( cur == cur2 )
+ break;
+
+ /* <f> == <f0> != <0f> */
+ bytes[n / 2] = ( n % 2 ) ? bytes[n / 2] + b
+ : b * 16;
+ }
+
+ skip_spaces( &cur, limit );
+
+ if ( *cur != '>' )
+ {
+ error = PSaux_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ *cursor = ++cur;
+
+ Exit:
+ *pnum_bytes = ( n + 1 ) / 2;
+
+ return error;
+ }
+
+
static FT_Long
t1_tofixed( FT_Byte** cursor,
FT_Byte* limit,
@@ -1171,6 +1256,20 @@
}
+ FT_LOCAL_DEF( FT_Error )
+ ps_parser_to_bytes( PS_Parser parser,
+ FT_Byte* bytes,
+ FT_Int max_bytes,
+ FT_Int* pnum_bytes )
+ {
+ return ps_tobytes( &parser->cursor,
+ parser->limit,
+ max_bytes,
+ bytes,
+ pnum_bytes );
+ }
+
+
FT_LOCAL_DEF( FT_Fixed )
ps_parser_to_fixed( PS_Parser parser,
FT_Int power_ten )