2000-07-07 21:46:01 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* winfnt.c */
|
|
|
|
/* */
|
|
|
|
/* FreeType font driver for Windows FNT/FON files */
|
|
|
|
/* */
|
2013-03-14 10:27:35 +01:00
|
|
|
/* Copyright 1996-2004, 2006-2013 by */
|
2000-07-07 21:46:01 +02:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
2007-06-16 09:59:39 +02:00
|
|
|
/* Copyright 2003 Huw D M Davies for Codeweavers */
|
|
|
|
/* Copyright 2007 Dmitry Timoshkov for Codeweavers */
|
2000-07-07 21:46:01 +02:00
|
|
|
/* */
|
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>
|
2003-01-15 23:48:27 +01:00
|
|
|
#include FT_WINFONTS_H
|
2000-12-09 01:45:38 +01:00
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
2012-01-16 18:00:24 +01:00
|
|
|
#include FT_TRUETYPE_IDS_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"
|
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"
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
#include FT_SERVICE_WINFNT_H
|
|
|
|
#include FT_SERVICE_XFREE86_NAME_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
|
|
|
|
|
|
|
|
* src/autohint/ahglobal.c (blue_chars), src/winfonts/winfnt.c
(fnt_cmap_class_rec, fnt_cmap_class), src/bdf/bdflib.c (empty,
_num_bdf_properties), src/gzip/infutil.c (inflate_mask),
src/gzip/inffixed.h (fixed_bl, fixed_bd, fixed_tl, fixed_td),
src/gzip/inftrees.h (inflate_trees_fixed), srf/gzip/inftrees.c
(inflate_trees_fixed): Decorate with more `const' to avoid
writable global variables which are disallowed on ARM.
2003-10-16 00:20:56 +02:00
|
|
|
static 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
|
2002-03-14 10:01:32 +01:00
|
|
|
#define FT_STRUCTURE WinMZ_HeaderRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
* src/autohint/ahglobal.c (blue_chars), src/winfonts/winfnt.c
(fnt_cmap_class_rec, fnt_cmap_class), src/bdf/bdflib.c (empty,
_num_bdf_properties), src/gzip/infutil.c (inflate_mask),
src/gzip/inffixed.h (fixed_bl, fixed_bd, fixed_tl, fixed_td),
src/gzip/inftrees.h (inflate_trees_fixed), srf/gzip/inftrees.c
(inflate_trees_fixed): Decorate with more `const' to avoid
writable global variables which are disallowed on ARM.
2003-10-16 00:20:56 +02:00
|
|
|
static const FT_Frame_Field winne_header_fields[] =
|
2000-07-09 00:52:21 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 10:01:32 +01:00
|
|
|
#define FT_STRUCTURE WinNE_HeaderRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2007-06-16 09:59:39 +02:00
|
|
|
static const FT_Frame_Field winpe32_header_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinPE32_HeaderRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 248 ),
|
|
|
|
FT_FRAME_ULONG_LE ( magic ), /* PE00 */
|
|
|
|
FT_FRAME_USHORT_LE ( machine ), /* 0x014c - i386 */
|
|
|
|
FT_FRAME_USHORT_LE ( number_of_sections ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 12 ),
|
|
|
|
FT_FRAME_USHORT_LE ( size_of_optional_header ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 2 ),
|
|
|
|
FT_FRAME_USHORT_LE ( magic32 ), /* 0x10b */
|
|
|
|
FT_FRAME_SKIP_BYTES( 110 ),
|
|
|
|
FT_FRAME_ULONG_LE ( rsrc_virtual_address ),
|
|
|
|
FT_FRAME_ULONG_LE ( rsrc_size ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 104 ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field winpe32_section_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinPE32_SectionRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 40 ),
|
|
|
|
FT_FRAME_BYTES ( name, 8 ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 4 ),
|
|
|
|
FT_FRAME_ULONG_LE ( virtual_address ),
|
|
|
|
FT_FRAME_ULONG_LE ( size_of_raw_data ),
|
|
|
|
FT_FRAME_ULONG_LE ( pointer_to_raw_data ),
|
|
|
|
FT_FRAME_SKIP_BYTES( 16 ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field winpe_rsrc_dir_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinPE_RsrcDirRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 16 ),
|
|
|
|
FT_FRAME_ULONG_LE ( characteristics ),
|
|
|
|
FT_FRAME_ULONG_LE ( time_date_stamp ),
|
|
|
|
FT_FRAME_USHORT_LE( major_version ),
|
|
|
|
FT_FRAME_USHORT_LE( minor_version ),
|
|
|
|
FT_FRAME_USHORT_LE( number_of_named_entries ),
|
|
|
|
FT_FRAME_USHORT_LE( number_of_id_entries ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field winpe_rsrc_dir_entry_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinPE_RsrcDirEntryRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 8 ),
|
|
|
|
FT_FRAME_ULONG_LE( name ),
|
|
|
|
FT_FRAME_ULONG_LE( offset ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field winpe_rsrc_data_entry_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE WinPE_RsrcDataEntryRec
|
|
|
|
|
|
|
|
FT_FRAME_START( 16 ),
|
|
|
|
FT_FRAME_ULONG_LE( offset_to_data ),
|
|
|
|
FT_FRAME_ULONG_LE( size ),
|
|
|
|
FT_FRAME_ULONG_LE( code_page ),
|
|
|
|
FT_FRAME_ULONG_LE( reserved ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
* src/autohint/ahglobal.c (blue_chars), src/winfonts/winfnt.c
(fnt_cmap_class_rec, fnt_cmap_class), src/bdf/bdflib.c (empty,
_num_bdf_properties), src/gzip/infutil.c (inflate_mask),
src/gzip/inffixed.h (fixed_bl, fixed_bd, fixed_tl, fixed_td),
src/gzip/inftrees.h (inflate_trees_fixed), srf/gzip/inftrees.c
(inflate_trees_fixed): Decorate with more `const' to avoid
writable global variables which are disallowed on ARM.
2003-10-16 00:20:56 +02:00
|
|
|
static const FT_Frame_Field winfnt_header_fields[] =
|
2000-07-09 00:52:21 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2003-01-15 23:48:27 +01:00
|
|
|
#define FT_STRUCTURE FT_WinFNT_HeaderRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
2003-10-02 23:36:18 +02:00
|
|
|
FT_FRAME_START( 148 ),
|
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 ),
|
2003-10-02 23:36:18 +02:00
|
|
|
FT_FRAME_ULONG_LE ( color_table_offset ),
|
2003-01-15 23:48:27 +01:00
|
|
|
FT_FRAME_BYTES ( reserved1, 16 ),
|
2000-07-09 00:52:21 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static void
|
2003-07-01 09:28:55 +02:00
|
|
|
fnt_font_done( FNT_Face face )
|
2000-07-09 00:52:21 +02:00
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
FT_Memory memory = FT_FACE( face )->memory;
|
|
|
|
FT_Stream stream = FT_FACE( face )->stream;
|
|
|
|
FNT_Font font = face->font;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !font )
|
|
|
|
return;
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( font->fnt_frame )
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_RELEASE( font->fnt_frame );
|
2004-04-01 22:35:57 +02:00
|
|
|
FT_FREE( font->family_name );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
FT_FREE( font );
|
|
|
|
face->font = 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
|
2002-04-02 16:50:31 +02:00
|
|
|
fnt_font_load( FNT_Font font,
|
2001-04-25 20:11:16 +02:00
|
|
|
FT_Stream stream )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2003-01-15 23:48:27 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_WinFNT_Header header = &font->header;
|
2003-10-02 23:36:18 +02:00
|
|
|
FT_Bool new_format;
|
|
|
|
FT_UInt size;
|
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 */
|
2003-06-20 09:33:20 +02:00
|
|
|
if ( FT_STREAM_SEEK( font->offset ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* check header */
|
|
|
|
if ( header->version != 0x200 &&
|
|
|
|
header->version != 0x300 )
|
|
|
|
{
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
FT_TRACE2(( " not a Windows FNT file\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Unknown_File_Format );
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2003-10-02 23:36:18 +02:00
|
|
|
new_format = FT_BOOL( font->header.version == 0x300 );
|
|
|
|
size = new_format ? 148 : 118;
|
|
|
|
|
|
|
|
if ( header->file_size < size )
|
|
|
|
{
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
FT_TRACE2(( " not a Windows FNT file\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Unknown_File_Format );
|
2003-10-02 23:36:18 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2002-12-18 23:53:12 +01:00
|
|
|
/* Version 2 doesn't have these fields */
|
|
|
|
if ( header->version == 0x200 )
|
|
|
|
{
|
|
|
|
header->flags = 0;
|
|
|
|
header->A_space = 0;
|
|
|
|
header->B_space = 0;
|
|
|
|
header->C_space = 0;
|
|
|
|
|
|
|
|
header->color_table_offset = 0;
|
|
|
|
}
|
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( header->file_type & 1 )
|
|
|
|
{
|
2000-09-29 08:41:56 +02:00
|
|
|
FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Unknown_File_Format );
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* this is a FNT file/table; extract its frame */
|
2002-03-22 16:55:55 +01:00
|
|
|
if ( FT_STREAM_SEEK( font->offset ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
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 FT_Error
|
2003-07-01 09:28:55 +02:00
|
|
|
fnt_face_get_dll_font( FNT_Face face,
|
|
|
|
FT_Int face_index )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2002-04-02 16:50:31 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_Stream stream = FT_FACE( face )->stream;
|
|
|
|
FT_Memory memory = FT_FACE( face )->memory;
|
2002-03-14 10:01:32 +01:00
|
|
|
WinMZ_HeaderRec mz_header;
|
2000-07-07 21:46:01 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
face->font = 0;
|
2000-07-07 21:46:01 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* does it begin with an MZ header? */
|
2003-06-20 09:33:20 +02:00
|
|
|
if ( FT_STREAM_SEEK( 0 ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
error = FT_ERR( Unknown_File_Format );
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( mz_header.magic == WINFNT_MZ_MAGIC )
|
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
/* yes, now look for an NE header in the file */
|
2002-03-14 10:01:32 +01:00
|
|
|
WinNE_HeaderRec ne_header;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2007-06-16 09:59:39 +02:00
|
|
|
FT_TRACE2(( "MZ signature found\n" ));
|
|
|
|
|
2003-06-20 09:33:20 +02:00
|
|
|
if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
error = FT_ERR( Unknown_File_Format );
|
2000-07-07 21:46:01 +02:00
|
|
|
if ( ne_header.magic == WINFNT_NE_MAGIC )
|
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
/* good, now look into the resource table for each FNT resource */
|
|
|
|
FT_ULong res_offset = mz_header.lfanew +
|
|
|
|
ne_header.resource_tab_offset;
|
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
|
|
|
|
2007-06-16 09:59:39 +02:00
|
|
|
FT_TRACE2(( "NE signature found\n" ));
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( FT_STREAM_SEEK( res_offset ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_ENTER( ne_header.rname_tab_offset -
|
2002-03-22 16:55:55 +01:00
|
|
|
ne_header.resource_tab_offset ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
size_shift = FT_GET_USHORT_LE();
|
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
|
|
|
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
type_id = FT_GET_USHORT_LE();
|
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
|
|
|
|
* include/freetype/internal/ftstream.h,
src/base/ftstream.c, src/cff/cffload.c, src/pcf/pcfread.c,
src/sfnt/ttcmap.c, src/sfnt/ttcmap0.c, src/sfnt/ttload.c,
src/sfnt/ttpost.c, src/sfnt/ttsbit.c,
src/truetype/ttgload.c, src/truetype/ttpload.c,
src/winfonts/winfnt.c:
changed the definitions of stream macros. Examples:
NEXT_Byte => FT_NEXT_BYTE
NEXT_Short => FT_NEXT_SHORT
NEXT_UShortLE => FT_NEXT_USHORT_LE
READ_Short => FT_READ_SHORT
GET_Long => FT_GET_LONG
etc..
also introduced the FT_PEEK_XXXX functions..
2002-03-22 13:55:23 +01:00
|
|
|
count = FT_GET_USHORT_LE();
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( type_id == 0x8008U )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
font_count = count;
|
2002-03-20 11:49:31 +01:00
|
|
|
font_offset = (FT_ULong)( FT_STREAM_POS() + 4 +
|
2001-03-10 18:07:42 +01:00
|
|
|
( 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
|
|
|
}
|
2003-07-01 09:28:55 +02:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
if ( !font_count || !font_offset )
|
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_TRACE2(( "this file doesn't contain any FNT resources\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_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
|
|
|
|
2007-06-06 12:05:49 +02:00
|
|
|
/* loading `winfnt_header_fields' needs at least 118 bytes; */
|
|
|
|
/* use this as a rough measure to check the expected font size */
|
|
|
|
if ( font_count * 118UL > stream->size )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "invalid number of faces\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-06 12:05:49 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
face->root.num_faces = font_count;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( face_index >= font_count )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2003-07-01 09:28:55 +02:00
|
|
|
}
|
2008-05-13 14:10:04 +02:00
|
|
|
else if ( face_index < 0 )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( FT_NEW( face->font ) )
|
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) ||
|
|
|
|
FT_FRAME_ENTER( 12 ) )
|
|
|
|
goto Fail;
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2007-06-16 09:59:39 +02:00
|
|
|
face->font->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
|
|
|
|
face->font->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
stream->cursor += 8;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
FT_FRAME_EXIT();
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
error = fnt_font_load( face->font, stream );
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2007-06-16 09:59:39 +02:00
|
|
|
else if ( ne_header.magic == WINFNT_PE_MAGIC )
|
|
|
|
{
|
|
|
|
WinPE32_HeaderRec pe32_header;
|
|
|
|
WinPE32_SectionRec pe32_section;
|
|
|
|
WinPE_RsrcDirRec root_dir, name_dir, lang_dir;
|
|
|
|
WinPE_RsrcDirEntryRec dir_entry1, dir_entry2, dir_entry3;
|
|
|
|
WinPE_RsrcDataEntryRec data_entry;
|
|
|
|
|
|
|
|
FT_Long root_dir_offset, name_dir_offset, lang_dir_offset;
|
|
|
|
FT_UShort i, j, k;
|
|
|
|
|
|
|
|
|
|
|
|
FT_TRACE2(( "PE signature found\n" ));
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( mz_header.lfanew ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe32_header_fields, &pe32_header ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_TRACE2(( "magic %04lx, machine %02x, number_of_sections %u, "
|
|
|
|
"size_of_optional_header %02x\n"
|
|
|
|
"magic32 %02x, rsrc_virtual_address %04lx, "
|
|
|
|
"rsrc_size %04lx\n",
|
|
|
|
pe32_header.magic, pe32_header.machine,
|
|
|
|
pe32_header.number_of_sections,
|
|
|
|
pe32_header.size_of_optional_header,
|
|
|
|
pe32_header.magic32, pe32_header.rsrc_virtual_address,
|
|
|
|
pe32_header.rsrc_size ));
|
|
|
|
|
|
|
|
if ( pe32_header.magic != WINFNT_PE_MAGIC /* check full signature */ ||
|
|
|
|
pe32_header.machine != 0x014c /* i386 */ ||
|
|
|
|
pe32_header.size_of_optional_header != 0xe0 /* FIXME */ ||
|
|
|
|
pe32_header.magic32 != 0x10b )
|
|
|
|
{
|
2007-06-19 06:53:30 +02:00
|
|
|
FT_TRACE2(( "this file has an invalid PE header\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
face->root.num_faces = 0;
|
|
|
|
|
|
|
|
for ( i = 0; i < pe32_header.number_of_sections; i++ )
|
|
|
|
{
|
|
|
|
if ( FT_STREAM_READ_FIELDS( winpe32_section_fields,
|
|
|
|
&pe32_section ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_TRACE2(( "name %.8s, va %04lx, size %04lx, offset %04lx\n",
|
|
|
|
pe32_section.name, pe32_section.virtual_address,
|
|
|
|
pe32_section.size_of_raw_data,
|
|
|
|
pe32_section.pointer_to_raw_data ));
|
|
|
|
|
|
|
|
if ( pe32_header.rsrc_virtual_address ==
|
|
|
|
pe32_section.virtual_address )
|
|
|
|
goto Found_rsrc_section;
|
|
|
|
}
|
|
|
|
|
2007-06-19 06:53:30 +02:00
|
|
|
FT_TRACE2(( "this file doesn't contain any resources\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Found_rsrc_section:
|
|
|
|
FT_TRACE2(( "found resources section %.8s\n", pe32_section.name ));
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &root_dir ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
root_dir_offset = pe32_section.pointer_to_raw_data;
|
|
|
|
|
|
|
|
for ( i = 0; i < root_dir.number_of_named_entries +
|
|
|
|
root_dir.number_of_id_entries; i++ )
|
|
|
|
{
|
|
|
|
if ( FT_STREAM_SEEK( root_dir_offset + 16 + i * 8 ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
|
|
|
|
&dir_entry1 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( !(dir_entry1.offset & 0x80000000UL ) /* DataIsDirectory */ )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_entry1.offset &= ~0x80000000UL;
|
|
|
|
|
|
|
|
name_dir_offset = pe32_section.pointer_to_raw_data +
|
|
|
|
dir_entry1.offset;
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
|
|
|
|
dir_entry1.offset ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &name_dir ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( j = 0; j < name_dir.number_of_named_entries +
|
|
|
|
name_dir.number_of_id_entries; j++ )
|
|
|
|
{
|
|
|
|
if ( FT_STREAM_SEEK( name_dir_offset + 16 + j * 8 ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
|
|
|
|
&dir_entry2 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( !(dir_entry2.offset & 0x80000000UL ) /* DataIsDirectory */ )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir_entry2.offset &= ~0x80000000UL;
|
|
|
|
|
|
|
|
lang_dir_offset = pe32_section.pointer_to_raw_data +
|
|
|
|
dir_entry2.offset;
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( pe32_section.pointer_to_raw_data +
|
|
|
|
dir_entry2.offset ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_fields, &lang_dir ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( k = 0; k < lang_dir.number_of_named_entries +
|
|
|
|
lang_dir.number_of_id_entries; k++ )
|
|
|
|
{
|
|
|
|
if ( FT_STREAM_SEEK( lang_dir_offset + 16 + k * 8 ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_dir_entry_fields,
|
|
|
|
&dir_entry3 ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( dir_entry2.offset & 0x80000000UL /* DataIsDirectory */ )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dir_entry1.name == 8 /* RT_FONT */ )
|
|
|
|
{
|
|
|
|
if ( FT_STREAM_SEEK( root_dir_offset + dir_entry3.offset ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( winpe_rsrc_data_entry_fields,
|
|
|
|
&data_entry ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_TRACE2(( "found font #%lu, offset %04lx, "
|
|
|
|
"size %04lx, cp %lu\n",
|
|
|
|
dir_entry2.name,
|
|
|
|
pe32_section.pointer_to_raw_data +
|
|
|
|
data_entry.offset_to_data -
|
|
|
|
pe32_section.virtual_address,
|
|
|
|
data_entry.size, data_entry.code_page ));
|
|
|
|
|
|
|
|
if ( face_index == face->root.num_faces )
|
|
|
|
{
|
|
|
|
if ( FT_NEW( face->font ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
face->font->offset = pe32_section.pointer_to_raw_data +
|
|
|
|
data_entry.offset_to_data -
|
|
|
|
pe32_section.virtual_address;
|
|
|
|
face->font->fnt_size = data_entry.size;
|
|
|
|
|
|
|
|
error = fnt_font_load( face->font, stream );
|
|
|
|
if ( error )
|
2007-06-17 13:27:17 +02:00
|
|
|
{
|
2007-06-16 09:59:39 +02:00
|
|
|
FT_TRACE2(( "font #%lu load error %d\n",
|
|
|
|
dir_entry2.name, error ));
|
2007-06-17 13:27:17 +02:00
|
|
|
goto Fail;
|
|
|
|
}
|
2007-06-16 09:59:39 +02:00
|
|
|
else
|
|
|
|
FT_TRACE2(( "font #%lu successfully loaded\n",
|
|
|
|
dir_entry2.name ));
|
|
|
|
}
|
|
|
|
|
|
|
|
face->root.num_faces++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-19 06:53:30 +02:00
|
|
|
if ( !face->root.num_faces )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-19 06:53:30 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2007-06-16 09:59:39 +02:00
|
|
|
if ( face_index >= face->root.num_faces )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2007-06-16 09:59:39 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Fail:
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( error )
|
2003-07-01 09:28:55 +02:00
|
|
|
fnt_font_done( face );
|
2000-07-07 21:46:01 +02:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
typedef struct FNT_CMapRec_
|
2002-03-01 03:26:22 +01:00
|
|
|
{
|
|
|
|
FT_CMapRec cmap;
|
|
|
|
FT_UInt32 first;
|
|
|
|
FT_UInt32 count;
|
|
|
|
|
|
|
|
} FNT_CMapRec, *FNT_CMap;
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2002-03-22 18:09:52 +01:00
|
|
|
fnt_cmap_init( FNT_CMap cmap )
|
2002-03-01 03:26:22 +01:00
|
|
|
{
|
2002-04-02 16:50:31 +02:00
|
|
|
FNT_Face face = (FNT_Face)FT_CMAP_FACE( cmap );
|
2003-07-01 09:28:55 +02:00
|
|
|
FNT_Font font = face->font;
|
2002-03-01 03:26:22 +01:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
|
|
|
|
cmap->first = (FT_UInt32) font->header.first_char;
|
|
|
|
cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 );
|
2002-03-01 03:26:22 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_UInt
|
2002-03-22 18:09:52 +01:00
|
|
|
fnt_cmap_char_index( FNT_CMap cmap,
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_UInt32 char_code )
|
|
|
|
{
|
2002-03-20 10:42:31 +01:00
|
|
|
FT_UInt gindex = 0;
|
2002-03-01 03:26:22 +01:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
char_code -= cmap->first;
|
|
|
|
if ( char_code < cmap->count )
|
* src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 23:50:24 +01:00
|
|
|
/* we artificially increase the glyph index; */
|
|
|
|
/* FNT_Load_Glyph reverts to the right one */
|
|
|
|
gindex = (FT_UInt)( char_code + 1 );
|
2002-03-01 03:26:22 +01:00
|
|
|
return gindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-31 17:32:09 +02:00
|
|
|
static FT_UInt32
|
2002-04-02 16:50:31 +02:00
|
|
|
fnt_cmap_char_next( FNT_CMap cmap,
|
|
|
|
FT_UInt32 *pchar_code )
|
2002-03-01 03:26:22 +01:00
|
|
|
{
|
|
|
|
FT_UInt gindex = 0;
|
|
|
|
FT_UInt32 result = 0;
|
2002-03-22 16:55:55 +01:00
|
|
|
FT_UInt32 char_code = *pchar_code + 1;
|
2002-03-01 03:26:22 +01:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
if ( char_code <= cmap->first )
|
|
|
|
{
|
|
|
|
result = cmap->first;
|
|
|
|
gindex = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char_code -= cmap->first;
|
|
|
|
if ( char_code < cmap->count )
|
|
|
|
{
|
|
|
|
result = cmap->first + char_code;
|
* src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 23:50:24 +01:00
|
|
|
gindex = (FT_UInt)( char_code + 1 );
|
2002-03-01 03:26:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-22 16:55:55 +01:00
|
|
|
*pchar_code = result;
|
|
|
|
return gindex;
|
2002-03-01 03:26:22 +01:00
|
|
|
}
|
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
|
* src/autohint/ahglobal.c (blue_chars), src/winfonts/winfnt.c
(fnt_cmap_class_rec, fnt_cmap_class), src/bdf/bdflib.c (empty,
_num_bdf_properties), src/gzip/infutil.c (inflate_mask),
src/gzip/inffixed.h (fixed_bl, fixed_bd, fixed_tl, fixed_td),
src/gzip/inftrees.h (inflate_trees_fixed), srf/gzip/inftrees.c
(inflate_trees_fixed): Decorate with more `const' to avoid
writable global variables which are disallowed on ARM.
2003-10-16 00:20:56 +02:00
|
|
|
static const FT_CMap_ClassRec fnt_cmap_class_rec =
|
2002-03-01 03:26:22 +01:00
|
|
|
{
|
2002-04-02 16:50:31 +02:00
|
|
|
sizeof ( FNT_CMapRec ),
|
|
|
|
|
|
|
|
(FT_CMap_InitFunc) fnt_cmap_init,
|
|
|
|
(FT_CMap_DoneFunc) NULL,
|
|
|
|
(FT_CMap_CharIndexFunc)fnt_cmap_char_index,
|
Add support for cmap type 14.
* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_CMAP_FORMAT_14): New macro.
* include/freetype/internal/ftobjs.h (FT_CMap_CharVarIndexFunc,
FT_CMap_CharVarIsDefaultFunc, FT_CMap_VariantListFunc,
FT_CMap_CharVariantListFunc, FT_CMap_VariantCharListFunc): New
support function prototypes.
(FT_CMap_ClassRec): Add them.
Update all users.
* include/freetype/ttnameid.h (TT_APPLE_ID_VARIANT_SELECTOR): New
macro.
* include/freetype/freetype.h (FT_Get_Char_Variant_Index,
FT_Get_Char_Variant_IsDefault, FT_Get_Variant_Selectors,
FT_Get_Variants_Of_Char, FT_Get_Chars_Of_Variant): New API
functions.
* src/base/ftobjs.c (find_variant_selector_charmap): New auxiliary
function.
(FT_Set_Charmap): Disallow cmaps of type 14.
(FT_Get_Char_Variant_Index, FT_Get_Char_Variant_IsDefault,
FT_Get_Variant_Selectors, FT_Get_Variants_Of_Char,
FT_Get_Chars_Of_Variant): New API functions.
* src/sfnt/ttcmap.c (TT_PEEK_UINT24, TT_NEXT_UINT24): New macros.
(TT_CMap14Rec, tt_cmap14_init, tt_cmap14_validate,
tt_cmap14_char_index, tt_cmap14_char_next, tt_cmap14_get_info,
tt_cmap14_char_map_def_binary, tt_cmap14_char_map_nondef_binary,
tt_cmap14_find_variant, tt_cmap14_char_var_index,
tt_cmap14_char_var_isdefault, tt_cmap14_variants,
tt_cmap14_char_variants, tt_cmap14_def_char_count,
tt_cmap14_get_def_chars, tt_cmap14_get_nondef_chars,
tt_cmap14_variant_chars, tt_cmap14_class_rec): New functions and
structures for cmap 14 support.
(tt_cmap_classes): Register tt_cmap14_class_rec.
(tt_face_build_cmaps): One more error message.
* docs/CHANGES: Mention cmap 14 support.
2007-10-15 19:21:32 +02:00
|
|
|
(FT_CMap_CharNextFunc) fnt_cmap_char_next,
|
|
|
|
|
|
|
|
NULL, NULL, NULL, NULL, NULL
|
2002-03-01 03:26:22 +01:00
|
|
|
};
|
|
|
|
|
2003-10-21 08:53:19 +02:00
|
|
|
static FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec;
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static void
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Face_Done( FT_Face fntface ) /* FNT_Face */
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Face face = (FNT_Face)fntface;
|
2008-10-02 00:39:05 +02:00
|
|
|
FT_Memory memory;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2008-10-02 00:39:05 +02:00
|
|
|
if ( !face )
|
|
|
|
return;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2008-10-02 00:39:05 +02:00
|
|
|
memory = FT_FACE_MEMORY( face );
|
|
|
|
|
|
|
|
fnt_font_done( face );
|
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
FT_FREE( fntface->available_sizes );
|
|
|
|
fntface->num_fixed_sizes = 0;
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
|
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,
|
2011-11-30 13:55:56 +01:00
|
|
|
FT_Face fntface, /* FNT_Face */
|
2001-04-25 20:11:16 +02:00
|
|
|
FT_Int face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Face face = (FNT_Face)fntface;
|
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 );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
Improve tracing.
* src/bdf/bdfdrivr.c (BDF_Face_Done), src/pcf/pcfdrivr.c
(PCF_Face_Done): Remove tracing message.
* src/bdf/bdfdrivr.c (BDF_Face_Init), src/cff/cffobjs.c
(cff_face_init), src/cid/cidobjs.c (cid_face_init),
src/pfr/pfrobjs.c (pfr_face_init), src/sfnt/sfobjs.c
(sfnt_init_face), src/truetype/ttobjs.c (tt_face_init),
src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c
(T42_Face_Init), src/winfonts/winfnt.c (FNT_Face_Init): Add
`greeting' message.
* src/sfnt/sfobjs.c (sfnt_open_font), src/type42/t42objs.c
(T42_Open_Face): Improve tracing.
2011-11-26 20:09:39 +01:00
|
|
|
FT_TRACE2(( "Windows FNT driver\n" ));
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* try to load font from a DLL */
|
|
|
|
error = fnt_face_get_dll_font( face, face_index );
|
2008-05-13 14:10:04 +02:00
|
|
|
if ( !error && face_index < 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( FT_ERR_EQ( error, Unknown_File_Format ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
/* this didn't work; try to load a single FNT font */
|
2002-03-14 10:01:32 +01:00
|
|
|
FNT_Font font;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( FT_NEW( face->font ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
fntface->num_faces = 1;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
font = face->font;
|
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 );
|
2007-10-29 23:00:58 +01:00
|
|
|
|
2008-05-13 14:10:04 +02:00
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
if ( face_index > 0 )
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2008-05-13 14:10:04 +02:00
|
|
|
else if ( face_index < 0 )
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
|
2007-06-19 06:53:30 +02:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* we now need to fill the root FT_Face fields */
|
|
|
|
/* with relevant information */
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2004-04-01 22:35:57 +02:00
|
|
|
FT_Face root = FT_FACE( face );
|
|
|
|
FNT_Font font = face->font;
|
|
|
|
FT_PtrDist family_size;
|
2000-07-09 00:52:21 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
|
2008-12-26 00:52:00 +01:00
|
|
|
root->face_index = face_index;
|
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
|
|
|
|
FT_FACE_FLAG_HORIZONTAL;
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( font->header.avg_width == font->header.max_width )
|
2000-07-07 21:46:01 +02:00
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( font->header.italic )
|
2000-07-07 21:46:01 +02:00
|
|
|
root->style_flags |= FT_STYLE_FLAG_ITALIC;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
if ( font->header.weight >= 800 )
|
2000-07-07 21:46:01 +02:00
|
|
|
root->style_flags |= FT_STYLE_FLAG_BOLD;
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* set up the `fixed_sizes' array */
|
|
|
|
if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Fail;
|
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
root->num_fixed_sizes = 1;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
FT_Bitmap_Size* bsize = root->available_sizes;
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
FT_UShort x_res, y_res;
|
2003-07-01 09:28:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
bsize->width = font->header.avg_width;
|
* include/freetype/internal/ftserv.h,
include/freetype/internal/service/svpfr.h,
include/freetype/internal/pfr.h,
src/base/ftpfr.c:
migrating the functions of "ftpfr.h" to the new
service-base internal API
* src/cff/cffobjs.c, src/cid/cidobjs.c, src/pfr/pfrsbit.c,
src/psaux/psobjs.c, src/sfnt/sfdriver.c, src/sfnt/sfobjs.c,
src/truetype/ttobjs.c, src/type1/t1driver.c, src/type1/t1objs.c,
src/type42/t42objs.c, src/winfonts/winfnt.c:
removing various compiler warnings
2003-09-21 18:04:05 +02:00
|
|
|
bsize->height = (FT_Short)(
|
|
|
|
font->header.pixel_height + font->header.external_leading );
|
2003-07-01 09:28:55 +02:00
|
|
|
bsize->size = font->header.nominal_point_size << 6;
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
|
|
|
|
x_res = font->header.horizontal_resolution;
|
|
|
|
if ( !x_res )
|
|
|
|
x_res = 72;
|
|
|
|
|
|
|
|
y_res = font->header.vertical_resolution;
|
|
|
|
if ( !y_res )
|
|
|
|
y_res = 72;
|
|
|
|
|
|
|
|
bsize->y_ppem = FT_MulDiv( bsize->size, y_res, 72 );
|
|
|
|
bsize->y_ppem = FT_PIX_ROUND( bsize->y_ppem );
|
|
|
|
|
* builds/amiga/src/base/ftsystem.c, devel/ftoption.h
include/freetype/ftcache.h, include/freetype/ftoutln.h,
include/freetype/cache/ftccache.h, include/freetype/cache/ftccmap.h,
include/freetype/config/ftoption.h, include/freetype/internal/ftcalc.h,
include/freetype/internal/ftdriver.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h, include/freetype/internal/ftrfork.h,
include/freetype/internal/psaux.h, include/freetype/internal/sfnt.h,
include/freetype/internal/t1types.h, include/freetype/internal/tttypes.h,
src/base/ftcalc.c, src/base/ftdbgmem.c, src/base/ftobjs.c,
src/base/ftsystem.c, src/base/ftutil.c, src/bdf/bdfdrivr.c,
src/cache/ftccache.c, src/cache/ftccback.h, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffdrivr.c, src/cid/cidriver.c,
src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c, src/psaux/psauxmod.c,
src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type42/t42drivr.c, src/winfonts/winfnt.c:
massive changes to the internals to respect the internal object layouts
and exported functions of FreeType 2.1.7. Note that the cache sub-system
cannot be fully retrofitted, unfortunately.
2006-02-16 23:45:31 +01:00
|
|
|
/*
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
* this reads:
|
|
|
|
*
|
|
|
|
* the nominal height is larger than the bbox's height
|
|
|
|
*
|
|
|
|
* => nominal_point_size contains incorrect value;
|
|
|
|
* use pixel_height as the nominal height
|
|
|
|
*/
|
* src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 23:50:24 +01:00
|
|
|
if ( bsize->y_ppem > ( font->header.pixel_height << 6 ) )
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
{
|
2006-01-14 06:09:30 +01:00
|
|
|
FT_TRACE2(( "use pixel_height as the nominal height\n" ));
|
|
|
|
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
bsize->y_ppem = font->header.pixel_height << 6;
|
|
|
|
bsize->size = FT_MulDiv( bsize->y_ppem, 72, y_res );
|
|
|
|
}
|
|
|
|
|
|
|
|
bsize->x_ppem = FT_MulDiv( bsize->size, x_res, 72 );
|
|
|
|
bsize->x_ppem = FT_PIX_ROUND( bsize->x_ppem );
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
{
|
|
|
|
FT_CharMapRec charmap;
|
|
|
|
|
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in
computation of glyph_index.
(FNT_Size_Set_Pixels): To find a strike, first check pixel_height
only, then try to find a better hit by comparing pixel_width also.
Without this fix it isn't possible to access all strikes.
Also compute metrics.max_advance to be in sync with other bitmap
drivers.
* src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code.
(FT_Set_Pixel_Size): Assign value to `metrics' after validation of
arguments.
Synchronize computation of height and width for bitmap strikes. The
`width' field in the FT_Bitmap_Size structure is now only useful to
enumerate different strikes. The `max_advance' field of the
FT_Size_Metrics structure should be used to get the (maximum) width
of a strike.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single
argument to function.
* src/psnames/psmodule.c (ps_unicode_value): Handle `.' after
`uniXXXX' and `uXXXX[X[X]]'.
* src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/.
* src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c:
s/FT_Err_/FTC_Err_/.
* src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/.
* src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/.
* src/psaux/t1cmap.c: Include psauxerr.h.
s/FT_Err_/PSaux_Err_/.
* src/pshinter/pshnterr.h: New file.
* src/pshinter/rules.mk: Updated.
* src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h.
s/FT_Err_/PSH_Err_/.
* src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c:
s/FT_Err_/PFR_Err_/.
* src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/.
* src/truetype/ttgload.c: s/FT_Err_/TT_Err_/.
* src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define
FT_ERR_PREFIX and FT_ERR_BASE.
s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
|
|
|
|
2003-12-23 00:01:20 +01:00
|
|
|
charmap.encoding = FT_ENCODING_NONE;
|
2010-07-09 05:26:33 +02:00
|
|
|
/* initial platform/encoding should indicate unset status? */
|
|
|
|
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
|
|
|
|
charmap.encoding_id = TT_APPLE_ID_DEFAULT;
|
2002-03-01 03:26:22 +01:00
|
|
|
charmap.face = root;
|
|
|
|
|
2003-12-23 00:01:20 +01:00
|
|
|
if ( font->header.charset == FT_WinFNT_ID_MAC )
|
|
|
|
{
|
|
|
|
charmap.encoding = FT_ENCODING_APPLE_ROMAN;
|
2010-07-09 05:26:33 +02:00
|
|
|
charmap.platform_id = TT_PLATFORM_MACINTOSH;
|
|
|
|
/* charmap.encoding_id = TT_MAC_ID_ROMAN; */
|
2003-12-23 00:01:20 +01:00
|
|
|
}
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
error = FT_CMap_New( fnt_cmap_class,
|
|
|
|
NULL,
|
|
|
|
&charmap,
|
|
|
|
NULL );
|
2002-06-19 17:57:55 +02:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
/* Select default charmap */
|
|
|
|
if ( root->num_charmaps )
|
|
|
|
root->charmap = root->charmaps[0];
|
2002-03-01 03:26:22 +01:00
|
|
|
}
|
|
|
|
|
2012-03-01 16:11:33 +01:00
|
|
|
/* set up remaining flags */
|
|
|
|
|
|
|
|
if ( font->header.last_char < font->header.first_char )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "invalid number of glyphs\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2012-03-01 16:11:33 +01:00
|
|
|
goto Fail;
|
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-07-01 09:28:55 +02:00
|
|
|
/* reserve one slot for the .notdef glyph at index 0 */
|
|
|
|
root->num_glyphs = font->header.last_char -
|
2006-05-02 11:00:29 +02:00
|
|
|
font->header.first_char + 1 + 1;
|
2003-07-01 09:28:55 +02:00
|
|
|
|
2007-06-05 09:32:15 +02:00
|
|
|
if ( font->header.face_name_offset >= font->header.file_size )
|
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_TRACE2(( "invalid family name offset\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-05 09:32:15 +02:00
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
family_size = font->header.file_size - font->header.face_name_offset;
|
2004-04-01 22:35:57 +02:00
|
|
|
/* Some broken fonts don't delimit the face name with a final */
|
|
|
|
/* NULL byte -- the frame is erroneously one byte too small. */
|
|
|
|
/* We thus allocate one more byte, setting it explicitly to */
|
|
|
|
/* zero. */
|
|
|
|
if ( FT_ALLOC( font->family_name, family_size + 1 ) )
|
|
|
|
goto Fail;
|
2006-05-02 11:00:29 +02:00
|
|
|
|
2004-04-01 22:35:57 +02:00
|
|
|
FT_MEM_COPY( font->family_name,
|
|
|
|
font->fnt_frame + font->header.face_name_offset,
|
|
|
|
family_size );
|
2006-05-02 11:00:29 +02:00
|
|
|
|
2004-04-01 22:35:57 +02:00
|
|
|
font->family_name[family_size] = '\0';
|
2006-05-02 11:00:29 +02:00
|
|
|
|
2004-04-01 22:35:57 +02:00
|
|
|
if ( FT_REALLOC( font->family_name,
|
|
|
|
family_size,
|
|
|
|
ft_strlen( font->family_name ) + 1 ) )
|
|
|
|
goto Fail;
|
2006-05-02 11:00:29 +02:00
|
|
|
|
2004-04-01 22:35:57 +02:00
|
|
|
root->family_name = font->family_name;
|
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
|
|
|
}
|
2004-04-01 22:35:57 +02:00
|
|
|
goto Exit;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-07 21:46:01 +02:00
|
|
|
Fail:
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Face_Done( fntface );
|
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
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Size_Select( FT_Size size,
|
|
|
|
FT_ULong strike_index )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
* include/freetype/freetype.h (FT_Select_Size): Rename the second
argument from `idx' to `strike_index'.
(FT_Size_Request_Type): Add FT_SIZE_REQUEST_TYPE_MAX to the end of
this enum.
* include/freetype/internal/ftobjs.h (FT_REQUEST_WIDTH,
FT_REQUEST_HEIGHT): New macros to get the width and height of a
request, in fractional pixels.
* include/freetype/internal/ftobjs.h (FT_Select_Metrics,
FT_Request_Metrics), src/base/ftobjs.c (FT_Select_Metrics,
FT_Request_Metrics): New base functions to set the font metrics. They
were part of FT_Select_Size/FT_Request_Size and are made independent
functions so that metrics are not set again and again.
* src/base/ftobjs.c (FT_Select_Size, FT_Request_Size): Metrics are set
only when driver's size_select/size_request is NULL. That is, drivers
should set the metrics themselves.
(FT_Match_Size): Round before matching. This was what we did and it
does cause some problems without rounding.
* src/cff/cffobjs.c (cff_size_select), src/truetype/ttdriver.c
(tt_size_select): Set the font metrics.
s/index/strike_index/.
The scaled metrics are always preferred over strikes' metrics, even
when some strike is selected. This is done because the strikes'
metrics are not reliable, e.g., the sign of the descender is wrong for
some fonts.
* src/cff/cffobjs.c (cff_size_request), src/truetype/ttdriver.c
(tt_size_request): Set the font metrics.
Call cff_size_select/tt_size_select when some strike is matched.
* src/bdf/bdfdrivr.c, src/cff/cffobjs.c, src/cid/cidobjs.c,
src/pcf/pcfdrivr.c, src/truetype/ttdriver.c, src/type1/t1objs.c,
src/type1/t1objs.h, src/type42/t42objs.c, src/winfonts/winfnt.c:
Set the font metrics.
s/index/strike_index/.
* src/tools/test_afm.c, src/psaux/psconv.c: Older versions of these
files were committed. Just a catch-up.
(PS_Conv_ToFixed): Remove the `goto'.
(PS_Conv_ASCIIHexDecode, PS_Conv_EexecDecode): Speed up a little.
* src/sfnt/ttsbit.c (tt_face_load_sbit_strikes,
tt_face_load_strike_metrics), src/sfnt/ttsbit0.c
(tt_face_load_sbit_strikes, tt_face_load_strike_metrics): The
advertised metrics in `available_sizes' are different from those
actually used.
2006-01-23 15:12:40 +01:00
|
|
|
FNT_Face face = (FNT_Face)size->face;
|
|
|
|
FT_WinFNT_Header header = &face->font->header;
|
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
FT_UNUSED( strike_index );
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
* include/freetype/freetype.h (FT_Select_Size): Rename the second
argument from `idx' to `strike_index'.
(FT_Size_Request_Type): Add FT_SIZE_REQUEST_TYPE_MAX to the end of
this enum.
* include/freetype/internal/ftobjs.h (FT_REQUEST_WIDTH,
FT_REQUEST_HEIGHT): New macros to get the width and height of a
request, in fractional pixels.
* include/freetype/internal/ftobjs.h (FT_Select_Metrics,
FT_Request_Metrics), src/base/ftobjs.c (FT_Select_Metrics,
FT_Request_Metrics): New base functions to set the font metrics. They
were part of FT_Select_Size/FT_Request_Size and are made independent
functions so that metrics are not set again and again.
* src/base/ftobjs.c (FT_Select_Size, FT_Request_Size): Metrics are set
only when driver's size_select/size_request is NULL. That is, drivers
should set the metrics themselves.
(FT_Match_Size): Round before matching. This was what we did and it
does cause some problems without rounding.
* src/cff/cffobjs.c (cff_size_select), src/truetype/ttdriver.c
(tt_size_select): Set the font metrics.
s/index/strike_index/.
The scaled metrics are always preferred over strikes' metrics, even
when some strike is selected. This is done because the strikes'
metrics are not reliable, e.g., the sign of the descender is wrong for
some fonts.
* src/cff/cffobjs.c (cff_size_request), src/truetype/ttdriver.c
(tt_size_request): Set the font metrics.
Call cff_size_select/tt_size_select when some strike is matched.
* src/bdf/bdfdrivr.c, src/cff/cffobjs.c, src/cid/cidobjs.c,
src/pcf/pcfdrivr.c, src/truetype/ttdriver.c, src/type1/t1objs.c,
src/type1/t1objs.h, src/type42/t42objs.c, src/winfonts/winfnt.c:
Set the font metrics.
s/index/strike_index/.
* src/tools/test_afm.c, src/psaux/psconv.c: Older versions of these
files were committed. Just a catch-up.
(PS_Conv_ToFixed): Remove the `goto'.
(PS_Conv_ASCIIHexDecode, PS_Conv_EexecDecode): Speed up a little.
* src/sfnt/ttsbit.c (tt_face_load_sbit_strikes,
tt_face_load_strike_metrics), src/sfnt/ttsbit0.c
(tt_face_load_sbit_strikes, tt_face_load_strike_metrics): The
advertised metrics in `available_sizes' are different from those
actually used.
2006-01-23 15:12:40 +01:00
|
|
|
FT_Select_Metrics( size->face, 0 );
|
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in
computation of glyph_index.
(FNT_Size_Set_Pixels): To find a strike, first check pixel_height
only, then try to find a better hit by comparing pixel_width also.
Without this fix it isn't possible to access all strikes.
Also compute metrics.max_advance to be in sync with other bitmap
drivers.
* src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code.
(FT_Set_Pixel_Size): Assign value to `metrics' after validation of
arguments.
Synchronize computation of height and width for bitmap strikes. The
`width' field in the FT_Bitmap_Size structure is now only useful to
enumerate different strikes. The `max_advance' field of the
FT_Size_Metrics structure should be used to get the (maximum) width
of a strike.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single
argument to function.
* src/psnames/psmodule.c (ps_unicode_value): Handle `.' after
`uniXXXX' and `uXXXX[X[X]]'.
* src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/.
* src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c:
s/FT_Err_/FTC_Err_/.
* src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/.
* src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/.
* src/psaux/t1cmap.c: Include psauxerr.h.
s/FT_Err_/PSaux_Err_/.
* src/pshinter/pshnterr.h: New file.
* src/pshinter/rules.mk: Updated.
* src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h.
s/FT_Err_/PSH_Err_/.
* src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c:
s/FT_Err_/PFR_Err_/.
* src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/.
* src/truetype/ttgload.c: s/FT_Err_/TT_Err_/.
* src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define
FT_ERR_PREFIX and FT_ERR_BASE.
s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
|
|
|
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
size->metrics.ascender = header->ascent * 64;
|
|
|
|
size->metrics.descender = -( header->pixel_height -
|
|
|
|
header->ascent ) * 64;
|
|
|
|
size->metrics.max_advance = header->max_width * 64;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
|
* src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in
computation of glyph_index.
(FNT_Size_Set_Pixels): To find a strike, first check pixel_height
only, then try to find a better hit by comparing pixel_width also.
Without this fix it isn't possible to access all strikes.
Also compute metrics.max_advance to be in sync with other bitmap
drivers.
* src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code.
(FT_Set_Pixel_Size): Assign value to `metrics' after validation of
arguments.
Synchronize computation of height and width for bitmap strikes. The
`width' field in the FT_Bitmap_Size structure is now only useful to
enumerate different strikes. The `max_advance' field of the
FT_Size_Metrics structure should be used to get the (maximum) width
of a strike.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for
computing `available_sizes->width' but make it always equal to
`available_sizes->height'.
* src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single
argument to function.
* src/psnames/psmodule.c (ps_unicode_value): Handle `.' after
`uniXXXX' and `uXXXX[X[X]]'.
* src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/.
* src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c:
s/FT_Err_/FTC_Err_/.
* src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/.
* src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/.
* src/psaux/t1cmap.c: Include psauxerr.h.
s/FT_Err_/PSaux_Err_/.
* src/pshinter/pshnterr.h: New file.
* src/pshinter/rules.mk: Updated.
* src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h.
s/FT_Err_/PSH_Err_/.
* src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c:
s/FT_Err_/PFR_Err_/.
* src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c,
src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/.
* src/truetype/ttgload.c: s/FT_Err_/TT_Err_/.
* src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define
FT_ERR_PREFIX and FT_ERR_BASE.
s/FT_Err_/Gzip_Err_/.
2003-06-22 17:33:53 +02:00
|
|
|
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
static FT_Error
|
|
|
|
FNT_Size_Request( FT_Size size,
|
|
|
|
FT_Size_Request req )
|
|
|
|
{
|
2006-01-14 06:09:30 +01:00
|
|
|
FNT_Face face = (FNT_Face)size->face;
|
|
|
|
FT_WinFNT_Header header = &face->font->header;
|
|
|
|
FT_Bitmap_Size* bsize = size->face->available_sizes;
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_Error error = FT_ERR( Invalid_Pixel_Size );
|
2006-01-14 06:09:30 +01:00
|
|
|
FT_Long height;
|
2006-01-13 15:53:28 +01:00
|
|
|
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
|
* include/freetype/freetype.h (FT_Select_Size): Rename the second
argument from `idx' to `strike_index'.
(FT_Size_Request_Type): Add FT_SIZE_REQUEST_TYPE_MAX to the end of
this enum.
* include/freetype/internal/ftobjs.h (FT_REQUEST_WIDTH,
FT_REQUEST_HEIGHT): New macros to get the width and height of a
request, in fractional pixels.
* include/freetype/internal/ftobjs.h (FT_Select_Metrics,
FT_Request_Metrics), src/base/ftobjs.c (FT_Select_Metrics,
FT_Request_Metrics): New base functions to set the font metrics. They
were part of FT_Select_Size/FT_Request_Size and are made independent
functions so that metrics are not set again and again.
* src/base/ftobjs.c (FT_Select_Size, FT_Request_Size): Metrics are set
only when driver's size_select/size_request is NULL. That is, drivers
should set the metrics themselves.
(FT_Match_Size): Round before matching. This was what we did and it
does cause some problems without rounding.
* src/cff/cffobjs.c (cff_size_select), src/truetype/ttdriver.c
(tt_size_select): Set the font metrics.
s/index/strike_index/.
The scaled metrics are always preferred over strikes' metrics, even
when some strike is selected. This is done because the strikes'
metrics are not reliable, e.g., the sign of the descender is wrong for
some fonts.
* src/cff/cffobjs.c (cff_size_request), src/truetype/ttdriver.c
(tt_size_request): Set the font metrics.
Call cff_size_select/tt_size_select when some strike is matched.
* src/bdf/bdfdrivr.c, src/cff/cffobjs.c, src/cid/cidobjs.c,
src/pcf/pcfdrivr.c, src/truetype/ttdriver.c, src/type1/t1objs.c,
src/type1/t1objs.h, src/type42/t42objs.c, src/winfonts/winfnt.c:
Set the font metrics.
s/index/strike_index/.
* src/tools/test_afm.c, src/psaux/psconv.c: Older versions of these
files were committed. Just a catch-up.
(PS_Conv_ToFixed): Remove the `goto'.
(PS_Conv_ASCIIHexDecode, PS_Conv_EexecDecode): Speed up a little.
* src/sfnt/ttsbit.c (tt_face_load_sbit_strikes,
tt_face_load_strike_metrics), src/sfnt/ttsbit0.c
(tt_face_load_sbit_strikes, tt_face_load_strike_metrics): The
advertised metrics in `available_sizes' are different from those
actually used.
2006-01-23 15:12:40 +01:00
|
|
|
height = FT_REQUEST_HEIGHT( req );
|
2006-01-14 06:09:30 +01:00
|
|
|
height = ( height + 32 ) >> 6;
|
|
|
|
|
|
|
|
switch ( req->type )
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
{
|
2006-01-14 06:09:30 +01:00
|
|
|
case FT_SIZE_REQUEST_TYPE_NOMINAL:
|
* src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 23:50:24 +01:00
|
|
|
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2006-01-14 06:09:30 +01:00
|
|
|
break;
|
2006-01-14 08:10:45 +01:00
|
|
|
|
2006-01-14 06:09:30 +01:00
|
|
|
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
|
|
|
|
if ( height == header->pixel_height )
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2006-01-14 06:09:30 +01:00
|
|
|
break;
|
2006-01-14 08:10:45 +01:00
|
|
|
|
2006-01-14 06:09:30 +01:00
|
|
|
default:
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Unimplemented_Feature );
|
2006-01-14 06:09:30 +01:00
|
|
|
break;
|
|
|
|
}
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
|
2006-01-14 06:09:30 +01:00
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
else
|
2011-11-30 13:55:56 +01:00
|
|
|
return FNT_Size_Select( size, 0 );
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
static FT_Error
|
|
|
|
FNT_Load_Glyph( FT_GlyphSlot slot,
|
2003-07-01 09:28:55 +02:00
|
|
|
FT_Size size,
|
2001-04-25 20:11:16 +02:00
|
|
|
FT_UInt glyph_index,
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
FT_Int32 load_flags )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2003-07-01 09:28:55 +02:00
|
|
|
FNT_Face face = (FNT_Face)FT_SIZE_FACE( size );
|
2010-09-13 07:32:22 +02:00
|
|
|
FNT_Font font;
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-07-09 00:52:21 +02:00
|
|
|
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( load_flags );
|
|
|
|
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2010-09-13 07:32:22 +02:00
|
|
|
if ( !face )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2010-09-13 07:32:22 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
font = face->font;
|
|
|
|
|
|
|
|
if ( !font ||
|
2006-11-19 10:19:17 +01:00
|
|
|
glyph_index >= (FT_UInt)( FT_FACE( face )->num_glyphs ) )
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-07-07 21:46:01 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2000-07-20 08:57:41 +02:00
|
|
|
if ( glyph_index > 0 )
|
2003-07-01 09:28:55 +02:00
|
|
|
glyph_index--; /* revert to real index */
|
2000-07-19 22:17:37 +02:00
|
|
|
else
|
2003-07-01 09:28:55 +02:00
|
|
|
glyph_index = font->header.default_char; /* the .notdef glyph */
|
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 */
|
2003-10-02 23:36:18 +02:00
|
|
|
p = font->fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
bitmap->width = FT_NEXT_SHORT_LE( p );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
if ( new_format )
|
2002-04-02 16:50:31 +02:00
|
|
|
offset = FT_NEXT_ULONG_LE( p );
|
2000-07-07 21:46:01 +02:00
|
|
|
else
|
2002-04-02 16:50:31 +02:00
|
|
|
offset = FT_NEXT_USHORT_LE( p );
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-10-02 23:36:18 +02:00
|
|
|
if ( offset >= font->header.file_size )
|
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_TRACE2(( "invalid FNT offset\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2003-10-02 23:36:18 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2003-06-02 09:24:33 +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;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2013-06-27 17:21:59 +02:00
|
|
|
if ( offset + pitch * bitmap->rows > font->header.file_size )
|
2007-06-17 13:27:17 +02:00
|
|
|
{
|
|
|
|
FT_TRACE2(( "invalid bitmap width\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2007-06-17 13:27:17 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2003-06-02 09:24:33 +02:00
|
|
|
/* note: since glyphs are stored in columns and not in rows we */
|
|
|
|
/* can't use ft_glyphslot_set_bitmap */
|
2006-05-02 11:00:29 +02:00
|
|
|
if ( FT_ALLOC_MULT( bitmap->buffer, pitch, bitmap->rows ) )
|
2003-06-02 09:24:33 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
column = (FT_Byte*)bitmap->buffer;
|
|
|
|
|
|
|
|
for ( ; pitch > 0; pitch--, column++ )
|
|
|
|
{
|
|
|
|
FT_Byte* limit = p + bitmap->rows;
|
|
|
|
|
|
|
|
|
|
|
|
for ( write = column; p < limit; p++, write += bitmap->pitch )
|
|
|
|
*write = *p;
|
|
|
|
}
|
2000-07-07 21:46:01 +02:00
|
|
|
}
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2003-06-18 08:59:57 +02:00
|
|
|
slot->internal->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 */
|
2004-06-09 22:27:39 +02:00
|
|
|
slot->metrics.width = bitmap->width << 6;
|
|
|
|
slot->metrics.height = bitmap->rows << 6;
|
2000-07-07 21:46:01 +02:00
|
|
|
slot->metrics.horiAdvance = bitmap->width << 6;
|
|
|
|
slot->metrics.horiBearingX = 0;
|
|
|
|
slot->metrics.horiBearingY = slot->bitmap_top << 6;
|
|
|
|
|
2006-01-15 16:01:45 +01:00
|
|
|
ft_synthesize_vertical_metrics( &slot->metrics,
|
|
|
|
bitmap->rows << 6 );
|
2006-01-15 07:24:53 +01: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
|
|
|
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
static FT_Error
|
|
|
|
winfnt_get_header( FT_Face face,
|
|
|
|
FT_WinFNT_HeaderRec *aheader )
|
|
|
|
{
|
|
|
|
FNT_Font font = ((FNT_Face)face)->font;
|
|
|
|
|
2003-09-22 11:53:56 +02:00
|
|
|
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
*aheader = font->header;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-09-22 11:53:56 +02:00
|
|
|
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
static const FT_Service_WinFntRec winfnt_service_rec =
|
|
|
|
{
|
|
|
|
winfnt_get_header
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SERVICE LIST
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const FT_ServiceDescRec winfnt_services[] =
|
|
|
|
{
|
2003-10-23 06:54:14 +02:00
|
|
|
{ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_WINFNT },
|
|
|
|
{ FT_SERVICE_ID_WINFNT, &winfnt_service_rec },
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Module_Interface
|
2011-11-30 13:55:56 +01:00
|
|
|
winfnt_get_service( FT_Module module,
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
const FT_String* service_id )
|
|
|
|
{
|
2011-11-30 13:55:56 +01:00
|
|
|
FT_UNUSED( module );
|
* include/freetype/internal/fnttypes.h,
include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c,
src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c,
src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c,
src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,:
simplification of service lookup macros, updating the PFR and
WINFNT font drivers to new services
2003-09-21 19:15:55 +02:00
|
|
|
|
|
|
|
return ft_service_list_lookup( winfnt_services, service_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-04 02:55:49 +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 winfnt_driver_class =
|
2000-07-07 21:46:01 +02:00
|
|
|
{
|
|
|
|
{
|
* include/freetype/ftglyph.h (ft_glyph_bbox_unscaled,
ft_glyph_bbox_subpixels, ft_glyph_bbox_gridfit,
ft_glyph_bbox_truncate, ft_glyph_bbox_pixels): Replaced with
FT_GLYPH_BBOX_UNSCALED, FT_GLYPH_BBOX_SUBPIXELS,
FT_GLYPH_BBIX_GRIDFIT, FT_GLYPH_BBOX_TRUNCATE, FT_GLYPH_BBOX_PIXELS.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* include/freetype/ftmodule.h (ft_module_font_driver,
ft_module_renderer, ft_module_hinter, ft_module_styler,
ft_module_driver_scalable, ft_module_driver_no_outlines,
ft_module_driver_has_hinter): Replaced with FT_MODULE_FONT_DRIVER,
FT_MODULE_RENDERER, FT_MODULE_HINTER, FT_MODULE_STYLER,
FT_MODULE_DRIVER_SCALABLE, FT_MODULE_DRIVER_NO_OUTLINES,
FT_MODULE_DRIVER_HAS_HINTER.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* src/base/ftglyph.c (FT_Glyph_Get_CBox): Handle bbox_mode better
as enumeration.
* src/pcf/pcfdrivr.c (pcf_driver_class), src/winfonts/winfnt.c
(winfnt_driver_class), src/bdf/bdfdrivr.c (bdf_driver_class): Add
the FT_MODULE_DRIVER_NO_OUTLINES flag.
2003-06-17 12:42:27 +02:00
|
|
|
FT_MODULE_FONT_DRIVER |
|
|
|
|
FT_MODULE_DRIVER_NO_OUTLINES,
|
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
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
0, /* FT_Module_Constructor */
|
|
|
|
0, /* FT_Module_Destructor */
|
|
|
|
winfnt_get_service
|
2000-07-07 21:46:01 +02:00
|
|
|
},
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2011-11-30 10:46:53 +01:00
|
|
|
sizeof ( FNT_FaceRec ),
|
|
|
|
sizeof ( FT_SizeRec ),
|
|
|
|
sizeof ( FT_GlyphSlotRec ),
|
2000-07-09 21:15:30 +02:00
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Face_Init,
|
|
|
|
FNT_Face_Done,
|
|
|
|
0, /* FT_Size_InitFunc */
|
|
|
|
0, /* FT_Size_DoneFunc */
|
|
|
|
0, /* FT_Slot_InitFunc */
|
|
|
|
0, /* FT_Slot_DoneFunc */
|
2000-07-07 21:46:01 +02:00
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Load_Glyph,
|
2002-03-22 18:09:52 +01:00
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
0, /* FT_Face_GetKerningFunc */
|
|
|
|
0, /* FT_Face_AttachFunc */
|
|
|
|
0, /* FT_Face_GetAdvancesFunc */
|
* builds/amiga/src/base/ftsystem.c, devel/ftoption.h
include/freetype/ftcache.h, include/freetype/ftoutln.h,
include/freetype/cache/ftccache.h, include/freetype/cache/ftccmap.h,
include/freetype/config/ftoption.h, include/freetype/internal/ftcalc.h,
include/freetype/internal/ftdriver.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h, include/freetype/internal/ftrfork.h,
include/freetype/internal/psaux.h, include/freetype/internal/sfnt.h,
include/freetype/internal/t1types.h, include/freetype/internal/tttypes.h,
src/base/ftcalc.c, src/base/ftdbgmem.c, src/base/ftobjs.c,
src/base/ftsystem.c, src/base/ftutil.c, src/bdf/bdfdrivr.c,
src/cache/ftccache.c, src/cache/ftccback.h, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffdrivr.c, src/cid/cidriver.c,
src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c, src/psaux/psauxmod.c,
src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type42/t42drivr.c, src/winfonts/winfnt.c:
massive changes to the internals to respect the internal object layouts
and exported functions of FreeType 2.1.7. Note that the cache sub-system
cannot be fully retrofitted, unfortunately.
2006-02-16 23:45:31 +01:00
|
|
|
|
2011-11-30 13:55:56 +01:00
|
|
|
FNT_Size_Request,
|
|
|
|
FNT_Size_Select
|
2000-07-07 21:46:01 +02:00
|
|
|
};
|
|
|
|
|
2000-07-09 00:52:21 +02:00
|
|
|
|
|
|
|
/* END */
|