2001-01-01 18:24:31 +01:00
|
|
|
/* pcfdriver.c
|
|
|
|
|
|
|
|
FreeType font driver for pcf files
|
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
Copyright (C) 2000-2001, 2002 by
|
2001-06-27 21:46:12 +02:00
|
|
|
Francesco Zappa Nardelli
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "pcf.h"
|
|
|
|
#include "pcfdriver.h"
|
|
|
|
#include "pcfutil.h"
|
2001-01-01 18:24:31 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "pcferror.h"
|
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_pcfread
|
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
|
|
|
typedef struct PCF_CMapRec_
|
2002-03-21 16:02:54 +01:00
|
|
|
{
|
|
|
|
FT_CMapRec cmap;
|
|
|
|
FT_UInt num_encodings;
|
|
|
|
PCF_Encoding encodings;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
} PCF_CMapRec, *PCF_CMap;
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2002-03-31 08:56:56 +02:00
|
|
|
pcf_cmap_init( PCF_CMap cmap )
|
2002-03-21 16:02:54 +01:00
|
|
|
{
|
2002-03-31 08:56:56 +02:00
|
|
|
PCF_Face face = (PCF_Face)FT_CMAP_FACE( cmap );
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
|
|
|
cmap->num_encodings = (FT_UInt)face->nencodings;
|
2002-03-21 16:02:54 +01:00
|
|
|
cmap->encodings = face->encodings;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
|
|
|
pcf_cmap_done( PCF_CMap cmap )
|
|
|
|
{
|
2002-06-11 00:41:57 +02:00
|
|
|
cmap->encodings = NULL;
|
2002-03-21 16:02:54 +01:00
|
|
|
cmap->num_encodings = 0;
|
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_UInt )
|
2002-03-22 18:09:52 +01:00
|
|
|
pcf_cmap_char_index( PCF_CMap cmap,
|
2002-03-21 16:02:54 +01:00
|
|
|
FT_UInt32 charcode )
|
|
|
|
{
|
2002-03-22 18:09:52 +01:00
|
|
|
PCF_Encoding encodings = cmap->encodings;
|
2002-03-21 16:02:54 +01:00
|
|
|
FT_UInt min, max, mid;
|
|
|
|
FT_UInt result = 0;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
min = 0;
|
|
|
|
max = cmap->num_encodings;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
while ( min < max )
|
|
|
|
{
|
|
|
|
FT_UInt32 code;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
mid = ( min + max ) >> 1;
|
|
|
|
code = encodings[mid].enc;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
if ( charcode == code )
|
|
|
|
{
|
2002-06-16 03:14:16 +02:00
|
|
|
result = encodings[mid].glyph + 1;
|
2002-03-21 16:02:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
if ( charcode < code )
|
|
|
|
max = mid;
|
|
|
|
else
|
2002-03-31 08:56:56 +02:00
|
|
|
min = mid + 1;
|
2002-03-21 16:02:54 +01:00
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
return result;
|
2002-06-11 00:41:57 +02:00
|
|
|
}
|
2002-03-21 16:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_UInt )
|
|
|
|
pcf_cmap_char_next( PCF_CMap cmap,
|
|
|
|
FT_UInt32 *acharcode )
|
|
|
|
{
|
|
|
|
PCF_Encoding encodings = cmap->encodings;
|
|
|
|
FT_UInt min, max, mid;
|
|
|
|
FT_UInt32 charcode = *acharcode + 1;
|
|
|
|
FT_UInt result = 0;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
min = 0;
|
|
|
|
max = cmap->num_encodings;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
while ( min < max )
|
|
|
|
{
|
|
|
|
FT_UInt32 code;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
mid = ( min + max ) >> 1;
|
|
|
|
code = encodings[mid].enc;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
if ( charcode == code )
|
|
|
|
{
|
2002-06-16 03:14:16 +02:00
|
|
|
result = encodings[mid].glyph + 1;
|
2002-03-21 16:02:54 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
if ( charcode < code )
|
|
|
|
max = mid;
|
|
|
|
else
|
2002-03-31 08:56:56 +02:00
|
|
|
min = mid + 1;
|
2002-03-21 16:02:54 +01:00
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
charcode = 0;
|
2002-06-11 00:41:57 +02:00
|
|
|
if ( min < cmap->num_encodings )
|
2002-03-21 16:02:54 +01:00
|
|
|
{
|
|
|
|
charcode = encodings[min].enc;
|
2002-06-16 03:14:16 +02:00
|
|
|
result = encodings[min].glyph + 1;
|
2002-03-21 16:02:54 +01:00
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
Exit:
|
|
|
|
*acharcode = charcode;
|
|
|
|
return result;
|
2002-06-11 00:41:57 +02:00
|
|
|
}
|
2002-03-21 16:02:54 +01:00
|
|
|
|
|
|
|
|
2002-03-22 16:55:55 +01:00
|
|
|
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec pcf_cmap_class =
|
2002-03-21 16:02:54 +01:00
|
|
|
{
|
|
|
|
sizeof( PCF_CMapRec ),
|
2002-03-31 08:56:56 +02:00
|
|
|
(FT_CMap_InitFunc) pcf_cmap_init,
|
|
|
|
(FT_CMap_DoneFunc) pcf_cmap_done,
|
|
|
|
(FT_CMap_CharIndexFunc)pcf_cmap_char_index,
|
|
|
|
(FT_CMap_CharNextFunc) pcf_cmap_char_next
|
2002-03-21 16:02:54 +01:00
|
|
|
};
|
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_pcfdriver
|
|
|
|
|
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2002-02-06 12:22:56 +01:00
|
|
|
PCF_Face_Done( PCF_Face face )
|
2001-06-27 21:46:12 +02:00
|
|
|
{
|
2002-03-31 08:56:56 +02:00
|
|
|
FT_Memory memory = FT_FACE_MEMORY( face );
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->encodings );
|
|
|
|
FT_FREE( face->metrics );
|
2001-01-01 18:24:31 +01:00
|
|
|
|
2002-02-06 12:22:56 +01:00
|
|
|
/* free properties */
|
2001-01-01 18:24:31 +01:00
|
|
|
{
|
2002-03-31 08:56:56 +02:00
|
|
|
PCF_Property prop = face->properties;
|
|
|
|
FT_Int i;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
2002-02-06 12:22:56 +01:00
|
|
|
for ( i = 0; i < face->nprops; i++ )
|
|
|
|
{
|
|
|
|
prop = &face->properties[i];
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( prop->name );
|
2002-02-06 12:22:56 +01:00
|
|
|
if ( prop->isString )
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( prop->value );
|
2002-02-06 12:22:56 +01:00
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->properties );
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->toc.tables );
|
|
|
|
FT_FREE( face->root.family_name );
|
|
|
|
FT_FREE( face->root.available_sizes );
|
|
|
|
FT_FREE( face->charset_encoding );
|
|
|
|
FT_FREE( face->charset_registry );
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
FT_TRACE4(( "DONE_FACE!!!\n" ));
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return PCF_Err_Ok;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2002-02-06 12:22:56 +01:00
|
|
|
PCF_Face_Init( FT_Stream stream,
|
2001-06-27 21:46:12 +02:00
|
|
|
PCF_Face face,
|
|
|
|
FT_Int face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2001-01-01 18:24:31 +01:00
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
FT_Error error = PCF_Err_Ok;
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
FT_UNUSED( num_params );
|
|
|
|
FT_UNUSED( params );
|
|
|
|
FT_UNUSED( face_index );
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
error = pcf_load_font( stream, face );
|
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
/* set-up charmap */
|
|
|
|
{
|
2002-03-31 08:56:56 +02:00
|
|
|
FT_String *charset_registry, *charset_encoding;
|
|
|
|
FT_Bool unicode_charmap = 0;
|
2002-03-21 16:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
charset_registry = face->charset_registry;
|
|
|
|
charset_encoding = face->charset_encoding;
|
|
|
|
|
|
|
|
if ( ( charset_registry != NULL ) &&
|
|
|
|
( charset_encoding != NULL ) )
|
|
|
|
{
|
2002-04-14 02:54:32 +02:00
|
|
|
if ( !ft_strcmp( face->charset_registry, "ISO10646" ) ||
|
|
|
|
( !ft_strcmp( face->charset_registry, "ISO8859" ) &&
|
|
|
|
!ft_strcmp( face->charset_encoding, "1" ) ) )
|
2002-03-21 16:02:54 +01:00
|
|
|
unicode_charmap = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
FT_CharMapRec charmap;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
|
|
|
|
charmap.face = FT_FACE( face );
|
2002-03-21 16:02:54 +01:00
|
|
|
charmap.encoding = ft_encoding_none;
|
|
|
|
charmap.platform_id = 0;
|
|
|
|
charmap.encoding_id = 0;
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
if ( unicode_charmap )
|
|
|
|
{
|
|
|
|
charmap.encoding = ft_encoding_unicode;
|
|
|
|
charmap.platform_id = 3;
|
|
|
|
charmap.encoding_id = 1;
|
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL );
|
2002-06-19 17:57:55 +02:00
|
|
|
|
2002-07-18 00:51:06 +02:00
|
|
|
#if 0
|
2002-06-19 17:57:55 +02:00
|
|
|
/* Select default charmap */
|
|
|
|
if (face->root.num_charmaps)
|
|
|
|
face->root.charmap = face->root.charmaps[0];
|
2002-07-18 00:51:06 +02:00
|
|
|
#endif
|
2002-03-21 16:02:54 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-11 00:41:57 +02:00
|
|
|
|
2002-03-21 16:02:54 +01:00
|
|
|
Exit:
|
|
|
|
return error;
|
2001-01-01 18:24:31 +01:00
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
Fail:
|
2001-01-01 18:24:31 +01:00
|
|
|
FT_TRACE2(( "[not a valid PCF file]\n" ));
|
2002-03-21 16:02:54 +01:00
|
|
|
error = PCF_Err_Unknown_File_Format; /* error */
|
|
|
|
goto Exit;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
|
|
|
PCF_Set_Pixel_Size( FT_Size size )
|
|
|
|
{
|
2001-01-01 18:24:31 +01:00
|
|
|
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
|
|
|
|
|
|
|
|
|
|
|
|
FT_TRACE4(( "rec %d - pres %d\n", size->metrics.y_ppem,
|
|
|
|
face->root.available_sizes->height ));
|
|
|
|
|
|
|
|
if ( size->metrics.y_ppem == face->root.available_sizes->height )
|
|
|
|
{
|
2002-03-31 08:56:56 +02:00
|
|
|
size->metrics.ascender = face->accel.fontAscent << 6;
|
|
|
|
size->metrics.descender = face->accel.fontDescent * (-64);
|
2001-01-01 18:24:31 +01:00
|
|
|
#if 0
|
2002-03-31 08:56:56 +02:00
|
|
|
size->metrics.height = face->accel.maxbounds.ascent << 6;
|
2001-01-01 18:24:31 +01:00
|
|
|
#endif
|
2002-03-31 08:56:56 +02:00
|
|
|
size->metrics.height = size->metrics.ascender -
|
|
|
|
size->metrics.descender;
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-12-10 11:47:47 +01:00
|
|
|
size->metrics.max_advance = face->accel.maxbounds.characterWidth << 6;
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return PCF_Err_Ok;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_TRACE4(( "size WRONG\n" ));
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return PCF_Err_Invalid_Pixel_Size;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-02-06 12:22:56 +01:00
|
|
|
PCF_Glyph_Load( FT_GlyphSlot slot,
|
2001-06-27 21:46:12 +02:00
|
|
|
FT_Size size,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int load_flags )
|
|
|
|
{
|
2001-01-01 18:24:31 +01:00
|
|
|
PCF_Face face = (PCF_Face)FT_SIZE_FACE( size );
|
2002-02-06 12:22:56 +01:00
|
|
|
FT_Stream stream = face->root.stream;
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
FT_Error error = PCF_Err_Ok;
|
2002-03-31 08:56:56 +02:00
|
|
|
FT_Memory memory = FT_FACE( face )->memory;
|
2001-01-01 18:24:31 +01:00
|
|
|
FT_Bitmap* bitmap = &slot->bitmap;
|
|
|
|
PCF_Metric metric;
|
|
|
|
int bytes;
|
|
|
|
|
|
|
|
FT_UNUSED( load_flags );
|
|
|
|
|
|
|
|
|
|
|
|
FT_TRACE4(( "load_glyph %d ---", glyph_index ));
|
|
|
|
|
|
|
|
if ( !face )
|
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = PCF_Err_Invalid_Argument;
|
2001-01-01 18:24:31 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2002-06-16 03:14:16 +02:00
|
|
|
if ( glyph_index > 0 )
|
|
|
|
glyph_index--;
|
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
metric = face->metrics + glyph_index;
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
bitmap->rows = metric->ascent + metric->descent;
|
2001-05-08 14:58:07 +02:00
|
|
|
bitmap->width = metric->rightSideBearing - metric->leftSideBearing;
|
2001-01-01 18:24:31 +01:00
|
|
|
bitmap->num_grays = 1;
|
|
|
|
bitmap->pixel_mode = ft_pixel_mode_mono;
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
FT_TRACE6(( "BIT_ORDER %d ; BYTE_ORDER %d ; GLYPH_PAD %d\n",
|
|
|
|
PCF_BIT_ORDER( face->bitmapsFormat ),
|
|
|
|
PCF_BYTE_ORDER( face->bitmapsFormat ),
|
|
|
|
PCF_GLYPH_PAD( face->bitmapsFormat ) ));
|
|
|
|
|
|
|
|
switch ( PCF_GLYPH_PAD( face->bitmapsFormat ) )
|
|
|
|
{
|
2001-06-27 21:46:12 +02:00
|
|
|
case 1:
|
2001-01-01 18:24:31 +01:00
|
|
|
bitmap->pitch = ( bitmap->width + 7 ) >> 3;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
bitmap->pitch = ( ( bitmap->width + 15 ) >> 4 ) << 1;
|
|
|
|
break;
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
case 4:
|
2001-01-01 18:24:31 +01:00
|
|
|
bitmap->pitch = ( ( bitmap->width + 31 ) >> 5 ) << 2;
|
|
|
|
break;
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
case 8:
|
|
|
|
bitmap->pitch = ( ( bitmap->width + 63 ) >> 6 ) << 3;
|
2001-01-01 18:24:31 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return PCF_Err_Invalid_File_Format;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX: to do: are there cases that need repadding the bitmap? */
|
|
|
|
bytes = bitmap->pitch * bitmap->rows;
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_ALLOC( bitmap->buffer, bytes ) )
|
2001-01-01 18:24:31 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
if ( FT_STREAM_SEEK( metric->bits ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_STREAM_READ( bitmap->buffer, bytes ) )
|
2001-01-01 18:24:31 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( PCF_BIT_ORDER( face->bitmapsFormat ) != MSBFirst )
|
2002-08-19 00:02:03 +02:00
|
|
|
BitOrderInvert( bitmap->buffer, bytes );
|
2001-01-01 18:24:31 +01:00
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
if ( ( PCF_BYTE_ORDER( face->bitmapsFormat ) !=
|
2001-01-01 18:24:31 +01:00
|
|
|
PCF_BIT_ORDER( face->bitmapsFormat ) ) )
|
|
|
|
{
|
|
|
|
switch ( PCF_SCAN_UNIT( face->bitmapsFormat ) )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
TwoByteSwap( bitmap->buffer, bytes );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
FourByteSwap( bitmap->buffer, bytes );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-08 15:54:36 +02:00
|
|
|
slot->bitmap_left = metric->leftSideBearing;
|
2001-01-01 18:24:31 +01:00
|
|
|
slot->bitmap_top = metric->ascent;
|
|
|
|
|
|
|
|
slot->metrics.horiAdvance = metric->characterWidth << 6 ;
|
2002-08-19 00:02:03 +02:00
|
|
|
slot->metrics.horiBearingX = metric->leftSideBearing << 6 ;
|
2001-01-01 18:24:31 +01:00
|
|
|
slot->metrics.horiBearingY = metric->ascent << 6 ;
|
|
|
|
slot->metrics.width = metric->characterWidth << 6 ;
|
|
|
|
slot->metrics.height = bitmap->rows << 6;
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16;
|
|
|
|
slot->format = ft_glyph_format_bitmap;
|
2002-02-24 03:39:08 +01:00
|
|
|
slot->flags = FT_GLYPH_OWN_BITMAP;
|
2001-01-01 18:24:31 +01:00
|
|
|
|
|
|
|
FT_TRACE4(( " --- ok\n" ));
|
|
|
|
|
|
|
|
Exit:
|
2001-06-27 21:46:12 +02:00
|
|
|
return error;
|
2001-01-01 18:24:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_TABLE_DEF
|
* include/freetype/internal/ftdriver.h,
include/freetype/internal/ftobjs.h,
src/base/ftapi.c, src/base/ftobjs.c,
src/cff/cffdrivr.c, src/cff/cffdrivr.h,
src/cid/cidriver.c, src/cid/cidriver.h,
src/pcf/pcfdriver.c, src/pcf/pcfdriver.h,
src/truetype/ttdriver.c, src/truetype/ttdriver.h,
src/type1/t1driver.c, src/type1/t1driver.h,
src/winfonts/winfnt.c, src/winfonts/winfnt.h:
updating the type definitions for font font drivers
2002-03-14 10:22:48 +01:00
|
|
|
const FT_Driver_ClassRec pcf_driver_class =
|
2001-01-01 18:24:31 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
ft_module_font_driver,
|
|
|
|
sizeof ( FT_DriverRec ),
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
"pcf",
|
|
|
|
0x10000L,
|
|
|
|
0x20000L,
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
0,
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
(FT_Module_Constructor)0,
|
|
|
|
(FT_Module_Destructor) 0,
|
|
|
|
(FT_Module_Requester) 0
|
|
|
|
},
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2001-01-01 18:24:31 +01:00
|
|
|
sizeof( PCF_FaceRec ),
|
|
|
|
sizeof( FT_SizeRec ),
|
|
|
|
sizeof( FT_GlyphSlotRec ),
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
(FT_Face_InitFunc) PCF_Face_Init,
|
|
|
|
(FT_Face_DoneFunc) PCF_Face_Done,
|
|
|
|
(FT_Size_InitFunc) 0,
|
|
|
|
(FT_Size_DoneFunc) 0,
|
|
|
|
(FT_Slot_InitFunc) 0,
|
|
|
|
(FT_Slot_DoneFunc) 0,
|
2001-06-27 21:46:12 +02:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
(FT_Size_ResetPointsFunc) PCF_Set_Pixel_Size,
|
|
|
|
(FT_Size_ResetPixelsFunc) PCF_Set_Pixel_Size,
|
2002-03-21 16:02:54 +01:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
(FT_Slot_LoadFunc) PCF_Glyph_Load,
|
2001-01-01 18:24:31 +01:00
|
|
|
|
2002-03-31 08:56:56 +02:00
|
|
|
(FT_Face_GetKerningFunc) 0,
|
|
|
|
(FT_Face_AttachFunc) 0,
|
* include/freetype/config/ftoption.h, include/freetype/internal/tttypes.h,
src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/cff/cffobjs.c,
src/pcf/pcfdrivr.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttcmap0.h, src/sfnt/ttload.c, src/type1/t1objs.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: code cleanup,
FT_CONFIG_OPTION_USE_CMAPS is now the default
2002-07-17 23:52:20 +02:00
|
|
|
(FT_Face_GetAdvancesFunc) 0
|
2001-01-01 18:24:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|