* include/freetype/ftxf86.h, src/base/ftxf86.c: added a new API named

FT_Get_X11_Font_Format to return an X11-compatible string describing the
    font format of a given face. This was put in a new optional base source
    file, corresponding to a new public header (named FT_XFREE86_H since
    this function should only be used within the XFree86 font server IMO).

    * include/freetype/config/ftheader.h: adding FT_XFREE86_H, though it's
    not documented yet.

    * include/freetype/t1tables.h, src/base/fttype1.c: adding two new APIs
    named "FT_Get_PS_Font_Info" and "FT_Has_PS_Glyph_Names". This required
    a new optional source in 'src/base' named "fttype1.c"

    * src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: updating
    build control files for the new files "ftxf86.c" and "fttype1.c" in
    src/base
This commit is contained in:
David Turner 2002-05-28 22:07:49 +00:00
parent 2f2390cb1b
commit 2a4fa1340e
9 changed files with 246 additions and 5 deletions

View File

@ -1,5 +1,22 @@
2005-05-28 David Turner <david@freetype.org> 2005-05-28 David Turner <david@freetype.org>
* include/freetype/ftxf86.h, src/base/ftxf86.c: added a new API named
FT_Get_X11_Font_Format to return an X11-compatible string describing the
font format of a given face. This was put in a new optional base source
file, corresponding to a new public header (named FT_XFREE86_H since
this function should only be used within the XFree86 font server IMO).
* include/freetype/config/ftheader.h: adding FT_XFREE86_H, though it's
not documented yet.
* include/freetype/t1tables.h, src/base/fttype1.c: adding two new APIs
named "FT_Get_PS_Font_Info" and "FT_Has_PS_Glyph_Names". This required
a new optional source in 'src/base' named "fttype1.c"
* src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: updating
build control files for the new files "ftxf86.c" and "fttype1.c" in
src/base
* src/pshinter/pshglob.c (psh_blues_scale_zones): fixed a bug that * src/pshinter/pshglob.c (psh_blues_scale_zones): fixed a bug that
prevented family blue zones substitution from hapenning correctly prevented family blue zones substitution from hapenning correctly

View File

@ -496,6 +496,8 @@
#define FT_CACHE_INTERNAL_GLYPH_H <freetype/cache/ftcglyph.h> #define FT_CACHE_INTERNAL_GLYPH_H <freetype/cache/ftcglyph.h>
#define FT_CACHE_INTERNAL_CACHE_H <freetype/cache/ftccache.h> #define FT_CACHE_INTERNAL_CACHE_H <freetype/cache/ftccache.h>
#define FT_XFREE86_H <freetype/ftxf86.h>
/* now include internal headers definitions from <freetype/internal/...> */ /* now include internal headers definitions from <freetype/internal/...> */
#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> #define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>

35
include/freetype/ftxf86.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef __FT_XFREE86_H__
#define __FT_XFREE86_H__
#include <ft2build.h>
#include FT_FREETYPE_H
FT_BEGIN_HEADER
/* this comment is intentionally disabled for now, to prevent this */
/* function from appearing in the API Reference. */
/*@***********************************************************************/
/* */
/* <Function> */
/* FT_Get_X11_Font_Format */
/* */
/* <Description> */
/* Returns a string describing the format of a given face as a X11 */
/* FONT_PROPERTY. It should only be used by FreeType 2 font backend */
/* of the XFree86 font server. */
/* */
/* <Input> */
/* face :: input face handle. */
/* */
/* <Return> */
/* font format string. NULL in case of error. */
/* */
FT_EXPORT_DEF( const char* )
FT_Get_X11_Font_Format( FT_Face face );
/* */
FT_END_HEADER
#endif /* __FT_XFREE86_H__ */

View File

@ -186,7 +186,7 @@ FT_BEGIN_HEADER
} T1_Blend_Flags; } T1_Blend_Flags;
/* backwards compatible definitions */ /*# backwards compatible definitions */
#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION #define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS #define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE #define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
@ -317,10 +317,65 @@ FT_BEGIN_HEADER
/* FreeType. */ /* FreeType. */
/* */ /* */
typedef CID_FaceInfoRec CID_Info; typedef CID_FaceInfoRec CID_Info;
/* */ /* */
/************************************************************************
*
* @function: FT_Has_PS_Glyph_Names
*
* @description:
* returns true when a given face provides reliable Postscript glyph
* names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, except
* that certain fonts (mostly TrueType) contain incorrect glyph name
* tables.
*
* when this function returns true, the caller is sure that the glyph
* names returned by @FT_Get_Glyph_Name are reliable.
*
* @input:
* face :: face handle
*
* @return:
* boolean. true if glyph names are reliable
*/
FT_EXPORT( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face );
/************************************************************************
*
* @function: FT_Get_PS_Font_Info
*
* @description:
* retrieve the @PS_FontInfoRec structure corresponding to a given
* Postscript font.
*
* @input:
* face :: postscript face handle
*
* @output:
* afont_info :: output font info structure pointer
*
* @return:
* error code. 0 means success
*
* @note:
* the string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* if the font's format is not Postscript-based, this function will
* return the @FT_Err_Invalid_Argument error code.
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec *afont_info );
/* */
FT_END_HEADER FT_END_HEADER
#endif /* __T1TABLES_H__ */ #endif /* __T1TABLES_H__ */

