1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ttsbit.c */
|
|
|
|
/* */
|
|
|
|
/* TrueType and OpenType embedded bitmap support (body). */
|
|
|
|
/* */
|
2006-01-13 15:53:28 +01:00
|
|
|
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-06-05 16:32:32 +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 */
|
1999-12-17 00:11:37 +01: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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
|
|
|
|
2006-02-21 00:50:21 +01:00
|
|
|
/* Alas, the memory-optimized sbit loader can't be used when implementing
|
|
|
|
* the 'old internals' hack !!
|
|
|
|
*/
|
|
|
|
#if defined FT_OPTIMIZE_MEMORY && !defined FT_CONFIG_OPTION_OLD_INTERNALS
|
2005-02-28 23:09:07 +01:00
|
|
|
#include "ttsbit0.c"
|
2006-02-21 00:50:21 +01:00
|
|
|
#else /* !OPTIMIZE_MEMORY || OLD_INTERNALS */
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "ttsbit.h"
|
1999-12-17 00:11:37 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "sferrors.h"
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-06-12 21:36:41 +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. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_ttsbit
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* blit_sbit */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Blits a bitmap from an input stream into a given target. Supports */
|
|
|
|
/* x and y offsets as well as byte padded lines. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* target :: The target bitmap/pixmap. */
|
|
|
|
/* */
|
|
|
|
/* source :: The input packed bitmap data. */
|
|
|
|
/* */
|
|
|
|
/* line_bits :: The number of bits per line. */
|
|
|
|
/* */
|
|
|
|
/* byte_padded :: A flag which is true if lines are byte-padded. */
|
|
|
|
/* */
|
|
|
|
/* x_offset :: The horizontal offset. */
|
|
|
|
/* */
|
|
|
|
/* y_offset :: The vertical offset. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* IMPORTANT: The x and y offsets are relative to the top corner of */
|
|
|
|
/* the target bitmap (unlike the normal TrueType */
|
|
|
|
/* convention). A positive y offset indicates a downwards */
|
|
|
|
/* direction! */
|
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static void
|
|
|
|
blit_sbit( FT_Bitmap* target,
|
|
|
|
FT_Byte* source,
|
|
|
|
FT_Int line_bits,
|
|
|
|
FT_Bool byte_padded,
|
|
|
|
FT_Int x_offset,
|
|
|
|
FT_Int y_offset )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* line_buff;
|
|
|
|
FT_Int line_incr;
|
|
|
|
FT_Int height;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort acc;
|
2001-06-19 10:28:24 +02:00
|
|
|
FT_UInt loaded;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* first of all, compute starting write position */
|
|
|
|
line_incr = target->pitch;
|
|
|
|
line_buff = target->buffer;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( line_incr < 0 )
|
|
|
|
line_buff -= line_incr * ( target->rows - 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
line_buff += ( x_offset >> 3 ) + y_offset * line_incr;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* We use the extra-classic `accumulator' trick to extract the bits */
|
|
|
|
/* from the source byte stream. */
|
|
|
|
/* */
|
|
|
|
/* Namely, the variable `acc' is a 16-bit accumulator containing the */
|
|
|
|
/* last `loaded' bits from the input stream. The bits are shifted to */
|
|
|
|
/* the upmost position in `acc'. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
acc = 0; /* clear accumulator */
|
|
|
|
loaded = 0; /* no bits were loaded */
|
|
|
|
|
|
|
|
for ( height = target->rows; height > 0; height-- )
|
|
|
|
{
|
2001-06-20 01:03:41 +02:00
|
|
|
FT_Byte* cur = line_buff; /* current write cursor */
|
|
|
|
FT_Int count = line_bits; /* # of bits to extract per line */
|
|
|
|
FT_Byte shift = (FT_Byte)( x_offset & 7 ); /* current write shift */
|
|
|
|
FT_Byte space = (FT_Byte)( 8 - shift );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* first of all, read individual source bytes */
|
|
|
|
if ( count >= 8 )
|
|
|
|
{
|
|
|
|
count -= 8;
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* ensure that there are at least 8 bits in the accumulator */
|
|
|
|
if ( loaded < 8 )
|
|
|
|
{
|
2002-01-07 11:04:09 +01:00
|
|
|
acc |= (FT_UShort)((FT_UShort)*source++ << ( 8 - loaded ));
|
1999-12-17 00:11:37 +01:00
|
|
|
loaded += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now write one byte */
|
2000-06-16 21:34:52 +02:00
|
|
|
val = (FT_Byte)( acc >> 8 );
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( shift )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-01-09 22:01:18 +01:00
|
|
|
cur[0] |= (FT_Byte)( val >> shift );
|
|
|
|
cur[1] |= (FT_Byte)( val << space );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
2000-05-18 01:35:37 +02:00
|
|
|
cur[0] |= val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
cur++;
|
|
|
|
acc <<= 8; /* remove bits from accumulator */
|
|
|
|
loaded -= 8;
|
|
|
|
count -= 8;
|
2000-07-02 02:27:53 +02:00
|
|
|
|
|
|
|
} while ( count >= 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* restore `count' to correct value */
|
|
|
|
count += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now write remaining bits (count < 8) */
|
|
|
|
if ( count > 0 )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* ensure that there are at least `count' bits in the accumulator */
|
2001-06-19 15:41:59 +02:00
|
|
|
if ( (FT_Int)loaded < count )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-01-07 11:04:09 +01:00
|
|
|
acc |= (FT_UShort)((FT_UShort)*source++ << ( 8 - loaded ));
|
1999-12-17 00:11:37 +01:00
|
|
|
loaded += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now write remaining bits */
|
2001-06-20 01:03:41 +02:00
|
|
|
val = (FT_Byte)( ( (FT_Byte)( acc >> 8 ) ) & ~( 0xFF >> count ) );
|
2002-01-09 22:01:18 +01:00
|
|
|
cur[0] |= (FT_Byte)( val >> shift );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( count > space )
|
2002-01-09 22:01:18 +01:00
|
|
|
cur[1] |= (FT_Byte)( val << space );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
acc <<= count;
|
|
|
|
loaded -= count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now, skip to next line */
|
|
|
|
if ( byte_padded )
|
2001-06-19 10:28:24 +02:00
|
|
|
{
|
|
|
|
acc = 0;
|
|
|
|
loaded = 0; /* clear accumulator on byte-padded lines */
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
line_buff += line_incr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-26 01:12:04 +01:00
|
|
|
static const FT_Frame_Field sbit_metrics_fields[] =
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 12:26:29 +01:00
|
|
|
#define FT_STRUCTURE TT_SBit_MetricsRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
2000-06-06 22:41:48 +02:00
|
|
|
FT_FRAME_START( 8 ),
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_BYTE( height ),
|
|
|
|
FT_FRAME_BYTE( width ),
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_CHAR( horiBearingX ),
|
|
|
|
FT_FRAME_CHAR( horiBearingY ),
|
|
|
|
FT_FRAME_BYTE( horiAdvance ),
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_CHAR( vertBearingX ),
|
|
|
|
FT_FRAME_CHAR( vertBearingY ),
|
|
|
|
FT_FRAME_BYTE( vertAdvance ),
|
2000-06-06 22:41:48 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Load_SBit_Const_Metrics */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Loads the metrics for `EBLC' index tables format 2 and 5. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* range :: The target range. */
|
|
|
|
/* */
|
|
|
|
/* stream :: The input stream. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
2002-03-31 20:48:24 +02:00
|
|
|
Load_SBit_Const_Metrics( TT_SBit_Range range,
|
|
|
|
FT_Stream stream )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +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
|
|
|
if ( FT_READ_ULONG( range->image_size ) )
|
2000-06-06 22:41:48 +02:00
|
|
|
return error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
return FT_STREAM_READ_FIELDS( sbit_metrics_fields, &range->metrics );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Load_SBit_Range_Codes */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Loads the range codes for `EBLC' index tables format 4 and 5. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* range :: The target range. */
|
|
|
|
/* */
|
|
|
|
/* stream :: The input stream. */
|
|
|
|
/* */
|
|
|
|
/* load_offsets :: A flag whether to load the glyph offset table. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
2002-03-31 20:48:24 +02:00
|
|
|
Load_SBit_Range_Codes( TT_SBit_Range range,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Bool load_offsets )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_ULong count, n, size;
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
|
|
|
|
* 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
|
|
|
if ( FT_READ_ULONG( count ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
range->num_glyphs = count;
|
|
|
|
|
|
|
|
/* Allocate glyph offsets table if needed */
|
|
|
|
if ( load_offsets )
|
|
|
|
{
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( range->glyph_offsets, count ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
size = count * 4L;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
size = count * 2L;
|
|
|
|
|
|
|
|
/* Allocate glyph codes table and access frame */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY ( range->glyph_codes, count ) ||
|
|
|
|
FT_FRAME_ENTER( size ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( n = 0; n < count; n++ )
|
|
|
|
{
|
* 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
|
|
|
range->glyph_codes[n] = FT_GET_USHORT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( load_offsets )
|
2000-06-16 21:34:52 +02:00
|
|
|
range->glyph_offsets[n] = (FT_ULong)range->image_offset +
|
* 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
|
|
|
FT_GET_USHORT();
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* TT_Load_SBit_Range */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Loads a given `EBLC' index/range table. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* range :: The target range. */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* stream :: The input stream. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
2002-03-31 20:48:24 +02:00
|
|
|
Load_SBit_Range( TT_SBit_Range range,
|
|
|
|
FT_Stream stream )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
|
|
|
|
|
|
|
|
switch( range->index_format )
|
|
|
|
{
|
|
|
|
case 1: /* variable metrics with 4-byte offsets */
|
|
|
|
case 3: /* variable metrics with 2-byte offsets */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_ULong num_glyphs, n;
|
|
|
|
FT_Int size_elem;
|
2001-06-19 10:28:24 +02:00
|
|
|
FT_Bool large = FT_BOOL( range->index_format == 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2004-10-13 07:15:44 +02:00
|
|
|
|
|
|
|
if ( range->last_glyph < range->first_glyph )
|
|
|
|
{
|
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
num_glyphs = range->last_glyph - range->first_glyph + 1L;
|
|
|
|
range->num_glyphs = num_glyphs;
|
2000-06-05 16:32:32 +02:00
|
|
|
num_glyphs++; /* XXX: BEWARE - see spec */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-06 22:41:48 +02:00
|
|
|
size_elem = large ? 4 : 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( range->glyph_offsets, num_glyphs ) ||
|
|
|
|
FT_FRAME_ENTER( num_glyphs * size_elem ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
for ( n = 0; n < num_glyphs; n++ )
|
2000-06-16 21:34:52 +02:00
|
|
|
range->glyph_offsets[n] = (FT_ULong)( range->image_offset +
|
2002-03-31 20:48:24 +02:00
|
|
|
( large ? FT_GET_ULONG()
|
|
|
|
: FT_GET_USHORT() ) );
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* all glyphs have identical metrics */
|
|
|
|
error = Load_SBit_Const_Metrics( range, stream );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
error = Load_SBit_Range_Codes( range, stream, 1 );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2002-03-31 20:48:24 +02:00
|
|
|
error = Load_SBit_Const_Metrics( range, stream ) ||
|
|
|
|
Load_SBit_Range_Codes( range, stream, 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
* 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
|
|
|
/* tt_face_load_sbit_strikes */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Loads the table of embedded bitmap sizes for this face. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: The target face object. */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* stream :: The input stream. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2002-03-01 03:26:22 +01:00
|
|
|
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 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Fixed version;
|
|
|
|
FT_ULong num_strikes;
|
|
|
|
FT_ULong table_base;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
static const FT_Frame_Field sbit_line_metrics_fields[] =
|
2000-06-06 22:41:48 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 12:26:29 +01:00
|
|
|
#define FT_STRUCTURE TT_SBit_LineMetricsRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
2000-06-06 22:41:48 +02:00
|
|
|
/* no FT_FRAME_START */
|
2000-07-31 20:59:02 +02:00
|
|
|
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] ),
|
2000-06-06 22:41:48 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
static const FT_Frame_Field strike_start_fields[] =
|
2000-06-07 02:00:08 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 12:26:29 +01:00
|
|
|
#define FT_STRUCTURE TT_SBit_StrikeRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
2000-06-07 02:00:08 +02:00
|
|
|
/* no FT_FRAME_START */
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_ULONG( ranges_offset ),
|
2000-06-07 02:00:08 +02:00
|
|
|
FT_FRAME_SKIP_LONG,
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_ULONG( num_ranges ),
|
|
|
|
FT_FRAME_ULONG( color_ref ),
|
2000-06-07 02:00:08 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
2005-02-28 23:09:07 +01:00
|
|
|
static const FT_Frame_Field strike_end_fields[] =
|
2000-06-07 02:00:08 +02:00
|
|
|
{
|
|
|
|
/* no FT_FRAME_START */
|
2000-07-31 20:59:02 +02:00
|
|
|
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 ),
|
2000-06-07 02:00:08 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2000-05-18 01:35:37 +02:00
|
|
|
face->num_sbit_strikes = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* this table is optional */
|
|
|
|
error = face->goto_table( face, TTAG_EBLC, stream, 0 );
|
2000-08-06 21:48:47 +02:00
|
|
|
if ( error )
|
2000-06-16 21:34:52 +02:00
|
|
|
error = face->goto_table( face, TTAG_bloc, stream, 0 );
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( error )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
table_base = FT_STREAM_POS();
|
|
|
|
if ( FT_FRAME_ENTER( 8L ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
* 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
|
|
|
version = FT_GET_LONG();
|
|
|
|
num_strikes = FT_GET_ULONG();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* check version number and strike count */
|
2000-06-06 22:41:48 +02:00
|
|
|
if ( version != 0x00020000L ||
|
|
|
|
num_strikes >= 0x10000L )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
* 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
|
|
|
FT_ERROR(( "tt_face_load_sbit_strikes: invalid table version!\n" ));
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = SFNT_Err_Invalid_File_Format;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate the strikes table */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( face->sbit_strikes, num_strikes ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
face->num_sbit_strikes = num_strikes;
|
|
|
|
|
|
|
|
/* now read each strike table separately */
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Strike strike = face->sbit_strikes;
|
|
|
|
FT_ULong count = num_strikes;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_FRAME_ENTER( 48L * num_strikes ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
while ( count > 0 )
|
|
|
|
{
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_READ_FIELDS( strike_start_fields, strike ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( sbit_line_metrics_fields, &strike->hori ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( sbit_line_metrics_fields, &strike->vert ) ||
|
|
|
|
FT_STREAM_READ_FIELDS( strike_end_fields, strike ) )
|
2000-08-01 00:51:00 +02:00
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
count--;
|
|
|
|
strike++;
|
|
|
|
}
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate the index ranges for each strike table */
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Strike strike = face->sbit_strikes;
|
|
|
|
FT_ULong count = num_strikes;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
while ( count > 0 )
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Range range;
|
|
|
|
FT_ULong count2 = strike->num_ranges;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* read each range */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( table_base + strike->ranges_offset ) ||
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_FRAME_ENTER( strike->num_ranges * 8L ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2004-10-13 07:15:44 +02:00
|
|
|
if ( FT_NEW_ARRAY( strike->sbit_ranges, strike->num_ranges ) )
|
|
|
|
goto Exit;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
range = strike->sbit_ranges;
|
|
|
|
while ( count2 > 0 )
|
|
|
|
{
|
* 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
|
|
|
range->first_glyph = FT_GET_USHORT();
|
|
|
|
range->last_glyph = FT_GET_USHORT();
|
2002-03-31 20:48:24 +02:00
|
|
|
range->table_offset = table_base + strike->ranges_offset +
|
|
|
|
FT_GET_ULONG();
|
1999-12-17 00:11:37 +01:00
|
|
|
count2--;
|
|
|
|
range++;
|
|
|
|
}
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* Now, read each index table */
|
|
|
|
count2 = strike->num_ranges;
|
|
|
|
range = strike->sbit_ranges;
|
|
|
|
while ( count2 > 0 )
|
|
|
|
{
|
|
|
|
/* Read the header */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( range->table_offset ) ||
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_FRAME_ENTER( 8L ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
* 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
|
|
|
range->index_format = FT_GET_USHORT();
|
|
|
|
range->image_format = FT_GET_USHORT();
|
|
|
|
range->image_offset = FT_GET_ULONG();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
error = Load_SBit_Range( range, stream );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
count2--;
|
|
|
|
range++;
|
|
|
|
}
|
|
|
|
|
|
|
|
count--;
|
|
|
|
strike++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
* 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
|
|
|
/* tt_face_free_sbit_strikes */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Releases the embedded bitmap tables. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: The target face object. */
|
|
|
|
/* */
|
2002-03-01 03:26:22 +01:00
|
|
|
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 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Memory memory = face->root.memory;
|
|
|
|
TT_SBit_Strike strike = face->sbit_strikes;
|
|
|
|
TT_SBit_Strike strike_limit = strike + face->num_sbit_strikes;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( strike )
|
|
|
|
{
|
|
|
|
for ( ; strike < strike_limit; strike++ )
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Range range = strike->sbit_ranges;
|
|
|
|
TT_SBit_Range range_limit = range + strike->num_ranges;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( range )
|
|
|
|
{
|
|
|
|
for ( ; range < range_limit; range++ )
|
|
|
|
{
|
|
|
|
/* release the glyph offsets and codes tables */
|
|
|
|
/* where appropriate */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( range->glyph_offsets );
|
|
|
|
FT_FREE( range->glyph_codes );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( strike->sbit_ranges );
|
1999-12-17 00:11:37 +01:00
|
|
|
strike->num_ranges = 0;
|
|
|
|
}
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->sbit_strikes );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
face->num_sbit_strikes = 0;
|
|
|
|
}
|
|
|
|
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
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 )
|
2000-11-07 00:07:51 +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 );
|
|
|
|
}
|
2000-11-07 07:30:29 +01:00
|
|
|
|
2000-11-07 00:07:51 +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 )
|
|
|
|
{
|
|
|
|
TT_SBit_Strike strike;
|
2000-11-07 00:07:51 +01:00
|
|
|
|
2000-11-07 07:30:29 +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
|
|
|
if ( strike_index >= face->num_sbit_strikes )
|
|
|
|
return SFNT_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
strike = face->sbit_strikes + strike_index;
|
|
|
|
|
* 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
|
|
|
metrics->x_ppem = strike->x_ppem;
|
|
|
|
metrics->y_ppem = strike->y_ppem;
|
* 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 = strike->hori.ascender << 6;
|
|
|
|
metrics->descender = strike->hori.descender << 6;
|
|
|
|
|
|
|
|
/* XXX: Is this correct? */
|
|
|
|
metrics->max_advance = ( strike->hori.min_origin_SB +
|
|
|
|
strike->hori.max_width +
|
|
|
|
strike->hori.min_advance_SB ) << 6;
|
|
|
|
|
|
|
|
metrics->height = metrics->ascender - metrics->descender;
|
|
|
|
|
|
|
|
return SFNT_Err_Ok;
|
2000-11-07 00:07:51 +01:00
|
|
|
}
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
* 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
|
|
|
/* find_sbit_range */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Scans a given strike's ranges and return, for a given glyph */
|
|
|
|
/* index, the corresponding sbit range, and `EBDT' offset. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* glyph_index :: The glyph index. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* strike :: The source/current sbit strike. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* arange :: The sbit range containing the glyph index. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means the glyph index was found. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
* 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
|
|
|
find_sbit_range( FT_UInt glyph_index,
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_SBit_Strike strike,
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Range *arange,
|
|
|
|
FT_ULong *aglyph_offset )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_SBit_RangeRec *range, *range_limit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* check whether the glyph index is within this strike's */
|
|
|
|
/* glyph range */
|
2000-12-01 00:48:22 +01:00
|
|
|
if ( glyph_index < (FT_UInt)strike->start_glyph ||
|
|
|
|
glyph_index > (FT_UInt)strike->end_glyph )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
/* scan all ranges in strike */
|
|
|
|
range = strike->sbit_ranges;
|
|
|
|
range_limit = range + strike->num_ranges;
|
|
|
|
if ( !range )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
for ( ; range < range_limit; range++ )
|
|
|
|
{
|
2000-12-01 00:48:22 +01:00
|
|
|
if ( glyph_index >= (FT_UInt)range->first_glyph &&
|
|
|
|
glyph_index <= (FT_UInt)range->last_glyph )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2001-06-20 01:03:41 +02:00
|
|
|
FT_UShort delta = (FT_UShort)( glyph_index - range->first_glyph );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
switch ( range->index_format )
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
*aglyph_offset = range->glyph_offsets[delta];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
*aglyph_offset = range->image_offset +
|
|
|
|
range->image_size * delta;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_ULong n;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
for ( n = 0; n < range->num_glyphs; n++ )
|
|
|
|
{
|
2000-12-01 00:48:22 +01:00
|
|
|
if ( (FT_UInt)range->glyph_codes[n] == glyph_index )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
if ( range->index_format == 4 )
|
|
|
|
*aglyph_offset = range->glyph_offsets[n];
|
|
|
|
else
|
|
|
|
*aglyph_offset = range->image_offset +
|
|
|
|
n * range->image_size;
|
2000-05-18 01:35:37 +02:00
|
|
|
goto Found;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
/* fall-through */
|
|
|
|
default:
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
Found:
|
1999-12-17 00:11:37 +01:00
|
|
|
/* return successfully! */
|
|
|
|
*arange = range;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
*arange = 0;
|
|
|
|
*aglyph_offset = 0;
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_Argument;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2004-04-13 23:08:17 +02:00
|
|
|
/* tt_find_sbit_image */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Checks whether an embedded bitmap (an `sbit') exists for a given */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* glyph, at a given strike. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: The target face object. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* glyph_index :: The glyph index. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
|
|
|
/* strike_index :: The current strike index. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* arange :: The SBit range containing the glyph index. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* astrike :: The SBit strike containing the glyph index. */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. Returns */
|
2001-06-28 01:25:46 +02:00
|
|
|
/* SFNT_Err_Invalid_Argument if no sbit exists for the requested */
|
|
|
|
/* glyph. */
|
|
|
|
/* */
|
2004-04-13 23:08:17 +02:00
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
tt_find_sbit_image( TT_Face face,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_ULong strike_index,
|
|
|
|
TT_SBit_Range *arange,
|
|
|
|
TT_SBit_Strike *astrike,
|
|
|
|
FT_ULong *aglyph_offset )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Error error;
|
|
|
|
TT_SBit_Strike strike;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
|
2002-09-28 18:40:57 +02:00
|
|
|
if ( !face->sbit_strikes ||
|
|
|
|
( face->num_sbit_strikes <= strike_index ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Fail;
|
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
strike = &face->sbit_strikes[strike_index];
|
1999-12-17 00:11:37 +01:00
|
|
|
|
* 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
|
|
|
error = find_sbit_range( glyph_index, strike,
|
2000-11-07 07:30:29 +01:00
|
|
|
arange, aglyph_offset );
|
2000-11-07 00:07:51 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-11-07 00:07:51 +01:00
|
|
|
*astrike = strike;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Fail:
|
|
|
|
/* no embedded bitmap for this glyph in face */
|
|
|
|
*arange = 0;
|
|
|
|
*astrike = 0;
|
|
|
|
*aglyph_offset = 0;
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_Argument;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2004-04-13 23:08:17 +02:00
|
|
|
/* tt_load_sbit_metrics */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Gets the big metrics for a given SBit. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* stream :: The input stream. */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* range :: The SBit range containing the glyph. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* big_metrics :: A big SBit metrics structure for the glyph. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The stream cursor must be positioned at the glyph's offset within */
|
|
|
|
/* the `EBDT' table before the call. */
|
|
|
|
/* */
|
|
|
|
/* If the image format uses variable metrics, the stream cursor is */
|
|
|
|
/* positioned just after the metrics header in the `EBDT' table on */
|
|
|
|
/* function exit. */
|
|
|
|
/* */
|
2004-04-13 23:08:17 +02:00
|
|
|
FT_LOCAL( FT_Error )
|
|
|
|
tt_load_sbit_metrics( FT_Stream stream,
|
|
|
|
TT_SBit_Range range,
|
|
|
|
TT_SBit_Metrics metrics )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
FT_Error error = SFNT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-05-18 01:35:37 +02:00
|
|
|
switch ( range->image_format )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-05-18 01:35:37 +02:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 8:
|
2000-06-06 22:41:48 +02:00
|
|
|
/* variable small metrics */
|
2000-06-05 16:32:32 +02:00
|
|
|
{
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_SBit_SmallMetricsRec smetrics;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2006-02-21 00:50:21 +01:00
|
|
|
static const FT_Frame_Field sbit_small_metrics_fields[] =
|
2000-06-06 22:41:48 +02:00
|
|
|
{
|
2000-07-31 20:59:02 +02:00
|
|
|
#undef FT_STRUCTURE
|
2002-03-14 12:26:29 +01:00
|
|
|
#define FT_STRUCTURE TT_SBit_SmallMetricsRec
|
2000-07-31 20:59:02 +02:00
|
|
|
|
2000-06-06 22:41:48 +02:00
|
|
|
FT_FRAME_START( 5 ),
|
2000-07-31 20:59:02 +02:00
|
|
|
FT_FRAME_BYTE( height ),
|
|
|
|
FT_FRAME_BYTE( width ),
|
|
|
|
FT_FRAME_CHAR( bearingX ),
|
|
|
|
FT_FRAME_CHAR( bearingY ),
|
|
|
|
FT_FRAME_BYTE( advance ),
|
2000-06-06 22:41:48 +02:00
|
|
|
FT_FRAME_END
|
|
|
|
};
|
|
|
|
|
2000-05-18 01:35:37 +02:00
|
|
|
|
2000-06-05 16:32:32 +02:00
|
|
|
/* read small metrics */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_READ_FIELDS( sbit_small_metrics_fields, &smetrics ) )
|
2000-06-05 16:32:32 +02:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* convert it to a big metrics */
|
|
|
|
metrics->height = smetrics.height;
|
|
|
|
metrics->width = smetrics.width;
|
|
|
|
metrics->horiBearingX = smetrics.bearingX;
|
|
|
|
metrics->horiBearingY = smetrics.bearingY;
|
|
|
|
metrics->horiAdvance = smetrics.advance;
|
|
|
|
|
|
|
|
/* these metrics are made up at a higher level when */
|
|
|
|
/* needed. */
|
|
|
|
metrics->vertBearingX = 0;
|
|
|
|
metrics->vertBearingY = 0;
|
|
|
|
metrics->vertAdvance = 0;
|
|
|
|
}
|
|
|
|
break;
|
2000-05-18 01:35:37 +02:00
|
|
|
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 9:
|
|
|
|
/* variable big metrics */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_READ_FIELDS( sbit_metrics_fields, metrics ) )
|
2000-08-01 00:51:00 +02:00
|
|
|
goto Exit;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
2000-05-18 01:35:37 +02:00
|
|
|
case 5:
|
2000-06-05 16:32:32 +02:00
|
|
|
default: /* constant metrics */
|
2000-05-18 01:35:37 +02:00
|
|
|
if ( range->index_format == 2 || range->index_format == 5 )
|
|
|
|
*metrics = range->metrics;
|
|
|
|
else
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_File_Format;
|
2000-05-18 01:35:37 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
* 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
|
|
|
/* crop_bitmap */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Crops a bitmap to its tightest bounding box, and adjusts its */
|
|
|
|
/* metrics. */
|
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* <InOut> */
|
|
|
|
/* map :: The bitmap. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* metrics :: The corresponding metrics structure. */
|
|
|
|
/* */
|
2001-06-28 01:25:46 +02:00
|
|
|
static void
|
* 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
|
|
|
crop_bitmap( FT_Bitmap* map,
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Metrics metrics )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* In this situation, some bounding boxes of embedded bitmaps are too */
|
|
|
|
/* large. We need to crop it to a reasonable size. */
|
|
|
|
/* */
|
|
|
|
/* --------- */
|
|
|
|
/* | | ----- */
|
|
|
|
/* | *** | |***| */
|
|
|
|
/* | * | | * | */
|
|
|
|
/* | * | ------> | * | */
|
|
|
|
/* | * | | * | */
|
|
|
|
/* | * | | * | */
|
|
|
|
/* | *** | |***| */
|
|
|
|
/* --------- ----- */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int rows, count;
|
|
|
|
FT_Long line_len;
|
|
|
|
FT_Byte* line;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2000-07-02 02:27:53 +02:00
|
|
|
/* first of all, check the top-most lines of the bitmap, and remove */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* them if they're empty. */
|
|
|
|
/* */
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
line = (FT_Byte*)map->buffer;
|
1999-12-17 00:11:37 +01:00
|
|
|
rows = map->rows;
|
|
|
|
line_len = map->pitch;
|
|
|
|
|
|
|
|
|
|
|
|
for ( count = 0; count < rows; count++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* cur = line;
|
|
|
|
FT_Byte* limit = line + line_len;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
if ( cur[0] )
|
|
|
|
goto Found_Top;
|
|
|
|
|
|
|
|
/* the current line was empty - skip to next one */
|
|
|
|
line = limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
Found_Top:
|
|
|
|
/* check that we have at least one filled line */
|
|
|
|
if ( count >= rows )
|
|
|
|
goto Empty_Bitmap;
|
|
|
|
|
|
|
|
/* now, crop the empty upper lines */
|
|
|
|
if ( count > 0 )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
line = (FT_Byte*)map->buffer;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_MEM_MOVE( line, line + count * line_len,
|
2002-03-31 20:48:24 +02:00
|
|
|
( rows - count ) * line_len );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
metrics->height = (FT_Byte)( metrics->height - count );
|
|
|
|
metrics->horiBearingY = (FT_Char)( metrics->horiBearingY - count );
|
|
|
|
metrics->vertBearingY = (FT_Char)( metrics->vertBearingY - count );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
map->rows -= count;
|
|
|
|
rows -= count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* second, crop the lower lines */
|
|
|
|
/* */
|
|
|
|
{
|
2000-07-02 02:27:53 +02:00
|
|
|
line = (FT_Byte*)map->buffer + ( rows - 1 ) * line_len;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
for ( count = 0; count < rows; count++ )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* cur = line;
|
|
|
|
FT_Byte* limit = line + line_len;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
if ( cur[0] )
|
|
|
|
goto Found_Bottom;
|
|
|
|
|
|
|
|
/* the current line was empty - skip to previous one */
|
|
|
|
line -= line_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
Found_Bottom:
|
|
|
|
if ( count > 0 )
|
|
|
|
{
|
2001-06-19 10:28:24 +02:00
|
|
|
metrics->height = (FT_Byte)( metrics->height - count );
|
1999-12-17 00:11:37 +01:00
|
|
|
rows -= count;
|
|
|
|
map->rows -= count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* third, get rid of the space on the left side of the glyph */
|
|
|
|
/* */
|
|
|
|
do
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* limit;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
line = (FT_Byte*)map->buffer;
|
1999-12-17 00:11:37 +01:00
|
|
|
limit = line + rows * line_len;
|
|
|
|
|
|
|
|
for ( ; line < limit; line += line_len )
|
|
|
|
if ( line[0] & 0x80 )
|
|
|
|
goto Found_Left;
|
|
|
|
|
|
|
|
/* shift the whole glyph one pixel to the left */
|
2000-06-16 21:34:52 +02:00
|
|
|
line = (FT_Byte*)map->buffer;
|
1999-12-17 00:11:37 +01:00
|
|
|
limit = line + rows * line_len;
|
|
|
|
|
|
|
|
for ( ; line < limit; line += line_len )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n, width = map->width;
|
|
|
|
FT_Byte old;
|
|
|
|
FT_Byte* cur = line;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
old = (FT_Byte)(cur[0] << 1);
|
1999-12-17 00:11:37 +01:00
|
|
|
for ( n = 8; n < width; n += 8 )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte val;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
val = cur[1];
|
2001-06-20 01:03:41 +02:00
|
|
|
cur[0] = (FT_Byte)( old | ( val >> 7 ) );
|
|
|
|
old = (FT_Byte)( val << 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
cur++;
|
|
|
|
}
|
|
|
|
cur[0] = old;
|
|
|
|
}
|
|
|
|
|
|
|
|
map->width--;
|
|
|
|
metrics->horiBearingX++;
|
|
|
|
metrics->vertBearingX++;
|
|
|
|
metrics->width--;
|
2000-07-02 02:27:53 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
} while ( map->width > 0 );
|
|
|
|
|
|
|
|
Found_Left:
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* finally, crop the bitmap width to get rid of the space on the right */
|
|
|
|
/* side of the glyph. */
|
|
|
|
/* */
|
|
|
|
do
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int right = map->width - 1;
|
|
|
|
FT_Byte* limit;
|
|
|
|
FT_Byte mask;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
line = (FT_Byte*)map->buffer + ( right >> 3 );
|
2000-06-05 16:32:32 +02:00
|
|
|
limit = line + rows * line_len;
|
2001-06-20 01:03:41 +02:00
|
|
|
mask = (FT_Byte)( 0x80 >> ( right & 7 ) );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
for ( ; line < limit; line += line_len )
|
|
|
|
if ( line[0] & mask )
|
|
|
|
goto Found_Right;
|
|
|
|
|
|
|
|
/* crop the whole glyph to the right */
|
|
|
|
map->width--;
|
|
|
|
metrics->width--;
|
2000-07-02 02:27:53 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
} while ( map->width > 0 );
|
|
|
|
|
|
|
|
Found_Right:
|
|
|
|
/* all right, the bitmap was cropped */
|
|
|
|
return;
|
|
|
|
|
|
|
|
Empty_Bitmap:
|
|
|
|
map->width = 0;
|
|
|
|
map->rows = 0;
|
|
|
|
map->pitch = 0;
|
* 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
|
|
|
map->pixel_mode = FT_PIXEL_MODE_MONO;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
2002-03-31 20:48:24 +02:00
|
|
|
Load_SBit_Single( FT_Bitmap* map,
|
|
|
|
FT_Int x_offset,
|
|
|
|
FT_Int y_offset,
|
|
|
|
FT_Int pix_bits,
|
|
|
|
FT_UShort image_format,
|
|
|
|
TT_SBit_Metrics metrics,
|
|
|
|
FT_Stream stream )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* check that the source bitmap fits into the target pixmap */
|
|
|
|
if ( x_offset < 0 || x_offset + metrics->width > map->width ||
|
|
|
|
y_offset < 0 || y_offset + metrics->height > map->rows )
|
|
|
|
{
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
error = SFNT_Err_Invalid_Argument;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Int glyph_width = metrics->width;
|
|
|
|
FT_Int glyph_height = metrics->height;
|
|
|
|
FT_Int glyph_size;
|
|
|
|
FT_Int line_bits = pix_bits * glyph_width;
|
|
|
|
FT_Bool pad_bytes = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* compute size of glyph image */
|
|
|
|
switch ( image_format )
|
|
|
|
{
|
|
|
|
case 1: /* byte-padded formats */
|
|
|
|
case 6:
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int line_length;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
switch ( pix_bits )
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
case 1:
|
|
|
|
line_length = ( glyph_width + 7 ) >> 3;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
line_length = ( glyph_width + 3 ) >> 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
line_length = ( glyph_width + 1 ) >> 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
line_length = glyph_width;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
glyph_size = glyph_height * line_length;
|
|
|
|
pad_bytes = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 5:
|
|
|
|
case 7:
|
2000-06-06 22:41:48 +02:00
|
|
|
line_bits = glyph_width * pix_bits;
|
|
|
|
glyph_size = ( glyph_height * line_bits + 7 ) >> 3;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* invalid format */
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_File_Format;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now read data and draw glyph into target pixmap */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_FRAME_ENTER( glyph_size ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* don't forget to multiply `x_offset' by `map->pix_bits' as */
|
|
|
|
/* the sbit blitter doesn't make a difference between pixmap */
|
|
|
|
/* depths. */
|
2000-06-16 21:34:52 +02:00
|
|
|
blit_sbit( map, (FT_Byte*)stream->cursor, line_bits, pad_bytes,
|
1999-12-17 00:11:37 +01:00
|
|
|
x_offset * pix_bits, y_offset );
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 01:25:46 +02:00
|
|
|
static FT_Error
|
2002-03-31 20:48:24 +02:00
|
|
|
Load_SBit_Image( TT_SBit_Strike strike,
|
|
|
|
TT_SBit_Range range,
|
|
|
|
FT_ULong ebdt_pos,
|
|
|
|
FT_ULong glyph_offset,
|
2003-03-20 08:04:40 +01:00
|
|
|
FT_GlyphSlot slot,
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Int x_offset,
|
|
|
|
FT_Int y_offset,
|
|
|
|
FT_Stream stream,
|
2003-03-20 08:04:40 +01:00
|
|
|
TT_SBit_Metrics metrics,
|
|
|
|
FT_Int depth )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2003-03-20 08:04:40 +01:00
|
|
|
FT_Memory memory = stream->memory;
|
|
|
|
FT_Bitmap* map = &slot->bitmap;
|
|
|
|
FT_Error error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* place stream at beginning of glyph data and read metrics */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( ebdt_pos + glyph_offset ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2004-04-13 23:08:17 +02:00
|
|
|
error = tt_load_sbit_metrics( stream, range, metrics );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
2003-04-23 17:50:27 +02:00
|
|
|
/* This function is recursive. At the top-level call, we */
|
2003-03-20 08:04:40 +01:00
|
|
|
/* compute the dimensions of the higher-level glyph to */
|
2003-04-23 17:50:27 +02:00
|
|
|
/* allocate the final pixmap buffer. */
|
2003-03-20 08:04:40 +01:00
|
|
|
if ( depth == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Long size;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-06-06 22:41:48 +02:00
|
|
|
map->width = metrics->width;
|
|
|
|
map->rows = metrics->height;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
switch ( strike->bit_depth )
|
|
|
|
{
|
|
|
|
case 1:
|
* 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
|
|
|
map->pixel_mode = FT_PIXEL_MODE_MONO;
|
2000-06-05 16:32:32 +02:00
|
|
|
map->pitch = ( map->width + 7 ) >> 3;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
2000-06-06 22:41:48 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
case 2:
|
* 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
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
|
2000-06-05 16:32:32 +02:00
|
|
|
map->pitch = ( map->width + 3 ) >> 2;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
2000-06-06 22:41:48 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
case 4:
|
* 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
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
|
2000-06-05 16:32:32 +02:00
|
|
|
map->pitch = ( map->width + 1 ) >> 1;
|
1999-12-17 00:11:37 +01:00
|
|
|
break;
|
2000-06-06 22:41:48 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
case 8:
|
* 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
|
|
|
map->pixel_mode = FT_PIXEL_MODE_GRAY;
|
1999-12-17 00:11:37 +01:00
|
|
|
map->pitch = map->width;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_File_Format;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size = map->rows * map->pitch;
|
|
|
|
|
|
|
|
/* check that there is no empty image */
|
|
|
|
if ( size == 0 )
|
|
|
|
goto Exit; /* exit successfully! */
|
|
|
|
|
2003-03-20 08:04:40 +01:00
|
|
|
error = ft_glyphslot_alloc_bitmap( slot, size );
|
|
|
|
if (error)
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( range->image_format )
|
|
|
|
{
|
|
|
|
case 1: /* single sbit image - load it */
|
|
|
|
case 2:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
return Load_SBit_Single( map, x_offset, y_offset, strike->bit_depth,
|
|
|
|
range->image_format, metrics, stream );
|
|
|
|
|
|
|
|
case 8: /* compound format */
|
2002-02-24 06:26:57 +01:00
|
|
|
FT_Stream_Skip( stream, 1L );
|
2000-05-18 01:35:37 +02:00
|
|
|
/* fallthrough */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
case 9:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* invalid image format */
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
return SFNT_Err_Invalid_File_Format;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-07-02 02:27:53 +02:00
|
|
|
/* All right, we have a compound format. First of all, read */
|
|
|
|
/* the array of elements. */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Component components;
|
|
|
|
TT_SBit_Component comp;
|
|
|
|
FT_UShort num_components, count;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_READ_USHORT( num_components ) ||
|
|
|
|
FT_NEW_ARRAY( components, num_components ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
count = num_components;
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_FRAME_ENTER( 4L * num_components ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Fail_Memory;
|
|
|
|
|
|
|
|
for ( comp = components; count > 0; count--, comp++ )
|
|
|
|
{
|
* 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
|
|
|
comp->glyph_code = FT_GET_USHORT();
|
|
|
|
comp->x_offset = FT_GET_CHAR();
|
|
|
|
comp->y_offset = FT_GET_CHAR();
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* Now recursively load each element glyph */
|
|
|
|
count = num_components;
|
|
|
|
comp = components;
|
|
|
|
for ( ; count > 0; count--, comp++ )
|
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Range elem_range;
|
2002-03-14 12:26:29 +01:00
|
|
|
TT_SBit_MetricsRec elem_metrics;
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_ULong elem_offset;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* find the range for this element */
|
* 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
|
|
|
error = find_sbit_range( comp->glyph_code,
|
1999-12-17 00:11:37 +01:00
|
|
|
strike,
|
|
|
|
&elem_range,
|
|
|
|
&elem_offset );
|
|
|
|
if ( error )
|
|
|
|
goto Fail_Memory;
|
|
|
|
|
|
|
|
/* now load the element, recursively */
|
|
|
|
error = Load_SBit_Image( strike,
|
|
|
|
elem_range,
|
|
|
|
ebdt_pos,
|
|
|
|
elem_offset,
|
2003-03-20 08:04:40 +01:00
|
|
|
slot,
|
1999-12-17 00:11:37 +01:00
|
|
|
x_offset + comp->x_offset,
|
|
|
|
y_offset + comp->y_offset,
|
|
|
|
stream,
|
2003-03-20 08:04:40 +01:00
|
|
|
&elem_metrics,
|
2003-04-23 17:50:27 +02:00
|
|
|
depth + 1 );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail_Memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fail_Memory:
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( components );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
* 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
|
|
|
/* tt_face_load_sbit_image */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Loads a given glyph sbit image from the font resource. This also */
|
|
|
|
/* returns its metrics. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* face :: The target face object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-11-07 00:07:51 +01:00
|
|
|
/* strike_index :: The current strike index. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* glyph_index :: The current glyph index. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* load_flags :: The glyph load flags (the code checks for the flag */
|
|
|
|
/* FT_LOAD_CROP_BITMAP). */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* stream :: The input stream. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Output> */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* map :: The target pixmap. */
|
2000-06-05 16:32:32 +02:00
|
|
|
/* */
|
2000-11-07 07:30:29 +01:00
|
|
|
/* metrics :: A big sbit metrics structure for the glyph image. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-06-25 08:47:11 +02:00
|
|
|
/* FreeType error code. 0 means success. Returns an error if no */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* glyph sbit exists for the index. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The `map.buffer' field is always freed before the glyph is loaded. */
|
|
|
|
/* */
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* 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
|
|
|
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 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2002-03-31 20:48:24 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_ULong ebdt_pos, glyph_offset;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-03-31 20:48:24 +02:00
|
|
|
TT_SBit_Strike strike;
|
|
|
|
TT_SBit_Range range;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Check whether there is a glyph sbit for the current index */
|
2004-04-13 23:08:17 +02:00
|
|
|
error = tt_find_sbit_image( face, glyph_index, strike_index,
|
|
|
|
&range, &strike, &glyph_offset );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* now, find the location of the `EBDT' table in */
|
|
|
|
/* the font file */
|
|
|
|
error = face->goto_table( face, TTAG_EBDT, stream, 0 );
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( error )
|
2000-06-16 21:34:52 +02:00
|
|
|
error = face->goto_table( face, TTAG_bdat, stream, 0 );
|
2004-12-12 07:55:40 +01:00
|
|
|
if ( error )
|
2000-06-05 16:32:32 +02:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
ebdt_pos = FT_STREAM_POS();
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
error = Load_SBit_Image( strike, range, ebdt_pos, glyph_offset,
|
2003-03-20 08:04:40 +01:00
|
|
|
face->root.glyph, 0, 0, stream, metrics, 0 );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* setup vertical metrics if needed */
|
|
|
|
if ( strike->flags & 1 )
|
|
|
|
{
|
|
|
|
/* in case of a horizontal strike only */
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int advance;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
advance = strike->hori.ascender - strike->hori.descender;
|
|
|
|
|
2000-07-02 02:27:53 +02:00
|
|
|
/* some heuristic values */
|
|
|
|
|
2001-06-20 01:03:41 +02:00
|
|
|
metrics->vertBearingX = (FT_Char)(-metrics->width / 2 );
|
* src/base/ftoutln.c (FT_Outline_Embolden): Strength should be
halved.
* src/base/ftsynth.c (FT_GlyphSlot_Embolden): Change the default
strength.
Don't increase slot->advance.y.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 2.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.ac (version_info): Set to 9:9:3.
Currently, we are still binary compatible.
* builds/win32/visualc/index.html,
builds/win32/visualc/freetype.dsp,
builds/win32/visualc/freetype.vcproj: s/219/2110/, s/2.1.9/2.1.10/.
* builds/freetype.mk (refdoc), README, Jamfile (RefDoc):
s/2.1.9/2.1.10/.
* docs/CHANGES, docs/VERSION.DLL: Updated.
* ChangeLog: Split off older entries into...
* ChangeLog.20, ChangeLog.21: These new files.
The next release will be 2.2.0, so don't worry about source code
backwards compatibility.
* include/freetype/ftimage.h (FT_Outline_MoveToFunc,
FT_Outline_LineToFunc, FT_Outline_ConicToFunc,
FT_Outline_CubicToFunc, FT_SpanFunc, FT_Raster_RenderFunc),
include/freetype/ftrender.h (FT_Glyph_TransformFunc,
FT_Renderer_RenderFunc, FT_Renderer_TransformFunc): Decorate
parameters with `const' where appropriate.
* src/sfnt/ttsbit.c (tt_face_load_sbit_image): Compute vertBearingY
to make glyphs centered vertically.
* src/truetype/ttgload.c (compute_glyph_metrics): Compute
vertBearingY to make glyphs centered vertically.
Fix some bugs in vertical metrics:
. loader->pp3.y and loader->pp4.y are in 26.6 format, not in font
units.
. As we use the glyph's cbox to calculate the top bearing now
there iss no need to adjust `top'.
* src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE): Use FT_UShort to be
in sync with OTV_OPTIONAL_OFFSET. Reported by YAMATO Masatake.
* docs/release: Update.
2005-06-16 21:07:08 +02:00
|
|
|
metrics->vertBearingY = (FT_Char)( ( advance - metrics->height ) / 2 );
|
2001-06-19 10:28:24 +02:00
|
|
|
metrics->vertAdvance = (FT_Char)( advance * 12 / 10 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-05-18 01:35:37 +02:00
|
|
|
/* Crop the bitmap now, unless specified otherwise */
|
2000-06-05 16:32:32 +02:00
|
|
|
if ( load_flags & FT_LOAD_CROP_BITMAP )
|
* 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
|
|
|
crop_bitmap( map, metrics );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2006-02-21 00:50:21 +01:00
|
|
|
#endif /* !OPTIMIZE_MEMORY || OLD_INTERNALS */
|
2005-03-01 03:13:50 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* END */
|