2005-02-28 23:09:07 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
2005-03-01 03:13:50 +01:00
|
|
|
/* ttsbit0.c */
|
2005-02-28 23:09:07 +01:00
|
|
|
/* */
|
|
|
|
/* TrueType and OpenType embedded bitmap support (body). */
|
2005-03-01 03:13:50 +01:00
|
|
|
/* This is a heap-optimized version. */
|
2005-02-28 23:09:07 +01:00
|
|
|
/* */
|
2006-01-13 15:53:28 +01:00
|
|
|
/* Copyright 2005, 2006 by */
|
2005-02-28 23:09:07 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
|
|
|
#include "ttsbit.h"
|
|
|
|
|
|
|
|
#include "sferrors.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_ttsbit
|
|
|
|
|
|
|
|
|
|
|
|
static const FT_Frame_Field tt_sbit_line_metrics_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE TT_SBit_LineMetricsRec
|
|
|
|
|
|
|
|
/* no FT_FRAME_START */
|
|
|
|
FT_FRAME_CHAR( ascender ),
|
|
|
|
FT_FRAME_CHAR( descender ),
|
|
|
|
FT_FRAME_BYTE( max_width ),
|
|
|
|
|
|
|
|
FT_FRAME_CHAR( caret_slope_numerator ),
|
|
|
|
FT_FRAME_CHAR( caret_slope_denominator ),
|
|
|
|
FT_FRAME_CHAR( caret_offset ),
|
|
|
|
|
|
|
|
FT_FRAME_CHAR( min_origin_SB ),
|
|
|
|
FT_FRAME_CHAR( min_advance_SB ),
|
|
|
|
FT_FRAME_CHAR( max_before_BL ),
|
|
|
|
FT_FRAME_CHAR( min_after_BL ),
|
|
|
|
FT_FRAME_CHAR( pads[0] ),
|
|
|
|
FT_FRAME_CHAR( pads[1] ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field tt_strike_start_fields[] =
|
|
|
|
{
|
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE TT_SBit_StrikeRec
|
|
|
|
|
|
|
|
/* no FT_FRAME_START */
|
|
|
|
FT_FRAME_ULONG( ranges_offset ),
|
|
|
|
FT_FRAME_SKIP_LONG,
|
|
|
|
FT_FRAME_ULONG( num_ranges ),
|
|
|
|
FT_FRAME_ULONG( color_ref ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const FT_Frame_Field tt_strike_end_fields[] =
|
|
|
|
{
|
|
|
|
/* no FT_FRAME_START */
|
|
|
|
FT_FRAME_USHORT( start_glyph ),
|
|
|
|
FT_FRAME_USHORT( end_glyph ),
|
|
|
|
FT_FRAME_BYTE ( x_ppem ),
|
|
|
|
FT_FRAME_BYTE ( y_ppem ),
|
|
|
|
FT_FRAME_BYTE ( bit_depth ),
|
|
|
|
FT_FRAME_CHAR ( flags ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
Clean up the SFNT_Interface. Table loading functions are now named
after the tables' tags; `hdmx' is TrueType-specific and thus the code
is moved to the truetype module; `get_metrics' is moved here from the
truetype module so that the code can be shared with the cff module.
This pass involves no real changes. That is, the code is moved
verbatim mostly. The only exception is the return value of
`tt_face_get_metrics'.
* include/freetype/internal/sfnt.h, src/sfnt/rules.mk,
src/sfnt/sfdriver.c, src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttsbit.c,
src/sfnt/ttsbit.h, src/sfnt/ttsbit0.c: Clean up the SFNT_Interface.
* src/sfnt/ttmtx.c, src/sfnt/ttmtx.h: Metrics-related tables' loading
and parsing code is moved here.
Move `tt_face_get_metrics' here from the truetype module. The return
value is changed from `void' to `FT_Error'.
* include/freetype/internal/fttrace.h: New trace: ttmtx.
* src/truetype/ttpload.c, src/truetype/ttpload.h: `hdmx' loading and
parsing code is moved here.
New function `tt_face_load_prep' splitted from `tt_face_load_fpgm'.
`tt_face_load_fpgm' returns `FT_Err_Ok' if `fpgm' doesn't exist.
* src/cff/cffgload.c, src/cff/cffobjs.c: Update.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Update.
2006-02-14 07:40:10 +01:00
|
|
|
tt_face_load_eblc( TT_Face face,
|
|
|
|
FT_Stream stream )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_Fixed version;
|
|
|
|
FT_ULong num_strikes, table_size;
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_Byte* p_limit;
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
FT_UInt count;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
face->sbit_num_strikes = 0;
|
|
|
|
|
|
|
|
/* this table is optional */
|
|
|
|
error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
|
|
|
|
if ( error )
|
|
|
|
error = face->goto_table( face, TTAG_bloc, stream, &table_size );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( table_size < 8 )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_ERROR(( "%s: table too short!\n", "tt_face_load_sbit_strikes" ));
|
2005-02-28 23:09:07 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
face->sbit_table_size = table_size;
|
|
|
|
|
|
|
|
p = face->sbit_table;
|
|
|
|
p_limit = p + table_size;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
version = FT_NEXT_ULONG( p );
|
|
|
|
num_strikes = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( version != 0x00020000UL || num_strikes >= 0x10000UL )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_ERROR(( "%s: invalid table version!\n",
|
|
|
|
"tt_face_load_sbit_strikes" ));
|
2005-02-28 23:09:07 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/*
|
|
|
|
* Count the number of strikes available in the table. We are a bit
|
|
|
|
* paranoid there and don't trust the data.
|
|
|
|
*/
|
2005-02-28 23:09:07 +01:00
|
|
|
count = (FT_UInt)num_strikes;
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( 8 +48UL * count > table_size )
|
|
|
|
count = (FT_UInt)( ( p_limit - p ) / 48 );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
face->sbit_num_strikes = count;
|
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
FT_TRACE3(( "sbit_num_strikes: %u\n", count ));
|
2005-02-28 23:09:07 +01:00
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FT_FRAME_RELEASE( face->sbit_table );
|
|
|
|
face->sbit_table_size = 0;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( void )
|
Clean up the SFNT_Interface. Table loading functions are now named
after the tables' tags; `hdmx' is TrueType-specific and thus the code
is moved to the truetype module; `get_metrics' is moved here from the
truetype module so that the code can be shared with the cff module.
This pass involves no real changes. That is, the code is moved
verbatim mostly. The only exception is the return value of
`tt_face_get_metrics'.
* include/freetype/internal/sfnt.h, src/sfnt/rules.mk,
src/sfnt/sfdriver.c, src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttsbit.c,
src/sfnt/ttsbit.h, src/sfnt/ttsbit0.c: Clean up the SFNT_Interface.
* src/sfnt/ttmtx.c, src/sfnt/ttmtx.h: Metrics-related tables' loading
and parsing code is moved here.
Move `tt_face_get_metrics' here from the truetype module. The return
value is changed from `void' to `FT_Error'.
* include/freetype/internal/fttrace.h: New trace: ttmtx.
* src/truetype/ttpload.c, src/truetype/ttpload.h: `hdmx' loading and
parsing code is moved here.
New function `tt_face_load_prep' splitted from `tt_face_load_fpgm'.
`tt_face_load_fpgm' returns `FT_Err_Ok' if `fpgm' doesn't exist.
* src/cff/cffgload.c, src/cff/cffobjs.c: Update.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Update.
2006-02-14 07:40:10 +01:00
|
|
|
tt_face_free_eblc( TT_Face face )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream = face->root.stream;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_FRAME_RELEASE( face->sbit_table );
|
|
|
|
face->sbit_table_size = 0;
|
|
|
|
face->sbit_num_strikes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* 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
|
|
|
tt_face_set_sbit_strike( TT_Face face,
|
|
|
|
FT_Size_Request req,
|
|
|
|
FT_ULong* astrike_index )
|
2005-02-28 23:09:07 +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
|
|
|
return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
|
|
|
|
}
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +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
|
|
|
FT_LOCAL_DEF( FT_Error )
|
|
|
|
tt_face_load_strike_metrics( TT_Face face,
|
|
|
|
FT_ULong strike_index,
|
|
|
|
FT_Size_Metrics* metrics )
|
|
|
|
{
|
* 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_Byte* strike;
|
* 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
|
|
|
|
2006-01-19 14:10:49 +01:00
|
|
|
if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
|
|
|
|
return SFNT_Err_Invalid_Argument;
|
2005-03-01 03:13:50 +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
|
|
|
strike = face->sbit_table + 8 + strike_index * 48;
|
|
|
|
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
metrics->x_ppem = (FT_UShort)strike[44];
|
|
|
|
metrics->y_ppem = (FT_UShort)strike[45];
|
* 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
|
|
|
|
* 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
|
|
|
metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
|
|
|
|
metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
|
* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
unused `max_points' and `max_contours'.
* src/cid/cidobjs.c (cid_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Update.
* include/freetype/internal/tttypes.h (TT_FaceRec): Remove unused
`max_components'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove unused
`loadSize' and `loadStack'.
* src/truetype/ttinterp.c (TT_Done_Context, TT_Load_Context),
src/sfnt/ttload.c (tt_face_load_maxp): Update.
* src/cff/cffobjs.h (cff_size_select), src/sfnt/sfdriver.c
(sfnt_interface), src/truetype/ttdriver.c (tt_size_request): Fix
compiler errors/warnings when TT_CONFIG_OPTION_EMBEDDED_BITMAPS is not
defined.
* src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_get_metrics): Fix
possible segment faults for the non-FT_OPTIMIZE_MEMORY'ed versions.
(finally!)
For most OpenType tables, `tt_face_load_xxxx' simply loads the table
and `face->root' is set later in `sfnt_load_face'. Here, we try to
make this work for _all_ tables.
* src/sfnt/ttsbit.c, src/sfnt/ttsbit0.c, src/sfnt/ttload.c,
src/sfnt/ttmtx.c: all `tt_face_load_xxxx' should load the table and
then exit. Error handling or setting face->root is done later in
`sfnt_load_face'.
Pretty trace messages.
* src/sfnt/sfobjs.c (sfnt_load_face): Work harder.
Mac bitmap-only fonts are not scalable.
Check that `face->header.Units_Per_EM' is not zero.
(LOAD_, LOADM_): Pretty trace messages.
* src/sfnt/ttsbit0.c (tt_face_load_strike_metrics): Read metrics from
`eblc'.
* src/sfnt/ttcmap.c (tt_face_build_cmaps), src/sfnt/ttpost.c
(load_format_20, load_format_25, tt_face_get_ps_name): Use
face->max_profile.numGlyphs, instead of face->root.num_glyphs.
2006-02-15 08:44:31 +01:00
|
|
|
metrics->height = metrics->ascender - metrics->descender;
|
* 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
|
|
|
|
|
|
|
/* XXX: Is this correct? */
|
|
|
|
metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
|
|
|
|
strike[18] + /* max_width */
|
|
|
|
(FT_Char)strike[23] /* min_advance_SB */
|
|
|
|
) << 6;
|
|
|
|
|
|
|
|
return SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
TT_Face face;
|
|
|
|
FT_Stream stream;
|
|
|
|
FT_Bitmap* bitmap;
|
|
|
|
TT_SBit_Metrics metrics;
|
|
|
|
FT_Bool metrics_loaded;
|
|
|
|
FT_Bool bitmap_allocated;
|
|
|
|
FT_Byte bit_depth;
|
|
|
|
|
|
|
|
FT_ULong ebdt_start;
|
|
|
|
FT_ULong ebdt_size;
|
|
|
|
|
|
|
|
FT_ULong strike_index_array;
|
|
|
|
FT_ULong strike_index_count;
|
|
|
|
FT_Byte* eblc_base;
|
|
|
|
FT_Byte* eblc_limit;
|
|
|
|
|
|
|
|
} TT_SBitDecoderRec, *TT_SBitDecoder;
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_init( TT_SBitDecoder decoder,
|
|
|
|
TT_Face face,
|
|
|
|
FT_ULong strike_index,
|
|
|
|
TT_SBit_MetricsRec* metrics )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Stream stream = face->root.stream;
|
|
|
|
FT_ULong ebdt_size;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
|
|
|
|
if ( error )
|
|
|
|
error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( error )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
decoder->face = face;
|
|
|
|
decoder->stream = stream;
|
|
|
|
decoder->bitmap = &face->root.glyph->bitmap;
|
|
|
|
decoder->metrics = metrics;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
decoder->metrics_loaded = 0;
|
|
|
|
decoder->bitmap_allocated = 0;
|
|
|
|
|
|
|
|
decoder->ebdt_start = FT_STREAM_POS();
|
|
|
|
decoder->ebdt_size = ebdt_size;
|
|
|
|
|
|
|
|
decoder->eblc_base = face->sbit_table;
|
|
|
|
decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* now find the strike corresponding to the index */
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_Byte* p = decoder->eblc_base + 8 + 48 * strike_index;
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
decoder->strike_index_array = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
p += 4;
|
2005-03-01 03:13:50 +01:00
|
|
|
decoder->strike_index_count = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
p += 34;
|
|
|
|
decoder->bit_depth = *p;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
tt_sbit_decoder_done( TT_SBitDecoder decoder )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_UNUSED( decoder );
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_UInt width, height;
|
|
|
|
FT_Bitmap* map = decoder->bitmap;
|
|
|
|
FT_Long size;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
if ( !decoder->metrics_loaded )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_Argument;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = decoder->metrics->width;
|
|
|
|
height = decoder->metrics->height;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
map->width = (int)width;
|
|
|
|
map->rows = (int)height;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
switch ( decoder->bit_depth )
|
|
|
|
{
|
|
|
|
case 1:
|
2005-03-01 03:13:50 +01:00
|
|
|
map->pixel_mode = FT_PIXEL_MODE_MONO;
|
|
|
|
map->pitch = ( map->width + 7 ) >> 3;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 2:
|
2005-03-01 03:13:50 +01:00
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
|
|
|
|
map->pitch = ( map->width + 3 ) >> 2;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 4:
|
2005-03-01 03:13:50 +01:00
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
|
|
|
|
map->pitch = ( map->width + 1 ) >> 1;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 8:
|
2005-03-01 03:13:50 +01:00
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY;
|
|
|
|
map->pitch = map->width;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = map->rows * map->pitch;
|
|
|
|
|
|
|
|
/* check that there is no empty image */
|
|
|
|
if ( size == 0 )
|
|
|
|
goto Exit; /* exit successfully! */
|
|
|
|
|
|
|
|
error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( error )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
decoder->bitmap_allocated = 1;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder,
|
|
|
|
FT_Byte* *pp,
|
|
|
|
FT_Byte* limit,
|
|
|
|
FT_Bool big )
|
|
|
|
{
|
|
|
|
FT_Byte* p = *pp;
|
|
|
|
TT_SBit_Metrics metrics = decoder->metrics;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
if ( p + 5 > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
if ( !decoder->metrics_loaded )
|
|
|
|
{
|
|
|
|
metrics->height = p[0];
|
|
|
|
metrics->width = p[1];
|
2005-03-01 03:13:50 +01:00
|
|
|
metrics->horiBearingX = (FT_Char)p[2];
|
|
|
|
metrics->horiBearingY = (FT_Char)p[3];
|
2005-02-28 23:09:07 +01:00
|
|
|
metrics->horiAdvance = p[4];
|
|
|
|
}
|
|
|
|
|
|
|
|
p += 5;
|
|
|
|
if ( big )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 3 > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
if ( !decoder->metrics_loaded )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
metrics->vertBearingX = (FT_Char)p[0];
|
|
|
|
metrics->vertBearingY = (FT_Char)p[1];
|
2005-02-28 23:09:07 +01:00
|
|
|
metrics->vertAdvance = p[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
p += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
decoder->metrics_loaded = 1;
|
|
|
|
*pp = p;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Fail:
|
2005-03-01 03:13:50 +01:00
|
|
|
return SFNT_Err_Invalid_Argument;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* forward declaration */
|
2005-02-28 23:09:07 +01:00
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos );
|
|
|
|
|
|
|
|
typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder,
|
|
|
|
FT_Byte* p,
|
|
|
|
FT_Byte* plimit,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos );
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
|
|
|
|
FT_Byte* p,
|
|
|
|
FT_Byte* limit,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_Byte* line;
|
|
|
|
FT_Int bit_height, bit_width, pitch, width, height, h;
|
|
|
|
FT_Bitmap* bitmap;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
if ( !decoder->bitmap_allocated )
|
|
|
|
{
|
|
|
|
error = tt_sbit_decoder_alloc_bitmap( decoder );
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( error )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* check that we can write the glyph into the bitmap */
|
2005-02-28 23:09:07 +01:00
|
|
|
bitmap = decoder->bitmap;
|
|
|
|
bit_width = bitmap->width;
|
|
|
|
bit_height = bitmap->rows;
|
|
|
|
pitch = bitmap->pitch;
|
2005-03-01 23:57:25 +01:00
|
|
|
line = bitmap->buffer;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
width = decoder->metrics->width;
|
|
|
|
height = decoder->metrics->height;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( x_pos < 0 || x_pos + width > bit_width ||
|
|
|
|
y_pos < 0 || y_pos + height > bit_height )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + ( ( width + 7 ) >> 3 ) * height > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* now do the blit */
|
|
|
|
line += y_pos * pitch + ( x_pos >> 3 );
|
2005-02-28 23:09:07 +01:00
|
|
|
x_pos &= 7;
|
|
|
|
|
|
|
|
if ( x_pos == 0 ) /* the easy one */
|
|
|
|
{
|
|
|
|
for ( h = height; h > 0; h--, line += pitch )
|
|
|
|
{
|
|
|
|
FT_Byte* write = line;
|
|
|
|
FT_Int w;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
for ( w = width; w >= 8; w -= 8 )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
write[0] = (FT_Byte)( write[0] | *p++ );
|
2005-02-28 23:09:07 +01:00
|
|
|
write += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( w > 0 )
|
2005-03-01 03:13:50 +01:00
|
|
|
write[0] = (FT_Byte)( write[0] | ( *p++ & ( 0xFF00U >> w ) ) );
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* x_pos > 0 */
|
|
|
|
{
|
|
|
|
for ( h = height; h > 0; h--, line += pitch )
|
|
|
|
{
|
|
|
|
FT_Byte* write = line;
|
|
|
|
FT_Int w;
|
|
|
|
FT_UInt wval = 0;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
for ( w = width; w >= 8; w -= 8 )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
wval = (FT_UInt)( wval | *p++ );
|
|
|
|
write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
|
2005-02-28 23:09:07 +01:00
|
|
|
write += 1;
|
|
|
|
wval <<= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( w > 0 )
|
2006-02-22 08:59:35 +01:00
|
|
|
wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
|
|
|
|
|
|
|
|
/* all bits read and there are ( x_pos + w ) bits to be written */
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
|
2006-02-22 08:59:35 +01:00
|
|
|
|
|
|
|
if ( x_pos + w > 8 )
|
|
|
|
{
|
|
|
|
write++;
|
|
|
|
wval <<= 8;
|
|
|
|
write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) );
|
|
|
|
}
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2005-03-02 12:24:23 +01:00
|
|
|
tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder,
|
|
|
|
FT_Byte* p,
|
|
|
|
FT_Byte* limit,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_Byte* line;
|
2006-02-22 08:59:35 +01:00
|
|
|
FT_Int bit_height, bit_width, pitch, width, height, h, nbits;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_Bitmap* bitmap;
|
2006-02-22 08:59:35 +01:00
|
|
|
FT_UShort rval;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
if ( !decoder->bitmap_allocated )
|
|
|
|
{
|
|
|
|
error = tt_sbit_decoder_alloc_bitmap( decoder );
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( error )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* check that we can write the glyph into the bitmap */
|
2005-02-28 23:09:07 +01:00
|
|
|
bitmap = decoder->bitmap;
|
|
|
|
bit_width = bitmap->width;
|
|
|
|
bit_height = bitmap->rows;
|
|
|
|
pitch = bitmap->pitch;
|
2005-03-01 23:57:25 +01:00
|
|
|
line = bitmap->buffer;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
width = decoder->metrics->width;
|
|
|
|
height = decoder->metrics->height;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( x_pos < 0 || x_pos + width > bit_width ||
|
|
|
|
y_pos < 0 || y_pos + height > bit_height )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2006-02-22 08:59:35 +01:00
|
|
|
if ( p + ( ( width * height + 7 ) >> 3 ) > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* now do the blit */
|
|
|
|
line += y_pos * pitch + ( x_pos >> 3 );
|
2005-02-28 23:09:07 +01:00
|
|
|
x_pos &= 7;
|
2006-02-22 08:59:35 +01:00
|
|
|
|
|
|
|
/* the higher byte of `rval' is used as a buffer */
|
|
|
|
rval = 0;
|
|
|
|
nbits = 0;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
for ( h = height; h > 0; h--, line += pitch )
|
|
|
|
{
|
2006-02-22 08:59:35 +01:00
|
|
|
FT_Byte* write = line;
|
|
|
|
FT_Int w = width;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2006-02-22 08:59:35 +01:00
|
|
|
if ( x_pos )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2006-02-22 08:59:35 +01:00
|
|
|
w = ( width < 8 - x_pos ) ? width : 8 - x_pos;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2006-02-22 08:59:35 +01:00
|
|
|
if ( nbits < w )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2006-02-22 08:59:35 +01:00
|
|
|
rval |= *p++;
|
|
|
|
nbits += 8 - w;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rval >>= 8;
|
|
|
|
nbits -= w;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
2006-02-22 08:59:35 +01:00
|
|
|
|
|
|
|
*write++ |= ( ( rval >> nbits ) & 0xFF ) & ~( 0xFF << w );
|
|
|
|
rval <<= 8;
|
|
|
|
|
|
|
|
w = width - w;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
2006-02-22 08:59:35 +01:00
|
|
|
for ( ; w >= 8; w -= 8 )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2006-02-22 08:59:35 +01:00
|
|
|
rval |= *p++;
|
|
|
|
*write++ |= ( rval >> nbits ) & 0xFF;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2006-02-22 08:59:35 +01:00
|
|
|
rval <<= 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( w > 0 )
|
|
|
|
{
|
|
|
|
if ( nbits < w )
|
|
|
|
{
|
|
|
|
rval |= *p++;
|
|
|
|
*write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
|
|
|
|
nbits += 8 - w;
|
|
|
|
|
|
|
|
rval <<= 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*write |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
|
|
|
|
nbits -= w;
|
|
|
|
}
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_compound( TT_SBitDecoder decoder,
|
|
|
|
FT_Byte* p,
|
|
|
|
FT_Byte* limit,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_UInt num_components, nn;
|
|
|
|
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 2 > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Fail;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
num_components = FT_NEXT_USHORT( p );
|
|
|
|
if ( p + 4 * num_components > limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
for ( nn = 0; nn < num_components; nn++ )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_UInt gindex = FT_NEXT_USHORT( p );
|
|
|
|
FT_Byte dx = FT_NEXT_BYTE( p );
|
|
|
|
FT_Byte dy = FT_NEXT_BYTE( p );
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
/* NB: a recursive call */
|
2005-03-01 03:13:50 +01:00
|
|
|
error = tt_sbit_decoder_load_image( decoder, gindex,
|
|
|
|
x_pos + dx, y_pos + dy );
|
2005-02-28 23:09:07 +01:00
|
|
|
if ( error )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
|
|
|
|
Fail:
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder,
|
|
|
|
FT_UInt glyph_format,
|
|
|
|
FT_ULong glyph_start,
|
|
|
|
FT_ULong glyph_size,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Stream stream = decoder->stream;
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_Byte* p_limit;
|
|
|
|
FT_Byte* data;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
/* seek into the EBDT table now */
|
2005-02-28 23:09:07 +01:00
|
|
|
if ( glyph_start + glyph_size > decoder->ebdt_size )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Invalid_Argument;
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
|
2005-03-01 03:13:50 +01:00
|
|
|
FT_FRAME_EXTRACT( glyph_size, data ) )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
p = data;
|
|
|
|
p_limit = p + glyph_size;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* read the data, depending on the glyph format */
|
2005-02-28 23:09:07 +01:00
|
|
|
switch ( glyph_format )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 8:
|
2005-02-28 23:09:07 +01:00
|
|
|
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
|
|
|
|
break;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 9:
|
2005-02-28 23:09:07 +01:00
|
|
|
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2005-03-01 03:13:50 +01:00
|
|
|
error = SFNT_Err_Ok;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
{
|
|
|
|
TT_SBitDecoder_LoadFunc loader;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
switch ( glyph_format )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
case 1:
|
|
|
|
case 6:
|
|
|
|
loader = tt_sbit_decoder_load_byte_aligned;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
case 2:
|
|
|
|
case 5:
|
|
|
|
case 7:
|
|
|
|
loader = tt_sbit_decoder_load_bit_aligned;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 8:
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 1 > p_limit )
|
|
|
|
goto Fail;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
p += 1; /* skip padding */
|
|
|
|
/* fall-through */
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 9:
|
2005-03-01 03:13:50 +01:00
|
|
|
loader = tt_sbit_decoder_load_compound;
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
default:
|
2005-03-01 03:13:50 +01:00
|
|
|
goto Fail;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
error = loader( decoder, p, p_limit, x_pos, y_pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FT_FRAME_RELEASE( data );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int x_pos,
|
|
|
|
FT_Int y_pos )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
/*
|
|
|
|
* First, we find the correct strike range that applies to this
|
|
|
|
* glyph index.
|
|
|
|
*/
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
FT_Byte* p = decoder->eblc_base + decoder->strike_index_array;
|
|
|
|
FT_Byte* p_limit = decoder->eblc_limit;
|
|
|
|
FT_ULong num_ranges = decoder->strike_index_count;
|
2005-03-01 23:57:25 +01:00
|
|
|
FT_UInt start, end, index_format, image_format;
|
2005-03-26 11:27:09 +01:00
|
|
|
FT_ULong image_start = 0, image_end = 0, image_offset;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
if ( p + 8 * num_ranges > p_limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto NoBitmap;
|
|
|
|
|
|
|
|
for ( ; num_ranges > 0; num_ranges-- )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
start = FT_NEXT_USHORT( p );
|
|
|
|
end = FT_NEXT_USHORT( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
if ( glyph_index >= start && glyph_index <= end )
|
|
|
|
goto FoundRange;
|
|
|
|
|
|
|
|
p += 4; /* ignore index offset */
|
|
|
|
}
|
|
|
|
goto NoBitmap;
|
|
|
|
|
|
|
|
FoundRange:
|
2005-03-03 18:09:08 +01:00
|
|
|
image_offset = FT_NEXT_ULONG( p );
|
2005-03-03 15:09:10 +01:00
|
|
|
p = decoder->eblc_base + decoder->strike_index_array + image_offset;
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 8 > p_limit )
|
2005-02-28 23:09:07 +01:00
|
|
|
goto NoBitmap;
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
/* now find the glyph's location and extend within the ebdt table */
|
|
|
|
index_format = FT_NEXT_USHORT( p );
|
|
|
|
image_format = FT_NEXT_USHORT( p );
|
|
|
|
image_offset = FT_NEXT_ULONG ( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
switch ( index_format )
|
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
case 1: /* 4-byte offsets relative to `image_offset' */
|
|
|
|
{
|
|
|
|
p += 4 * ( glyph_index - start );
|
|
|
|
if ( p + 8 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
image_start = FT_NEXT_ULONG( p );
|
|
|
|
image_end = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( image_start == image_end ) /* missing glyph */
|
|
|
|
goto NoBitmap;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 2: /* big metrics, constant image size */
|
2005-03-01 03:13:50 +01:00
|
|
|
{
|
|
|
|
FT_ULong image_size;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 12 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
image_size = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
|
|
|
|
goto NoBitmap;
|
|
|
|
|
2005-11-21 04:05:34 +01:00
|
|
|
image_start = image_size * ( glyph_index - start );
|
2005-03-01 03:13:50 +01:00
|
|
|
image_end = image_start + image_size;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 3: /* 2-byte offsets relative to 'image_offset' */
|
2005-03-01 03:13:50 +01:00
|
|
|
{
|
|
|
|
p += 2 * ( glyph_index - start );
|
|
|
|
if ( p + 4 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
image_start = FT_NEXT_USHORT( p );
|
|
|
|
image_end = FT_NEXT_USHORT( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( image_start == image_end ) /* missing glyph */
|
|
|
|
goto NoBitmap;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 4: /* sparse glyph array with (glyph,offset) pairs */
|
2005-03-01 03:13:50 +01:00
|
|
|
{
|
|
|
|
FT_ULong mm, num_glyphs;
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 4 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
num_glyphs = FT_NEXT_ULONG( p );
|
|
|
|
if ( p + ( num_glyphs + 1 ) * 4 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
for ( mm = 0; mm < num_glyphs; mm++ )
|
|
|
|
{
|
|
|
|
FT_UInt gindex = FT_NEXT_USHORT( p );
|
|
|
|
|
|
|
|
|
|
|
|
if ( gindex == glyph_index )
|
2005-02-28 23:09:07 +01:00
|
|
|
{
|
2005-03-01 03:13:50 +01:00
|
|
|
image_start = FT_NEXT_USHORT( p );
|
|
|
|
p += 2;
|
|
|
|
image_end = FT_PEEK_USHORT( p );
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
2005-03-01 03:13:50 +01:00
|
|
|
p += 2;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
if ( mm >= num_glyphs )
|
|
|
|
goto NoBitmap;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
case 5: /* constant metrics with sparse glyph codes */
|
2005-03-01 03:13:50 +01:00
|
|
|
{
|
|
|
|
FT_ULong image_size, mm, num_glyphs;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( p + 16 > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
image_size = FT_NEXT_ULONG( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
num_glyphs = FT_NEXT_ULONG( p );
|
|
|
|
if ( p + 2 * num_glyphs > p_limit )
|
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
for ( mm = 0; mm < num_glyphs; mm++ )
|
|
|
|
{
|
|
|
|
FT_UInt gindex = FT_NEXT_USHORT( p );
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
if ( gindex == glyph_index )
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
if ( mm >= num_glyphs )
|
|
|
|
goto NoBitmap;
|
|
|
|
|
2005-11-21 04:05:34 +01:00
|
|
|
image_start = image_size*mm;
|
2005-03-01 03:13:50 +01:00
|
|
|
image_end = image_start + image_size;
|
|
|
|
}
|
|
|
|
break;
|
2005-02-28 23:09:07 +01:00
|
|
|
|
|
|
|
default:
|
2005-03-01 03:13:50 +01:00
|
|
|
goto NoBitmap;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( image_start > image_end )
|
|
|
|
goto NoBitmap;
|
|
|
|
|
|
|
|
image_end -= image_start;
|
|
|
|
image_start = image_offset + image_start;
|
|
|
|
|
|
|
|
return tt_sbit_decoder_load_bitmap( decoder,
|
|
|
|
image_format,
|
2005-04-14 18:03:15 +02:00
|
|
|
image_start,
|
2005-02-28 23:09:07 +01:00
|
|
|
image_end,
|
|
|
|
x_pos,
|
|
|
|
y_pos );
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
NoBitmap:
|
2005-03-01 03:13:50 +01:00
|
|
|
return SFNT_Err_Invalid_Argument;
|
2005-02-28 23:09:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
tt_face_load_sbit_image( TT_Face face,
|
|
|
|
FT_ULong strike_index,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_UInt load_flags,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Bitmap *map,
|
|
|
|
TT_SBit_MetricsRec *metrics )
|
|
|
|
{
|
|
|
|
TT_SBitDecoderRec decoder[1];
|
|
|
|
FT_Error error;
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_UNUSED( load_flags );
|
|
|
|
FT_UNUSED( stream );
|
|
|
|
FT_UNUSED( map );
|
|
|
|
|
2005-03-01 03:13:50 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
error = tt_sbit_decoder_load_image( decoder, glyph_index, 0, 0 );
|
|
|
|
tt_sbit_decoder_done( decoder );
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2005-03-01 03:13:50 +01:00
|
|
|
|
|
|
|
/* EOF */
|