View File

@ -23,8 +23,8 @@ SubDirHdrs [ FT2_SubDir src base ] ;
# Add the optional/replaceable files. # Add the optional/replaceable files.
# #
Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c
ftbbox.c ftdebug.c ; ftbbox.c ftdebug.c ftxf86.c fttype1.c ;
# Add Macintosh-specific file to the library when necessary. # Add Macintosh-specific file to the library when necessary.
# #

View File

@ -15,7 +15,7 @@
CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base]) CFLAGS=$(COMP_FLAGS)$(DEBUG)/include=([--.builds.vms],[--.include],[--.src.base])
OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj OBJS=ftbase.obj,ftinit.obj,ftglyph.obj,ftdebug.obj,ftbdf.obj,ftmm.obj,fttype1.obj,ftxf86.obj
all : $(OBJS) all : $(OBJS)
library [--.lib]freetype.olb $(OBJS) library [--.lib]freetype.olb $(OBJS)

74
src/base/fttype1.c Normal file
View File

@ -0,0 +1,74 @@
#include <ft2build.h>
#include FT_INTERNAL_TYPE1_TYPES_H
#include FT_INTERNAL_OBJECTS_H
/* case a FT_Face to a T1_Face when relevant */
/* this implementation sucks, but a lot of things should change in the */
/* future anyway.. */
/* */
static T1_Face
t1_face_check_cast( FT_Face face )
{
FT_Module driver;
T1_Face result = NULL;
if ( face && face->driver != NULL )
{
driver = (FT_Module) face->driver;
if ( driver->clazz && driver->clazz->module_name &&
ft_strcmp( driver->clazz->module_name, "type1" ) == 0 )
{
/* correct typecast ! */
result = (T1_Face) face;
}
}
return result;
}
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec* afont_info )
{
FT_Error error = FT_Err_Invalid_Argument;
T1_Face t1_face = t1_face_check_cast( face );
if ( t1_face != NULL )
{
*afont_info = t1_face->type1.font_info;
error = FT_Err_Ok;
}
return error;
}
/* XXX: bad hack, but I didn't want to change several drivers here */
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face )
{
FT_Int result = 0;
const char* driver_name;
if ( face && face->driver && face->driver->root.clazz )
{
/* for now, only the type1 and cff drivers provide reliable */
/* glyph names... */
/* we could probably hack the TrueType driver to recognize */
/* certain cases where the glyph names are most certainly */
/* correct (e.g. using a 20 or 22 format 'post' table), but */
/* this will probably happen later... :-) */
driver_name = face->driver->root.clazz->module_name;
result = ( ft_strcmp( driver_name, "type1" ) ||
ft_strcmp( driver_name, "cff" ) );
}
return result;
}

56
src/base/ftxf86.c Normal file
View File

@ -0,0 +1,56 @@
#include <ft2build.h>
#include FT_XFREE86_H
#include FT_INTERNAL_OBJECTS_H
/* XXX: this really is a sad hack, but I didn't want to change every */
/* driver just to support this at the moment, since other important */
/* changes are coming anyway !! */
typedef struct
{
const char* driver_name;
const char* format_name;
} FT_FontFormatRec;
FT_EXPORT_DEF( const char* )
FT_Get_X11_Font_Format( FT_Face face )
{
static const FT_FontFormatRec font_formats[] =
{
{ "type1", "Type 1" },
{ "truetype", "TrueType" },
{ "bdf", "BDF" },
{ "pcf", "PCF" },
{ "type42", "Type 42" },
{ "cidtype1", "CID Type 1" },
{ "cff", "CFF" },
{ "pfr", "PFR" },
{ "winfonts", "Windows FNT" }
};
const char* result = NULL;
if ( face && face->driver )
{
FT_Module driver = (FT_Module) face->driver;
if ( driver->clazz && driver->clazz->module_name )
{
FT_Int n, count = sizeof(font_formats)/sizeof(font_formats[0]);
result = driver->clazz->module_name;
for ( n = 0; n < count; n++ )
if ( ft_strcmp( result, font_formats[n].driver_name ) == 0 )
{
result = font_formats[n].format_name;
break;
}
}
}
return result;
}

View File

@ -52,6 +52,8 @@ BASE_SRC := $(BASE_)ftcalc.c \
BASE_EXT_SRC := $(BASE_)ftglyph.c \ BASE_EXT_SRC := $(BASE_)ftglyph.c \
$(BASE_)ftmm.c \ $(BASE_)ftmm.c \
$(BASE_)ftbdf.c \ $(BASE_)ftbdf.c \
$(BASE_)fttype1.c \
$(BASE_)ftxf86.c \
$(BASE_)ftbbox.c $(BASE_)ftbbox.c
# Default extensions objects # Default extensions objects