[pcf] Enrich family name with foundry name and glyph width info.

This is a very old patch from openSuSE (from 2006, submitted to
FreeType in 2011) that I forgot to apply.

  https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch

Prepend the foundry name plus a space to the family name.  There are
many fonts just called `Fixed' which look completely different, and
which have nothing to do with each other.  When selecting `Fixed' in
KDE or Gnome one gets results that appear rather random, the style
changes often if one changes the size and one cannot select some
fonts at all.

We also check whether we have `wide' characters; all put together,
we get family names like `Sony Fixed' or `Misc Fixed Wide'.

* src/pcf/pcfread.c (pcf_load_font): Implement it.

* docs/CHANGES: Document it.
This commit is contained in:
Werner Lemberg 2016-09-30 08:11:52 +02:00
parent 71b617d8b7
commit 3576487add
3 changed files with 80 additions and 2 deletions

View File

@ -1,3 +1,26 @@
2016-09-29 Werner Lemberg <wl@gnu.org>
[pcf] Enrich family name with foundry name and glyph width info.
This is a very old patch from openSuSE (from 2006, submitted to
FreeType in 2011) that I forgot to apply.
https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch
Prepend the foundry name plus a space to the family name. There are
many fonts just called `Fixed' which look completely different, and
which have nothing to do with each other. When selecting `Fixed' in
KDE or Gnome one gets results that appear rather random, the style
changes often if one changes the size and one cannot select some
fonts at all.
We also check whether we have `wide' characters; all put together,
we get family names like `Sony Fixed' or `Misc Fixed Wide'.
* src/pcf/pcfread.c (pcf_load_font): Implement it.
* docs/CHANGES: Document it.
2016-09-29 Werner Lemberg <wl@gnu.org>
[ftfuzzer] Speed up.

View File

@ -24,6 +24,12 @@ CHANGES BETWEEN 2.7 and 2.7.1
and the number of CVT entries. Please report if you encounter a
font where the selected values are not adequate.
- PCF family names are made more `colourful'; they now include the
foundry and information whether they contain wide characters.
For example, you no longer get `Fixed' but rather `Sony Fixed'
or `Misc Fixed Wide'.
======================================================================
CHANGES BETWEEN 2.6.5 and 2.7

View File

@ -1266,8 +1266,57 @@ THE SOFTWARE.
prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop && prop->isString )
{
if ( FT_STRDUP( root->family_name, prop->value.atom ) )
goto Exit;
/* Prepend the foundry name plus a space to the family name. */
/* There are many fonts just called `Fixed' which look completely */
/* different, and which have nothing to do with each other. When */
/* selecting `Fixed' in KDE or Gnome one gets results that appear */
/* rather random, the style changes often if one changes the size */
/* and one cannot select some fonts at all. */
/* */
/* We also check whether we have `wide' characters; all put */
/* together, we get family names like `Sony Fixed' or `Misc Fixed */
/* Wide'. */
PCF_Property foundry_prop, point_size_prop, average_width_prop;
int l = ft_strlen( prop->value.atom ) + 1;
int wide = 0;
foundry_prop = pcf_find_property( face, "FOUNDRY" );
point_size_prop = pcf_find_property( face, "POINT_SIZE" );
average_width_prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( point_size_prop && average_width_prop )
{
if ( average_width_prop->value.l >= point_size_prop->value.l )
{
/* This font is at least square shaped or even wider */
wide = 1;
l += ft_strlen( " Wide" );
}
}
if ( foundry_prop && foundry_prop->isString )
{
l += ft_strlen( foundry_prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, foundry_prop->value.atom );
ft_strcat( root->family_name, " " );
ft_strcat( root->family_name, prop->value.atom );
}
else
{
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
}
if ( wide )
ft_strcat( root->family_name, " Wide" );
}
else
root->family_name = NULL;