* include/freetype/ftbdf.h, include/freetype/internal/bdftypes.h,

src/base/ftbdf.c, src/bdf/bdfdrivr.c, src/pcf/pcfdrivr.c,
    src/pcf/pcfread.h:

      adding a new API, named FT_Get_BDF_Property to retrieve the BDF
      properties of a given PCF or BDF font
This commit is contained in:
David Turner 2003-01-22 22:45:28 +00:00
parent 0d52639603
commit 2f70965f9f
10 changed files with 316 additions and 25 deletions

View File

@ -1,3 +1,13 @@
2003-01-22 David Turner <david@freetype.org>
* include/freetype/ftbdf.h, include/freetype/internal/bdftypes.h,
src/base/ftbdf.c, src/bdf/bdfdrivr.c, src/pcf/pcfdrivr.c,
src/pcf/pcfread.h:
adding a new API, named FT_Get_BDF_Property to retrieve the BDF
properties of a given PCF or BDF font
2003-01-18 Werner Lemberg <wl@gnu.org>
* builds/unix/ltmain.sh: Regenerated with `libtoolize --force
@ -145,7 +155,7 @@
2002-12-02 Antoine Leca <Antoine-Freetype@Leca-Marti.org>
* src/base/ftobjs.c: Modified the logic to get Unicode charmaps.
* src/base/ftobjs.c: Modified the logic to get Unicode charmaps.
Now it loads UCS-4 charmaps when there is one.
* src/base/ftobjs.c (find_unicode_charmap): New function.
* src/base/ftobjs.c (open_face): Refer to the above one.
@ -200,7 +210,7 @@
the use of system-wide zlib.
Note that this macro, as well as
FT_CONFIG_OPTION_BYTECODE_INTERPRETER, is not #undef-ed anymore.
FT_CONFIG_OPTION_BYTECODE_INTERPRETER, is not #undef-ed anymore.
This allows the build system to define them depending on the
configuration (typically by adding -D flags at compile time).

View File

@ -43,6 +43,73 @@ FT_BEGIN_HEADER
/*************************************************************************/
/**********************************************************************
*
* @enum:
* FT_PropertyType
*
* @description:
* list of BDF property types
*
* @values:
* BDF_PROPERTY_TYPE_NONE ::
* value 0 is used to indicate a missing property
*
* BDF_PROPERTY_TYPE_ATOM ::
* property is a string atom
*
* BDF_PROPERTY_TYPE_INTEGER ::
* property is a 32-bit signed integer
*
* BDF_PROPERTY_TYPE_CARDINAL ::
* property is a 32-bit unsigned integer
*/
typedef enum
{
BDF_PROPERTY_TYPE_NONE = 0,
BDF_PROPERTY_TYPE_ATOM = 1,
BDF_PROPERTY_TYPE_INTEGER = 2,
BDF_PROPERTY_TYPE_CARDINAL = 3
} BDF_PropertyType;
/**********************************************************************
*
* @type: BDF_Property
*
* @description:
* handle to a @BDF_PropertyRec structure used to model a given
* BDF/PCF property
*/
typedef struct BDF_PropertyRec_* BDF_Property;
/**********************************************************************
*
* @struct: BDF_PropertyRec
*
* @description:
* models a given BDF/PCF property
*
* @note:
* type :: property type
* u.atom :: atom string, when type is @BDF_PROPERTY_TYPE_ATOM
* u.integer :: signed integer, when type is @BDF_PROPERTY_TYPE_INTEGER
* u.cardinal :: unsigned integer, when type is @BDF_PROPERTY_TYPE_CARDINAL
*/
typedef struct BDF_PropertyRec_
{
BDF_PropertyType type;
union {
const char* atom;
FT_Int32 integer;
FT_UInt32 cardinal;
} u;
} BDF_PropertyRec;
/**********************************************************************
*
* @function:
@ -74,6 +141,37 @@ FT_BEGIN_HEADER
const char* *acharset_encoding,
const char* *acharset_registry );
/**********************************************************************
*
* @function:
* FT_Get_BDF_Property
*
* @description:
* Retrieves a BDF property from a BDF or PCF font file
*
* @input:
* face :: handle to input face
* name :: property name
*
* @output:
* aproperty :: the property
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function works with BDF _and_ PCF fonts. It returns an error
* otherwise. it also returns an error when the property is not in the
* font.
*
* in case of error, "aproperty->type" is always set to
* @BDF_PROPERTY_TYPE_NONE
*/
FT_EXPORT( FT_Error )
FT_Get_BDF_Property( FT_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty );
/* */
FT_END_HEADER

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BDF_H
FT_BEGIN_HEADER
@ -44,6 +45,10 @@ FT_BEGIN_HEADER
} BDF_Public_FaceRec, *BDF_Public_Face;
typedef FT_Error (*BDF_GetPropertyFunc)( FT_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty );
FT_END_HEADER

View File

@ -462,6 +462,8 @@ FT_BEGIN_HEADER
FT_Get_Module_Interface( FT_Library library,
const char* mod_name );
/* */
/*************************************************************************/
/*************************************************************************/

View File

@ -20,6 +20,22 @@
#include FT_INTERNAL_BDF_TYPES_H
#include FT_INTERNAL_OBJECTS_H
static FT_Bool
test_font_type( FT_Face face, const char* name )
{
if ( face && face->driver )
{
FT_Module driver = (FT_Module)face->driver;
if ( driver->clazz && driver->clazz->module_name )
{
if ( ft_strcmp( driver->clazz->module_name, name ) == 0 )
return 1;
}
}
return 0;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_BDF_Charset_ID( FT_Face face,
@ -29,35 +45,52 @@
FT_Error error;
const char* encoding = NULL;
const char* registry = NULL;
error = FT_Err_Invalid_Argument;
if ( face != NULL && face->driver != NULL )
if ( test_font_type( face, "bdf" ) )
{
FT_Module driver = (FT_Module) face->driver;
BDF_Public_Face bdf_face = (BDF_Public_Face)face;
if ( driver->clazz && driver->clazz->module_name &&
ft_strcmp( driver->clazz->module_name, "bdf" ) == 0 )
{
BDF_Public_Face bdf_face = (BDF_Public_Face)face;
encoding = (const char*) bdf_face->charset_encoding;
registry = (const char*) bdf_face->charset_registry;
error = 0;
}
encoding = (const char*) bdf_face->charset_encoding;
registry = (const char*) bdf_face->charset_registry;
error = 0;
}
if ( acharset_encoding )
*acharset_encoding = encoding;
if ( acharset_registry )
*acharset_registry = registry;
return error;
}
return error;
}
FT_EXPORT( FT_Error )
FT_Get_BDF_Property( FT_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty )
{
FT_Error error;
error = FT_Err_Invalid_Argument;
aproperty->type = BDF_PROPERTY_TYPE_NONE;
if ( face != NULL && face->driver != NULL )
{
FT_Driver driver = face->driver;
BDF_GetPropertyFunc func;
func = (BDF_GetPropertyFunc) driver->root.clazz->get_interface(
FT_MODULE( driver ), "get_bdf_property" );
if ( func )
error = func( face, prop_name, aproperty );
}
return error;
}
/* END */

View File

@ -29,6 +29,7 @@ THE SOFTWARE.
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_OBJECTS_H
#include FT_BDF_H
#include "bdf.h"
#include "bdfdrivr.h"
@ -631,6 +632,58 @@ THE SOFTWARE.
}
static FT_Error
bdf_get_bdf_property( BDF_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty )
{
bdf_property_t* prop;
FT_ASSERT( face && face->bdffont );
prop = bdf_get_font_property( face->bdffont, (char*)prop_name );
if ( prop != NULL )
{
switch ( prop->format )
{
case BDF_ATOM:
aproperty->type = BDF_PROPERTY_TYPE_ATOM;
aproperty->u.atom = prop->value.atom;
break;
case BDF_INTEGER:
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = prop->value.int32;
break;
case BDF_CARDINAL:
aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
aproperty->u.cardinal = prop->value.card32;
break;
default:
goto Fail;
}
return 0;
}
Fail:
return FT_Err_Invalid_Argument;
}
static FT_Module_Interface
bdf_driver_requester( FT_Module module,
const char* name )
{
FT_UNUSED( module );
if ( name && ft_strcmp( name, "get_bdf_property" ) == 0 )
return (FT_Module_Interface) bdf_get_bdf_property;
return NULL;
}
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec bdf_driver_class =
{
@ -646,7 +699,7 @@ THE SOFTWARE.
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
(FT_Module_Requester) bdf_driver_requester
},
sizeof ( BDF_FaceRec ),

View File

@ -229,7 +229,6 @@ FT_BEGIN_HEADER
pcf_load_font( FT_Stream,
PCF_Face );
FT_END_HEADER
#endif /* __PCF_H__ */

View File

@ -32,10 +32,12 @@ THE SOFTWARE.
#include FT_INTERNAL_OBJECTS_H
#include FT_GZIP_H
#include FT_ERRORS_H
#include FT_BDF_H
#include "pcf.h"
#include "pcfdriver.h"
#include "pcfutil.h"
#include "pcfread.h"
#include "pcferror.h"
@ -458,6 +460,49 @@ THE SOFTWARE.
}
static FT_Error
pcf_get_bdf_property( PCF_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty )
{
PCF_Property prop;
prop = pcf_find_property( face, prop_name );
if ( prop != NULL )
{
if ( prop->isString )
{
aproperty->type = BDF_PROPERTY_TYPE_ATOM;
aproperty->u.atom = prop->value.atom;
}
else
{
/* apparently, the PCF driver loads all properties as signed integers !
* this really doesn't seem to be a problem, because this is
* sufficient for any meaningful values
*/
aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
aproperty->u.integer = prop->value.integer;
}
return 0;
}
return FT_Err_Invalid_Argument;
}
static FT_Module_Interface
pcf_driver_requester( FT_Module module,
const char* name )
{
FT_UNUSED( module );
if ( name && ft_strcmp( name, "get_bdf_property" ) == 0 )
return (FT_Module_Interface) pcf_get_bdf_property;
return NULL;
}
FT_CALLBACK_TABLE_DEF
const FT_Driver_ClassRec pcf_driver_class =
{
@ -473,7 +518,7 @@ THE SOFTWARE.
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
(FT_Module_Requester) pcf_driver_requester
},
sizeof( PCF_FaceRec ),

View File

@ -33,6 +33,7 @@ THE SOFTWARE.
#include "pcf.h"
#include "pcfdriver.h"
#include "pcfread.h"
#include "pcferror.h"
@ -316,7 +317,7 @@ THE SOFTWARE.
};
static PCF_Property
FT_LOCAL_DEF( PCF_Property )
pcf_find_property( PCF_Face face,
const FT_String* prop )
{

45
src/pcf/pcfread.h Normal file
View File

@ -0,0 +1,45 @@
/* pcfread.h
FreeType font driver for pcf fonts
Copyright 2000-2001 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef __PCFREAD_H__
#define __PCFREAD_H__
#include <ft2build.h>
FT_BEGIN_HEADER
FT_LOCAL( PCF_Property )
pcf_find_property( PCF_Face face,
const FT_String* prop );
FT_END_HEADER
#endif /* __PCFUTIL_H__ */
/* END */