2000-07-07 21:46:01 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* winfnt.c */
|
|
|
|
/* */
|
|
|
|
/* FreeType font driver for Windows FNT/FON files */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996-2000 by */
|
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-07-09 00:52:21 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
2000-07-07 21:46:01 +02:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-12-09 01:45:38 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_FNT_TYPES_H
|
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
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "winfnt.h"
|
2000-07-07 21:46:01 +02: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 "fnterrs.h"
|
|
|
|
|
2000-07-09 00:52:21 +02: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. */
|
|
|
|
/* */
|
2000-07-07 21:46:01 +02:00
|
|
|
#undef FT_COMPONENT
|
2000-07-09 00:52:21 +02:00
|
|
|
#define FT_COMPONENT trace_winfnt
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-07-09 00:52:21 +02:00
|
|
|
const FT_Frame_Field winmz_header_fields[] =
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinMZ_Header
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_START( 64 ),
|
2000-09-29 08:41:56 +02:00
|
|
|
FT_FRAME_USHORT_LE ( magic ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 29 * 2 ),
|
|
|
|
FT_FRAME_ULONG_LE ( lfanew ),
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static
|
|
|
|
const FT_Frame_Field winne_header_fields[] =
|
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinNE_Header
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_START( 40 ),
|
2000-09-29 08:41:56 +02:00
|
|
|
FT_FRAME_USHORT_LE ( magic ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 34 ),
|
|
|
|
FT_FRAME_USHORT_LE ( resource_tab_offset ),
|
|
|
|
FT_FRAME_USHORT_LE ( rname_tab_offset ),
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static
|
|
|
|
const FT_Frame_Field winfnt_header_fields[] =
|
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinFNT_Header
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_START( 134 ),
|
2000-09-29 08:41:56 +02:00
|
|
|
FT_FRAME_USHORT_LE( version ),
|
|
|
|
FT_FRAME_ULONG_LE ( file_size ),
|
|
|
|
FT_FRAME_BYTES ( copyright, 60 ),
|
|
|
|
FT_FRAME_USHORT_LE( file_type ),
|
|
|
|
FT_FRAME_USHORT_LE( nominal_point_size ),
|
|
|
|
FT_FRAME_USHORT_LE( vertical_resolution ),
|
|
|
|
FT_FRAME_USHORT_LE( horizontal_resolution ),
|
|
|
|
FT_FRAME_USHORT_LE( ascent ),
|
|
|
|
FT_FRAME_USHORT_LE( internal_leading ),
|
|
|
|
FT_FRAME_USHORT_LE( external_leading ),
|
|
|
|
FT_FRAME_BYTE ( italic ),
|
|
|
|
FT_FRAME_BYTE ( underline ),
|
|
|
|
FT_FRAME_BYTE ( strike_out ),
|
|
|
|
FT_FRAME_USHORT_LE( weight ),
|
|
|
|
FT_FRAME_BYTE ( charset ),
|
|
|
|
FT_FRAME_USHORT_LE( pixel_width ),
|
|
|
|
FT_FRAME_USHORT_LE( pixel_height ),
|
|
|
|
FT_FRAME_BYTE ( pitch_and_family ),
|
|
|
|
FT_FRAME_USHORT_LE( avg_width ),
|
|
|
|
FT_FRAME_USHORT_LE( max_width ),
|
|
|
|
FT_FRAME_BYTE ( first_char ),
|
|
|
|
FT_FRAME_BYTE ( last_char ),
|
|
|
|
FT_FRAME_BYTE ( default_char ),
|
|
|
|
FT_FRAME_BYTE ( break_char ),
|
|
|
|
FT_FRAME_USHORT_LE( bytes_per_row ),
|
|
|
|
FT_FRAME_ULONG_LE ( device_offset ),
|
|
|
|
FT_FRAME_ULONG_LE ( face_name_offset ),
|
|
|
|
FT_FRAME_ULONG_LE ( bits_pointer ),
|
|
|
|
FT_FRAME_ULONG_LE ( bits_offset ),
|
|
|
|
FT_FRAME_BYTE ( reserved ),
|
|
|
|
FT_FRAME_ULONG_LE ( flags ),
|
|
|
|
FT_FRAME_USHORT_LE( A_space ),
|
|
|
|
FT_FRAME_USHORT_LE( B_space ),
|
|
|
|
FT_FRAME_USHORT_LE( C_space ),
|
|
|
|
FT_FRAME_USHORT_LE( color_table_offset ),
|
|
|
|
FT_FRAME_BYTES ( reserved, 4 ),
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static void
|
|
|
|
fnt_font_done( FNT_Font* font,
|
|
|
|
FT_Stream stream )
|
2000-07-09 00:52:21 +02:00
|
|
|
{
|
|
|
|
if ( font->fnt_frame )
|
2000-07-07 21:46:01 +02:00
|
|
|
RELEASE_Frame( font->fnt_frame );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
font->fnt_size = 0;
|
|
|
|
font->fnt_frame = 0;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
fnt_font_load( FNT_Font* font,
|
|
|
|
FT_Stream stream )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2000-07-09 00:52:21 +02:00
|
|
|
WinFNT_Header* header = &font->header;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
/* first of all, read the FNT header */
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( FILE_Seek( font->offset ) ||
|
2000-07-07 21:46:01 +02:00
|
|
|
READ_Fields( winfnt_header_fields, header ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if ( header->version != 0x200 &&
|
|
|
|
header->version != 0x300 )
|
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_TRACE2(( "[not a valid FNT file]\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
|
|
|
error = FNT_Err_Unknown_File_Format;
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( header->file_type & 1 )
|
|
|
|
{
|
2000-09-29 08:41:56 +02:00
|
|
|
FT_TRACE2(( "[can't handle vector FNT fonts]\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
|
|
|
error = FNT_Err_Unknown_File_Format;
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* small fixup -- some fonts have the `pixel_width' field set to 0 */
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( header->pixel_width == 0 )
|
|
|
|
header->pixel_width = header->pixel_height;
|
|
|
|
|
|
|
|
/* this is a FNT file/table, we now extract its frame */
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( FILE_Seek( font->offset ) ||
|
2000-07-07 21:46:01 +02:00
|
|
|
EXTRACT_Frame( header->file_size, font->fnt_frame ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static void
|
|
|
|
fnt_face_done_fonts( FNT_Face face )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory;
|
|
|
|
FT_Stream stream = FT_FACE(face)->stream;
|
|
|
|
FNT_Font* cur = face->fonts;
|
|
|
|
FNT_Font* limit = cur + face->num_fonts;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for ( ; cur < limit; cur++ )
|
2001-04-25 20:11:16 +02:00
|
|
|
fnt_font_done( cur, stream );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
FREE( face->fonts );
|
|
|
|
face->num_fonts = 0;
|
|
|
|
}
|
|
|
|
|
2000-09-29 08:41:56 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
fnt_face_get_dll_fonts( FNT_Face face )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Stream stream = FT_FACE(face)->stream;
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory;
|
|
|
|
WinMZ_Header mz_header;
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
face->fonts = 0;
|
|
|
|
face->num_fonts = 0;
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* does it begin with a MZ header? */
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( FILE_Seek( 0 ) ||
|
|
|
|
READ_Fields( winmz_header_fields, &mz_header ) )
|
|
|
|
goto Exit;
|
|
|
|
|
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 = FNT_Err_Unknown_File_Format;
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( mz_header.magic == WINFNT_MZ_MAGIC )
|
|
|
|
{
|
|
|
|
/* yes, now look for a NE header in the file */
|
|
|
|
WinNE_Header ne_header;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( FILE_Seek( mz_header.lfanew ) ||
|
|
|
|
READ_Fields( winne_header_fields, &ne_header ) )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02: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
|
|
|
error = FNT_Err_Unknown_File_Format;
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( ne_header.magic == WINFNT_NE_MAGIC )
|
|
|
|
{
|
|
|
|
/* good, now look in the resource table for each FNT resource */
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_ULong res_offset = mz_header.lfanew +
|
|
|
|
ne_header.resource_tab_offset;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_UShort size_shift;
|
|
|
|
FT_UShort font_count = 0;
|
|
|
|
FT_ULong font_offset = 0;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( FILE_Seek( res_offset ) ||
|
|
|
|
ACCESS_Frame( ne_header.rname_tab_offset -
|
|
|
|
ne_header.resource_tab_offset ) )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
size_shift = GET_UShortLE();
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
FT_UShort type_id, count;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
type_id = GET_UShortLE();
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( !type_id )
|
2000-07-07 21:46:01 +02:00
|
|
|
break;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
count = GET_UShortLE();
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( type_id == 0x8008 )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
font_count = count;
|
2001-03-10 18:07:42 +01:00
|
|
|
font_offset = (FT_ULong)( FILE_Pos() + 4 +
|
|
|
|
( stream->cursor - stream->limit ) );
|
2000-07-07 21:46:01 +02:00
|
|
|
break;
|
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
stream->cursor += 4 + count * 12;
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
FORGET_Frame();
|
|
|
|
|
|
|
|
if ( !font_count || !font_offset )
|
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_TRACE2(( "this file doesn't contain any FNT resources!\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
|
|
|
error = FNT_Err_Unknown_File_Format;
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
if ( FILE_Seek( font_offset ) ||
|
2000-07-09 21:15:30 +02:00
|
|
|
ALLOC_ARRAY( face->fonts, font_count, FNT_Font ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
face->num_fonts = font_count;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( ACCESS_Frame( (FT_Long)font_count * 12 ) )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
/* now read the offset and position of each FNT font */
|
|
|
|
{
|
|
|
|
FNT_Font* cur = face->fonts;
|
|
|
|
FNT_Font* limit = cur + font_count;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
cur->offset = (FT_ULong)GET_UShortLE() << size_shift;
|
|
|
|
cur->fnt_size = (FT_ULong)GET_UShortLE() << size_shift;
|
|
|
|
cur->size_shift = size_shift;
|
|
|
|
stream->cursor += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FORGET_Frame();
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
/* finally, try to load each font there */
|
|
|
|
{
|
|
|
|
FNT_Font* cur = face->fonts;
|
|
|
|
FNT_Font* limit = cur + font_count;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
2001-04-25 20:11:16 +02:00
|
|
|
error = fnt_font_load( cur, stream );
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail:
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
2001-04-25 20:11:16 +02:00
|
|
|
fnt_face_done_fonts( face );
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static void
|
|
|
|
FNT_Face_Done( FNT_Face face )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_Memory memory = FT_FACE_MEMORY( face );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
fnt_face_done_fonts( face );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
FREE( face->root.available_sizes );
|
|
|
|
face->root.num_fixed_sizes = 0;
|
|
|
|
}
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
FNT_Face_Init( FT_Stream stream,
|
|
|
|
FNT_Face face,
|
|
|
|
FT_Int face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_Memory memory = FT_FACE_MEMORY( face );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_UNUSED( num_params );
|
|
|
|
FT_UNUSED( params );
|
|
|
|
FT_UNUSED( face_index );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
/* try to load several fonts from a DLL */
|
2001-04-25 20:11:16 +02:00
|
|
|
error = fnt_face_get_dll_fonts( face );
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
/* this didn't work, now try to load a single FNT font */
|
|
|
|
FNT_Font* font;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( ALLOC( face->fonts, sizeof ( *face->fonts ) ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
face->num_fonts = 1;
|
|
|
|
font = face->fonts;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
font->offset = 0;
|
|
|
|
font->fnt_size = stream->size;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
error = fnt_font_load( font, stream );
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* all right, one or more fonts were loaded; we now need to */
|
2000-07-09 21:15:30 +02:00
|
|
|
/* fill the root FT_Face fields with relevant information */
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_Face root = FT_FACE( face );
|
|
|
|
FNT_Font* fonts = face->fonts;
|
|
|
|
FNT_Font* limit = fonts + face->num_fonts;
|
|
|
|
FNT_Font* cur;
|
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
root->num_faces = 1;
|
|
|
|
root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
|
|
|
|
FT_FACE_FLAG_HORIZONTAL;
|
|
|
|
|
|
|
|
if ( fonts->header.avg_width == fonts->header.max_width )
|
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( fonts->header.italic )
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_ITALIC;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( fonts->header.weight >= 800 )
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_BOLD;
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* Setup the `fixed_sizes' array */
|
|
|
|
if ( ALLOC_ARRAY( root->available_sizes, face->num_fonts,
|
|
|
|
FT_Bitmap_Size ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Fail;
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
root->num_fixed_sizes = face->num_fonts;
|
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FT_Bitmap_Size* size = root->available_sizes;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for ( cur = fonts; cur < limit; cur++, size++ )
|
|
|
|
{
|
|
|
|
size->width = cur->header.pixel_width;
|
|
|
|
size->height = cur->header.pixel_height;
|
|
|
|
}
|
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* Setup the `charmaps' array */
|
2000-07-07 21:46:01 +02:00
|
|
|
root->charmaps = &face->charmap_handle;
|
|
|
|
root->num_charmaps = 1;
|
|
|
|
|
|
|
|
face->charmap.encoding = ft_encoding_unicode;
|
|
|
|
face->charmap.platform_id = 3;
|
|
|
|
face->charmap.encoding_id = 1;
|
|
|
|
face->charmap.face = root;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
face->charmap_handle = &face->charmap;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
root->charmap = face->charmap_handle;
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
/* setup remaining flags */
|
2000-07-09 00:52:21 +02:00
|
|
|
root->num_glyphs = fonts->header.last_char -
|
|
|
|
fonts->header.first_char + 1;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
root->family_name = (FT_String*)fonts->fnt_frame +
|
|
|
|
fonts->header.face_name_offset;
|
2000-08-01 00:51:00 +02:00
|
|
|
root->style_name = (char *)"Regular";
|
2000-07-09 00:52:21 +02:00
|
|
|
|
|
|
|
if ( root->style_flags & FT_STYLE_FLAG_BOLD )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
|
2000-08-01 00:51:00 +02:00
|
|
|
root->style_name = (char *)"Bold Italic";
|
2000-07-07 21:46:01 +02:00
|
|
|
else
|
2000-08-01 00:51:00 +02:00
|
|
|
root->style_name = (char *)"Bold";
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2000-07-09 00:52:21 +02:00
|
|
|
else if ( root->style_flags & FT_STYLE_FLAG_ITALIC )
|
2000-08-01 00:51:00 +02:00
|
|
|
root->style_name = (char *)"Italic";
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
Fail:
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
2001-04-25 20:11:16 +02:00
|
|
|
FNT_Face_Done( face );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
FNT_Size_Set_Pixels( FNT_Size size )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
/* look up a font corresponding to the current pixel size */
|
2000-07-09 00:52:21 +02:00
|
|
|
FNT_Face face = (FNT_Face)FT_SIZE_FACE( size );
|
2000-07-07 21:46:01 +02:00
|
|
|
FNT_Font* cur = face->fonts;
|
|
|
|
FNT_Font* limit = cur + face->num_fonts;
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
size->font = 0;
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
/* we only compare the character height, as fonts used some strange */
|
2000-07-09 00:52:21 +02:00
|
|
|
/* values */
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( cur->header.pixel_height == size->root.metrics.y_ppem )
|
|
|
|
{
|
|
|
|
size->font = cur;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-18 08:50:03 +02:00
|
|
|
size->root.metrics.ascender = cur->header.ascent * 64;
|
|
|
|
size->root.metrics.descender = ( cur->header.pixel_height -
|
|
|
|
cur->header.ascent ) * 64;
|
|
|
|
size->root.metrics.height = cur->header.pixel_height * 64;
|
2000-07-07 21:46:01 +02:00
|
|
|
break;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02: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
|
|
|
return ( size->font ? FNT_Err_Ok : FNT_Err_Invalid_Pixel_Size );
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_UInt
|
|
|
|
FNT_Get_Char_Index( FT_CharMap charmap,
|
|
|
|
FT_Long char_code )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2001-01-01 18:25:21 +01:00
|
|
|
FT_Long result = char_code;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
|
|
|
if ( charmap )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
FNT_Font* font = ((FNT_Face)charmap->face)->fonts;
|
2001-01-01 18:25:21 +01:00
|
|
|
FT_Long first = font->header.first_char;
|
|
|
|
FT_Long count = font->header.last_char - first + 1;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
char_code -= first;
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( char_code < count )
|
2000-07-20 08:57:41 +02:00
|
|
|
result = char_code + 1;
|
2000-07-07 21:46:01 +02:00
|
|
|
else
|
2000-07-19 22:17:37 +02:00
|
|
|
result = 0;
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
FNT_Load_Glyph( FT_GlyphSlot slot,
|
|
|
|
FNT_Size size,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int load_flags )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FNT_Font* font = size->font;
|
|
|
|
FT_Error error = 0;
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_Int len;
|
|
|
|
FT_Bitmap* bitmap = &slot->bitmap;
|
|
|
|
FT_ULong offset;
|
|
|
|
FT_Bool new_format;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_UNUSED( slot );
|
|
|
|
FT_UNUSED( load_flags );
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( !font )
|
2000-07-07 21:46:01 +02: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
|
|
|
error = FNT_Err_Invalid_Argument;
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2000-07-20 08:57:41 +02:00
|
|
|
if ( glyph_index > 0 )
|
2000-07-19 22:17:37 +02:00
|
|
|
glyph_index--;
|
|
|
|
else
|
|
|
|
glyph_index = font->header.default_char - font->header.first_char;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
new_format = FT_BOOL( font->header.version == 0x300 );
|
2000-07-07 21:46:01 +02:00
|
|
|
len = new_format ? 6 : 4;
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
/* jump to glyph entry */
|
2000-07-09 00:52:21 +02:00
|
|
|
p = font->fnt_frame + 118 + len * glyph_index;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
bitmap->width = NEXT_ShortLE(p);
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( new_format )
|
2000-07-07 21:46:01 +02:00
|
|
|
offset = NEXT_ULongLE(p);
|
|
|
|
else
|
|
|
|
offset = NEXT_UShortLE(p);
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* jump to glyph data */
|
2000-07-07 21:46:01 +02:00
|
|
|
p = font->fnt_frame + /* font->header.bits_offset */ + offset;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* allocate and build bitmap */
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_Memory memory = FT_FACE_MEMORY( slot->face );
|
|
|
|
FT_Int pitch = ( bitmap->width + 7 ) >> 3;
|
|
|
|
FT_Byte* column;
|
|
|
|
FT_Byte* write;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
|
|
|
bitmap->pitch = pitch;
|
|
|
|
bitmap->rows = font->header.pixel_height;
|
2000-07-07 21:46:01 +02:00
|
|
|
bitmap->pixel_mode = ft_pixel_mode_mono;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( ALLOC( bitmap->buffer, pitch * bitmap->rows ) )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
column = (FT_Byte*)bitmap->buffer;
|
|
|
|
|
|
|
|
for ( ; pitch > 0; pitch--, column++ )
|
|
|
|
{
|
|
|
|
FT_Byte* limit = p + bitmap->rows;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
for ( write = column; p < limit; p++, write += bitmap->pitch )
|
|
|
|
write[0] = p[0];
|
|
|
|
}
|
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
slot->flags = ft_glyph_own_bitmap;
|
|
|
|
slot->bitmap_left = 0;
|
|
|
|
slot->bitmap_top = font->header.ascent;
|
|
|
|
slot->format = ft_glyph_format_bitmap;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
/* now set up metrics */
|
|
|
|
slot->metrics.horiAdvance = bitmap->width << 6;
|
|
|
|
slot->metrics.horiBearingX = 0;
|
|
|
|
slot->metrics.horiBearingY = slot->bitmap_top << 6;
|
|
|
|
|
|
|
|
slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16;
|
2000-12-04 23:53:55 +01:00
|
|
|
slot->format = ft_glyph_format_bitmap;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-09 21:15:30 +02:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-11-04 02:55:49 +01:00
|
|
|
FT_CALLBACK_TABLE_DEF
|
|
|
|
const FT_Driver_Class winfnt_driver_class =
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
{
|
|
|
|
ft_module_font_driver,
|
2000-07-09 00:52:21 +02:00
|
|
|
sizeof ( FT_DriverRec ),
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
"winfonts",
|
2000-07-09 00:52:21 +02:00
|
|
|
0x10000L,
|
|
|
|
0x20000L,
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
0,
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
(FT_Module_Constructor)0,
|
|
|
|
(FT_Module_Destructor) 0,
|
|
|
|
(FT_Module_Requester) 0
|
2000-07-07 21:46:01 +02:00
|
|
|
},
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
sizeof( FNT_FaceRec ),
|
|
|
|
sizeof( FNT_SizeRec ),
|
|
|
|
sizeof( FT_GlyphSlotRec ),
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
(FTDriver_initFace) FNT_Face_Init,
|
|
|
|
(FTDriver_doneFace) FNT_Face_Done,
|
2000-07-07 21:46:01 +02:00
|
|
|
(FTDriver_initSize) 0,
|
|
|
|
(FTDriver_doneSize) 0,
|
|
|
|
(FTDriver_initGlyphSlot)0,
|
|
|
|
(FTDriver_doneGlyphSlot)0,
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
(FTDriver_setCharSizes) FNT_Size_Set_Pixels,
|
|
|
|
(FTDriver_setPixelSizes)FNT_Size_Set_Pixels,
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
(FTDriver_loadGlyph) FNT_Load_Glyph,
|
|
|
|
(FTDriver_getCharIndex) FNT_Get_Char_Index,
|
|
|
|
|
|
|
|
(FTDriver_getKerning) 0,
|
|
|
|
(FTDriver_attachFile) 0,
|
|
|
|
(FTDriver_getAdvances) 0
|
|
|
|
};
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-10-31 23:13:54 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* getDriverClass */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* This function is used when compiling the TrueType driver as a */
|
|
|
|
/* shared library (`.DLL' or `.so'). It will be used by the */
|
|
|
|
/* high-level library of FreeType to retrieve the address of the */
|
|
|
|
/* driver's generic interface. */
|
|
|
|
/* */
|
|
|
|
/* It shouldn't be implemented in a static build, as each driver must */
|
|
|
|
/* have the same function as an exported entry point. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The address of the TrueType's driver generic interface. The */
|
|
|
|
/* format-specific interface can then be retrieved through the method */
|
|
|
|
/* interface->get_format_interface. */
|
|
|
|
/* */
|
2000-11-04 02:55:49 +01:00
|
|
|
FT_EXPORT_DEF( const FT_Driver_Class* ) getDriverClass( void )
|
2000-10-31 23:13:54 +01:00
|
|
|
{
|
|
|
|
return &winfnt_driver_class;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
|
|
|
|
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
/* END */
|