freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] patch: check bdf properties WEIGHT_NAME and SLANT case insen


From: Federic Zhang
Subject: Re: [Devel] patch: check bdf properties WEIGHT_NAME and SLANT case insensitively
Date: Wed, 27 Aug 2003 19:05:07 +0800
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.2.1) Gecko/20030507

Similiar problem occurs in the bdfdrivr.c and pcfdriver.c when check
whether the charset_registry is either "ISO10646" or "ISO8859", if the
string is lowercase, and the test will fail and charmap's encoding is
wrongly set to FT_ENCODING_NONE.

With the issue the fc-cache will fail to generate the fonts.cache-1
for the bdf/pcf.gz font that has lowercase charset_registry property.

-federic

Most bitmap fonts contain the bdf properties WEIGHT_NAME and SLANT
with an upper case first letter like this:

    WEIGHT_NAME "Bold"
    SLANT "I"

But there are quite a few which have these properties all in lower
case like this:

    WEIGHT_NAME "bold"
    SLANT "i"

As freetype checks only for upper case first letters, the weights andd
style of such fonts cannot be properly distinguished by fontconfig,
for example:

    address@hidden:~$ fc-list "etl fixed:foundry=etl:pixelsize=16" family style 
weight foundry file
    /usr/X11R6/lib/X11/fonts/misc/lt1-16b-etl.pcf.gz: ETL 
fixed:style=Regular:weight=100:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16bi-etl.pcf.gz: ETL 
fixed:style=Regular:weight=100:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16-etl.pcf.gz: ETL 
Fixed:style=Regular:weight=100:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16i-etl.pcf.gz: ETL 
fixed:style=Regular:weight=100:foundry=ETL
address@hidden:~$
All fonts above are listed with "style=Regular:weight=100", i.e. they
are identical as far as fontconfig is concerned and when trying to
select such a font one gets a rather random result.

It is probably better if freetype checked this case insensitively.
The attached patch does this and after applying the patch and calling
'fc-cache' the same fc-list command returns:

    address@hidden:~$ fc-list "etl fixed:foundry=etl:pixelsize=16" family style 
weight foundry file
    /usr/X11R6/lib/X11/fonts/misc/lt1-16i-etl.pcf.gz: ETL 
fixed:style=Italic:weight=100:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16-etl.pcf.gz: ETL 
Fixed:style=Regular:weight=100:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16b-etl.pcf.gz: ETL 
fixed:style=Bold:weight=200:foundry=ETL
    /usr/X11R6/lib/X11/fonts/misc/lt1-16bi-etl.pcf.gz: ETL fixed:style=Bold 
Italic:weight=200:foundry=ETL
address@hidden:~$
which is more useful.



------------------------------------------------------------------------

diff -ru freetype-2.1.4.orig/src/bdf/bdfdrivr.c 
freetype-2.1.4/src/bdf/bdfdrivr.c
--- freetype-2.1.4.orig/src/bdf/bdfdrivr.c      2003-03-20 08:04:40.000000000 
+0100
+++ freetype-2.1.4/src/bdf/bdfdrivr.c   2003-08-26 18:07:50.000000000 +0200
@@ -266,15 +266,18 @@
       if ( prop != NULL )
         if ( prop->format == BDF_ATOM )
           if ( prop->value.atom != NULL )
-            if ( ( *(prop->value.atom) == 'O' ) ||
-                 ( *(prop->value.atom) == 'I' ) )
+            if ( ( *(prop->value.atom) == 'O' ) ||
+                 ( *(prop->value.atom) == 'o' ) ||
+                 ( *(prop->value.atom) == 'I' ) ||
+                 ( *(prop->value.atom) == 'i' ) )
               root->style_flags |= FT_STYLE_FLAG_ITALIC;
prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
       if ( prop != NULL )
         if ( prop->format == BDF_ATOM )
           if ( prop->value.atom != NULL )
-            if ( *(prop->value.atom) == 'B' )
+            if ( ( *(prop->value.atom) == 'B' ) ||
+                 ( *(prop->value.atom) == 'b' ) )
               root->style_flags |= FT_STYLE_FLAG_BOLD;
prop = bdf_get_font_property( font, (char *)"FAMILY_NAME" );
diff -ru freetype-2.1.4.orig/src/pcf/pcfread.c freetype-2.1.4/src/pcf/pcfread.c
--- freetype-2.1.4.orig/src/pcf/pcfread.c       2003-01-22 23:45:28.000000000 
+0100
+++ freetype-2.1.4/src/pcf/pcfread.c    2003-08-26 18:05:10.000000000 +0200
@@ -931,13 +931,16 @@
       if ( prop != NULL )
         if ( prop->isString )
           if ( ( *(prop->value.atom) == 'O' ) ||
-               ( *(prop->value.atom) == 'I' ) )
+               ( *(prop->value.atom) == 'o' ) ||
+               ( *(prop->value.atom) == 'I' ) ||
+               ( *(prop->value.atom) == 'i' ) )
             root->style_flags |= FT_STYLE_FLAG_ITALIC;
prop = pcf_find_property( face, "WEIGHT_NAME" );
       if ( prop != NULL )
         if ( prop->isString )
-          if ( *(prop->value.atom) == 'B' )
+          if ( ( *(prop->value.atom) == 'B' ) ||
+               ( *(prop->value.atom) == 'b' ) )
             root->style_flags |= FT_STYLE_FLAG_BOLD;
root->style_name = (char *)"Regular";


------------------------------------------------------------------------




--





reply via email to

[Prev in Thread] Current Thread [Next in Thread]