[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] Parsing problem in t1load.c
From: |
Ben Capper |
Subject: |
[Devel] Parsing problem in t1load.c |
Date: |
Wed, 26 Mar 2003 12:16:13 +1100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020607 |
Hi there all,
I'm new to this list so please correct me if I'm going about this the
wrong way.
I've discovered a smallish problem with t1load.c. The parser seems to
assume that all PostScript names are alphanumeric, which is not true.
PostScript names are allowed to contain any character that is not
whitespace, or one of the PostScript delimiters.
We came across this when dealing with some auto generated type 1 fonts
which contained glyphs with ~ in their names. When the parser encounters
these names if prematurely thinks it has reached the end of the name,
and understandingly chokes soon after.
I've attached a patch against the 2.1.4rc2 version of t1load.c which
replaces the static test function is_alnum with something more
comprehensive. Is this appropriate?
Cheers,
-> Ben
PS Thanks very much for the hard work. We are very happy with FreeType
over here.
Benjamin Capper
-------
Software Engineer - Research and Development
Toshiba (Australia) Pty Ltd
address@hidden
-------
Note: I do not speak for Toshiba.
Patch Follows....
--- /home/bcapper/tmp/freetype-2.1.4rc2/src/type1/t1load.c Tue Dec 17
08:51:24 2002
+++ t1load.c Wed Mar 26 10:57:31 2003
@@ -779,16 +779,24 @@
static int
- is_alpha( FT_Byte c )
+ is_name_char( FT_Byte c )
{
- /* Note: we must accept "+" as a valid character, as it is used in */
- /* embedded type1 fonts in PDF documents. */
- /* */
- return ( ft_isalnum( c ) ||
- c == '.' ||
- c == '_' ||
- c == '-' ||
- c == '+' );
+ /* Note: PostScript allows any non-delimiting, non-whitespace */
+ /* in a name (PS Ref Manual, 3rd Ed, p31) */
+ /* PostScript delimiters include (,),<,>,[,],{,},/ and % */
+
+ return ( ! ( c == '(' ||
+ c == ')' ||
+ c == '<' ||
+ c == '>' ||
+ c == '[' ||
+ c == ']' ||
+ c == '{' ||
+ c == '}' ||
+ c == '/' ||
+ c == '%' ||
+ is_space( c ) )
+ );
}
@@ -861,7 +869,7 @@
cur++;
cur2 = cur;
- while ( cur2 < limit && is_alpha( *cur2 ) )
+ while ( cur2 < limit && is_name_char( *cur2 ) )
cur2++;
len = cur2 - cur;
@@ -1070,7 +1078,7 @@
FT_PtrDist len;
- while ( cur2 < limit && is_alpha( *cur2 ) )
+ while ( cur2 < limit && is_name_char( *cur2 ) )
cur2++;
len = cur2 - cur - 1;
@@ -1312,7 +1320,7 @@
FT_PtrDist len;
- while ( cur2 < limit && is_alpha( *cur2 ) )
+ while ( cur2 < limit && is_name_char( *cur2 ) )
cur2++;
len = cur2 - cur - 1;
@@ -1572,7 +1580,7 @@
cur++;
cur2 = cur;
- while ( cur2 < limit && is_alpha( *cur2 ) )
+ while ( cur2 < limit && is_name_char( *cur2 ) )
cur2++;
len = cur2 - cur;
#####################################################################################
Note:
This message is for the named person's use only. It may contain confidential,
proprietary or legally privileged information. No confidentiality or privilege
is waived or lost by any mis-transmission. If you receive this message in
error,
please immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender. You must not, directly or indirectly,
use, disclose, distribute, print, or copy any part of this message if you are
not
the intended recipient. Toshiba Australia reserves the right to monitor all
e-mail communications through its networks.
Thank You.
#####################################################################################
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Devel] Parsing problem in t1load.c,
Ben Capper <=