Cleanups; adding some copyrights; formatting.

This commit is contained in:
Werner Lemberg 2003-04-23 05:38:13 +00:00
parent 3ae7cc997a
commit c8c6bf5c63
9 changed files with 547 additions and 393 deletions

101
ChangeLog
View File

@ -36,9 +36,10 @@
will ignore stem quantization only when FT_LOAD_TARGET_SMOOTH is
used.
* src/base/ftobjs.c: Changed the default computations to include
rounding in all cases; this is required to provide accurate kerning
data when native TrueType hinting is enabled.
* src/base/ftobjs.c (FT_Set_Char_Size): Changed the default
computations to include rounding in all cases; this is required to
provide accurate kerning data when native TrueType hinting is
enabled.
* src/type1/t1load.c: The Type 1 loader now accepts more general
names according to the PostScript specification (the previous one
@ -71,9 +72,11 @@
* include/freetype/internal/ftobjs.h (ft_glyphslot_free_bitmap,
ft_glyphslot_alloc_bitmap, ft_glyphslot_set_bitmap): New functions.
* src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/pcf/pcfdriver.c,
src/pfr/pfrsbit.c, src/sfnt/ttsbit.c, src/type42/t42objs.c,
src/winfonts/winfnt.c:
* src/base/ftobjs.c: Implement them.
(ft_glyphslot_done): Use ft_glyphslot_free_bitmap.
* src/bdf/bdfdrivr.c, src/pcf/pcfdriver.c, src/pfr/pfrsbit.c,
src/sfnt/ttsbit.c, src/type42/t42objs.c, src/winfonts/winfnt.c:
* src/cache/ftlru.c: Fixed an invalid assertion check.
@ -99,10 +102,16 @@
2003-03-13 David Turner <david@freetype.org>
* src/base/ftdbgmem.c, docs/DEBUG.TXT: Added new environment
variables to control memory debugging with FreeType. See the
description of "FT2_DEBUG_MEMORY", "FT2_ALLOC_TOTAL_MAX" and
"FT2_ALLOC_COUNT_MAX" in DEBUG.TXT.
Added new environment variables to control memory debugging with
FreeType. See the description of "FT2_DEBUG_MEMORY",
"FT2_ALLOC_TOTAL_MAX" and "FT2_ALLOC_COUNT_MAX" in DEBUG.TXT.
* src/base/ftdbgmem.c (FT_MemTableRec): Add `alloc_count',
`bound_total', `alloc_total_max', `bound_count', `alloc_count_max'.
(ft_mem_debug_alloc): Handle new variables.
(ft_mem_debug_init): s/FT_DEBUG_MEMORY/FT2_DEBUG_MEMORY/.
Handle new environment variables.
* docs/DEBUG.TXT: Updated.
* src/cache/ftccache.c, src/cache/ftccmap.c, src/cache/ftcsbits.c,
src/cache/ftlru.c: Fixed the cache sub-system to correctly deal with
@ -166,11 +175,14 @@
2003-02-18 David Turner <david@freetype.org>
* src/truetype/ttdriver.c, src/truetype/ttobjs.h,
src/truetype/ttobjs.c, src/truetype/ttinterp.c, src/base/ftobjs.c:
Fixing the slight distortion problem that ocurred due to the latest
Fixing the slight distortion problem that occurred due to the latest
auto-hinter changes.
* src/base/ftobjs.c (ft_recompute_scaled_metrics): Fix rounding.
* src/truetype/ttdriver.c, src/truetype/ttobjs.h,
src/truetype/ttobjs.c, src/truetype/ttinterp.c:
* src/autohint/ahhint.c (ah_hinter_load): Disabled the advance width
"correction" which seemed to provide more trouble than benefits.
@ -214,7 +226,9 @@
the top of non-capital letters is aligned on a pixel boundary
whenever possible.
* src/base/ftobjs.c, src/truetype/ttobjs.c:
* src/base/ftobjs.c (FT_Set_Char_Size)
[FT_CONFIG_CHESTER_BLUE_SCALE]: Round differently.
* src/truetype/ttobjs.c:
* src/pshinter/pshalgo3.c: Improved the Postscript hinter. Getting
rid of stem snapping seems to work well here (though the stems are
@ -238,8 +252,12 @@
FT_Get_BDF_Property): New function.
* include/freetype/internal/bdftypes.h: Include FT_BDF_H.
(BDF_GetPropertyFunc): New function pointer.
src/base/ftbdf.c, src/bdf/bdfdrivr.c, src/pcf/pcfdrivr.c,
src/pcf/pcfread.h:
* src/base/ftbdf.c (test_font_type): New helper function.
(FT_Get_BDF_Charset_ID): Use `test_font_type'.
(FT_Get_BDF_Property): New function.
* src/bdf/bdfdrivr.c, src/pcf/pcfdrivr.c, src/pcf/pcfread.h:
* src/sfnt/ttload.c (sfnt_dir_check): Relaxed the "head" table size
verification to accept a few broken fonts who pad the size
@ -279,9 +297,11 @@
* include/freetype/internal/fnttypes.h: Move Windows FNT definition
to...
* include/freetype/ftwinfnt.h: This new file.
* include/freetype/internal/fnttypes.h, src/base/winfnt.c,
src/winfonts/winfnt.c, src/base/Jamfile, src/base/rules.mk,
src/base/descrip.mms:
* src/base/ftwinfnt.c: New file, providing `FT_Get_WinFNT_Header'.
* src/winfonts/winfnt.c:
* src/base/Jamfile, src/base/descrip.mms, src/base/rules.mk:
Updated.
2003-01-14 Graham Asher <graham.asher@btinternet.com>
@ -353,6 +373,7 @@
returned when the font doesn't contain a Unicode charmap. This
allows FT2 to load "symbol.ttf" and a few others correctly since the
last release.
(open_face): Fix return value.
2003-01-08 Owen Taylor <owen@redhat.com>
@ -382,6 +403,11 @@
* src/base/ftstroker.c: Probably the last bug-fixes to the stroker;
the API is likely to change, however.
(ft_stroke_border_close): Don't record empty paths.
(ft_stroke_border_get_counts): Increase `num_points' also in for loop.
(ft_stroke_border_export): Don't increase `write' twice in for loops.
(ft_stroker_outside): Handle `phi' together with `theta'.
(FT_Stroker_ParseOutline): New function.
* src/base/fttrigon.c (FT_Angle_Diff): Fixing function: It returned
invalid values for large negative angle differences (resulting in
@ -391,7 +417,7 @@
assertion, and changing code to avoid hash table size contraction.
* src/base/Jamfile, src/base/rules.mk, src/base/descrip.mms: Adding
"ftstroker.obj" to default build, as optional component.
"ftstroker" to default build, as optional component.
2002-12-26 David Turner <david@freetype.org>
@ -417,6 +443,7 @@
function pointer.
* include/freetype/tttables.h (FT_Load_Sfnt_Table): New function.
* src/base/ftobjs.c: Implement it.
2002-12-17 David Turner <david@freetype.org>
@ -443,9 +470,9 @@
* src/base/ftobjs.c: Modified the logic to get Unicode charmaps.
Now it loads UCS-4 charmaps when there is one.
* src/base/ftobjs.c (find_unicode_charmap): New function.
* src/base/ftobjs.c (open_face): Refer to the above one.
* src/base/ftobjs.c (FT_Select_Charmap): Idem.
(find_unicode_charmap): New function.
(open_face): Refer to the above one.
(FT_Select_Charmap): Idem.
2002-11-29 Antoine Leca <Antoine-Freetype@Leca-Marti.org>
@ -538,6 +565,29 @@
* src/psaux/psobjs.c (ps_table_add): Modified increment loop in
order to implement exponential behaviour.
2002-11-01 David Turner <david@freetype.org>
Added PFR-specific public API. Fixed the kerning retrievel routine
(it returned invalid values when the outline and metrics resolution
differ).
* include/freetype/ftpfr.h, include/freetype/internal/pfr.h: New
files.
* include/freetype/internal/internal.h (FT_INTERNAL_PFR_H): New
macro for pfr.h.
src/base/ftpfr.c: New file.
* src/base/Jamfile, src/base/descrip.mms: Updated.
* src/base/ftobjs.c (ft_glyphslot_clear): Small internal fix to
better support bitmap-based font formats.
* src/base/ftsynth.c (FT_GlyphSlot_Embolden): Fix handling of
`scale'.
Fix arguments to `FT_Vector_From_Polar'.
2002-10-31 David Turner <david@freetype.org>
* include/freetype/ftgzip.h, src/gzip/ftgzip.c: New files, adding
@ -550,9 +600,6 @@
* include/freetype/internal/pcftypes.h (PCF_Public_FaceRec): Add
`gzip_stream' and `gzip_source'.
* include/freetype/ftpfr.h, include/freetype/internal/pfr.h: New
files.
* include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_ZLIB):
New macro.
(T1_CONFIG_OPTION_DISABLE_HINTER, FT_CONFIG_OPTION_USE_CMAPS
@ -564,8 +611,6 @@
that platform specific configuration file can override.
* include/freetype/internal/ftstream.h: Include FT_SYSTEM_H.
* include/freetype/internal/internal.h (FT_INTERNAL_PFR_H): New
macro for pfr.h.
2002-10-30 David Turner <david@freetype.org>

View File

@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing BDF-specific strings (body). */
/* */
/* Copyright 2002 by */
/* Copyright 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -20,13 +20,16 @@
#include FT_INTERNAL_BDF_TYPES_H
#include FT_INTERNAL_OBJECTS_H
static FT_Bool
test_font_type( FT_Face face, const char* name )
test_font_type( FT_Face face,
const char* name )
{
if ( face && face->driver )
{
FT_Module driver = (FT_Module)face->driver;
if ( driver->clazz && driver->clazz->module_name )
{
if ( ft_strcmp( driver->clazz->module_name, name ) == 0 )
@ -76,6 +79,7 @@
{
FT_Error error;
error = FT_Err_Invalid_Argument;
aproperty->type = BDF_PROPERTY_TYPE_NONE;
@ -85,6 +89,7 @@
FT_Driver driver = face->driver;
BDF_GetPropertyFunc func;
func = (BDF_GetPropertyFunc)driver->root.clazz->get_interface(
FT_MODULE( driver ), "get_bdf_property" );
if ( func )
@ -93,4 +98,5 @@
return error;
}
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
/* Copyright 2001, 2002 by */
/* Copyright 2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -260,7 +260,7 @@
slot->bitmap.rows = 0;
slot->bitmap.pitch = 0;
slot->bitmap.pixel_mode = 0;
/* don't touch 'slot->bitmap.buffer' !! */
/* don't touch 'slot->bitmap.buffer'! */
slot->bitmap_left = 0;
slot->bitmap_top = 0;
@ -748,11 +748,11 @@
/* <Description> */
/* This function finds a Unicode charmap, if there is one. */
/* And if there is more than one, it tries to favour the more */
/* extensive one, i.e. one that supports UCS-4 against those which */
/* extensive one, i.e., one that supports UCS-4 against those which */
/* are limited to the BMP (said UCS-2 encoding.) */
/* */
/* This function is called from open_face() (just below), and also */
/* from FT_Select_Charmap( , FT_ENCODING_UNICODE). */
/* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE). */
/* */
static FT_Error
find_unicode_charmap( FT_Face face )
@ -771,26 +771,26 @@
return FT_Err_Invalid_CharMap_Handle;
/*
* the original TrueType specification(s) only specified charmap
* The original TrueType specification(s) only specified charmap
* formats that are capable of mapping 8 or 16 bit character codes to
* glyph indices.
*
* however, recent updates to the Apple and OpenType specifications
* However, recent updates to the Apple and OpenType specifications
* introduced new formats that are capable of mapping 32-bit character
* codes as well. And these are already used on some fonts, mainly to
* map non-BMP Asian ideographs as defined in Unicode.
*
* for compatibility purposes, these fonts generally come with
* For compatibility purposes, these fonts generally come with
* *several* Unicode charmaps:
*
* - one of them in the "old" 16-bit format, that cannot access
* all glyphs in the font
* - One of them in the "old" 16-bit format, that cannot access
* all glyphs in the font.
*
* - another one in the "new" 32-bit format, that can access all
* - Another one in the "new" 32-bit format, that can access all
* the glyphs.
*
* this function has been written to always favor a 32-bit charmap
* when found. Otherwise, a 16-bit one is returned when found
* This function has been written to always favor a 32-bit charmap
* when found. Otherwise, a 16-bit one is returned when found.
*/
/* since the `interesting' table, with id's 3,10, is normally the */
@ -1571,7 +1571,7 @@
return FT_Err_Invalid_Face_Handle;
/* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
/* charmap available, i.e. one with UCS-4 characters, if possible. */
/* charmap available, i.e., one with UCS-4 characters, if possible. */
/* */
/* This is done by find_unicode_charmap() above, to share code. */
if ( encoding == FT_ENCODING_UNICODE )

View File

@ -2,9 +2,9 @@
/* */
/* ftpfr.c */
/* */
/* FreeType API for accessing PFR-specific data */
/* FreeType API for accessing PFR-specific data (body). */
/* */
/* Copyright 2002 by */
/* Copyright 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -27,11 +27,13 @@
{
FT_Error error = FT_Err_Bad_Argument;
if ( face && face->driver )
{
FT_Module module = (FT_Module) face->driver;
const char* name = module->clazz->module_name;
if ( name[0] == 'p' &&
name[1] == 'f' &&
name[2] == 'r' &&
@ -45,7 +47,6 @@
}
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Metrics( FT_Face face,
FT_UInt *aoutline_resolution,
@ -56,6 +57,7 @@
FT_Error error;
FT_PFR_Service service;
error = ft_pfr_check( face, &service );
if ( !error )
{
@ -68,6 +70,7 @@
return error;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Kerning( FT_Face face,
FT_UInt left,
@ -77,6 +80,7 @@
FT_Error error;
FT_PFR_Service service;
error = ft_pfr_check( face, &service );
if ( !error )
{
@ -94,6 +98,7 @@
FT_Error error;
FT_PFR_Service service;
error = ft_pfr_check( face, &service );
if ( !error )
{
@ -102,4 +107,5 @@
return error;
}
/* END */

View File

@ -1,9 +1,28 @@
/***************************************************************************/
/* */
/* ftstroker.c */
/* */
/* FreeType path stroker (body). */
/* */
/* Copyright 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_STROKER_H
#include FT_TRIGONOMETRY_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_DEBUG_H
/***************************************************************************/
/***************************************************************************/
/***** *****/
@ -18,12 +37,14 @@
#define FT_IS_SMALL( x ) ( (x) > -FT_EPSILON && (x) < FT_EPSILON )
static FT_Pos
ft_pos_abs( FT_Pos x )
{
return x >= 0 ? x : -x ;
}
static void
ft_conic_split( FT_Vector* base )
{
@ -53,6 +74,7 @@
FT_Angle theta;
FT_Int close1, close2;
d1.x = base[1].x - base[2].x;
d1.y = base[1].y - base[2].y;
d2.x = base[0].x - base[1].x;
@ -122,6 +144,7 @@
FT_Angle theta1, theta2;
FT_Int close1, close2, close3;
d1.x = base[2].x - base[3].x;
d1.y = base[2].y - base[3].y;
d2.x = base[1].x - base[2].x;
@ -162,6 +185,7 @@
*angle_mid = FT_Atan2( d2.x, d2.y );
*angle_out = FT_Atan2( d3.x, d3.y );
}
theta1 = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_mid ) );
theta2 = ft_pos_abs( FT_Angle_Diff( *angle_mid, *angle_out ) );
@ -170,7 +194,6 @@
}
/***************************************************************************/
/***************************************************************************/
/***** *****/
@ -210,11 +233,13 @@
FT_UInt new_max = border->num_points + new_points;
FT_Error error = 0;
if ( new_max > old_max )
{
FT_UInt cur_max = old_max;
FT_Memory memory = border->memory;
while ( cur_max < new_max )
cur_max += ( cur_max >> 1 ) + 16;
@ -228,12 +253,13 @@
return error;
}
static void
ft_stroke_border_close( FT_StrokeBorder border )
{
FT_ASSERT( border->start >= 0 );
/* don't record empty paths !! */
/* don't record empty paths! */
if ( border->num_points > (FT_UInt)border->start )
{
border->tags[border->start ] |= FT_STROKE_TAG_BEGIN;
@ -252,6 +278,7 @@
{
FT_Error error = 0;
FT_ASSERT( border->start >= 0 );
if ( border->movable )
@ -268,6 +295,7 @@
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
vec[0] = *to;
tag[0] = FT_STROKE_TAG_ON;
@ -286,6 +314,7 @@
{
FT_Error error;
FT_ASSERT( border->start >= 0 );
error = ft_stroke_border_grow( border, 2 );
@ -315,6 +344,7 @@
{
FT_Error error;
FT_ASSERT( border->start >= 0 );
error = ft_stroke_border_grow( border, 3 );
@ -323,6 +353,7 @@
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
vec[0] = *control1;
vec[1] = *control2;
vec[2] = *to;
@ -353,6 +384,7 @@
FT_Fixed length;
FT_Error error = 0;
/* compute start point */
FT_Vector_From_Polar( &a, radius, angle_start );
a.x += center->x;
@ -397,13 +429,15 @@
/* add cubic arc */
error = ft_stroke_border_cubicto( border, &a2, &b2, &b );
if (error) break;
if ( error )
break;
/* process the rest of the arc ?? */
a = b;
total -= step;
angle = next;
}
return error;
}
@ -450,6 +484,7 @@
{
FT_Memory memory = border->memory;
FT_FREE( border->points );
FT_FREE( border->tags );
@ -473,6 +508,7 @@
FT_Byte* tags = border->tags;
FT_Int in_contour = 0;
for ( ; count > 0; count--, num_points++, point++, tags++ )
{
if ( tags[0] & FT_STROKE_TAG_BEGIN )
@ -494,6 +530,7 @@
num_contours++;
}
}
if ( in_contour != 0 )
goto Fail;
@ -524,6 +561,7 @@
FT_Byte* read = border->tags;
FT_Byte* write = (FT_Byte*)outline->tags + outline->n_points;
for ( ; count > 0; count--, read++, write++ )
{
if ( *read & FT_STROKE_TAG_ON )
@ -542,6 +580,7 @@
FT_Short* write = outline->contours + outline->n_contours;
FT_Short index = (FT_Short)outline->n_points;
for ( ; count > 0; count--, tags++, index++ )
{
if ( *tags & FT_STROKE_TAG_END )
@ -597,6 +636,7 @@
FT_Error error;
FT_Stroker stroker;
if ( !FT_NEW( stroker ) )
{
stroker->memory = memory;
@ -635,6 +675,7 @@
{
FT_Memory memory = stroker->memory;
ft_stroke_border_done( &stroker->borders[0] );
ft_stroke_border_done( &stroker->borders[1] );
@ -644,7 +685,6 @@
}
/* creates a circular arc at a corner or cap */
static FT_Error
ft_stroker_arcto( FT_Stroker stroker,
@ -655,6 +695,7 @@
FT_Error error = 0;
FT_StrokeBorder border = stroker->borders + side;
rotate = FT_SIDE_TO_ROTATE( side );
total = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
@ -679,6 +720,7 @@
{
FT_Error error = 0;
if ( stroker->line_cap == FT_STROKER_LINECAP_ROUND )
{
/* add a round cap */
@ -694,6 +736,7 @@
FT_Fixed radius = stroker->radius;
FT_StrokeBorder border = stroker->borders + side;
FT_Vector_From_Polar( &delta2, radius, angle + rotate );
FT_Vector_From_Polar( &delta, radius, angle );
@ -701,7 +744,8 @@
delta.y += stroker->center.y + delta2.y;
error = ft_stroke_border_lineto( border, &delta, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
FT_Vector_From_Polar( &delta2, radius, angle - rotate );
FT_Vector_From_Polar( &delta, radius, angle );
@ -711,12 +755,12 @@
error = ft_stroke_border_lineto( border, &delta, 0 );
}
Exit:
return error;
}
/* process an inside corner, i.e. compute intersection */
static FT_Error
ft_stroker_inside( FT_Stroker stroker,
@ -745,7 +789,8 @@
if ( sigma < 0x10000L )
{
FT_Vector_From_Polar( &delta, stroker->radius, stroker->angle_out + rotate );
FT_Vector_From_Polar( &delta, stroker->radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
border->movable = 0;
@ -774,6 +819,7 @@
FT_Error error;
FT_Angle rotate;
if ( stroker->line_join == FT_STROKER_LINEJOIN_ROUND )
{
error = ft_stroker_arcto( stroker, side );
@ -786,6 +832,7 @@
FT_Fixed thcos;
FT_Bool miter;
rotate = FT_SIDE_TO_ROTATE( side );
miter = FT_BOOL( stroker->line_join == FT_STROKER_LINEJOIN_MITER );
@ -807,20 +854,22 @@
if ( sigma >= 0x10000L )
miter = 0;
if ( miter ) /* this is a miter (broken angle) */
{
FT_Vector middle, delta;
FT_Fixed length;
/* compute middle point */
FT_Vector_From_Polar( &middle, FT_MulFix( radius, stroker->miter_limit ),
FT_Vector_From_Polar( &middle,
FT_MulFix( radius, stroker->miter_limit ),
phi );
middle.x += stroker->center.x;
middle.y += stroker->center.y;
/* compute first angle point */
length = FT_MulFix( radius, FT_DivFix( 0x10000L - sigma,
length = FT_MulFix( radius,
FT_DivFix( 0x10000L - sigma,
ft_pos_abs( FT_Sin( theta ) ) ) );
FT_Vector_From_Polar( &delta, length, phi + rotate );
@ -828,7 +877,8 @@
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
/* compute second angle point */
FT_Vector_From_Polar( &delta, length, phi - rotate );
@ -836,7 +886,8 @@
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
/* finally, add a movable end point */
FT_Vector_From_Polar( &delta, radius, stroker->angle_out + rotate );
@ -845,11 +896,13 @@
error = ft_stroke_border_lineto( border, &delta, 1 );
}
else /* this is a bevel (intersection) */
{
FT_Fixed length;
FT_Vector delta;
length = FT_DivFix( stroker->radius, thcos );
FT_Vector_From_Polar( &delta, length, phi );
@ -860,13 +913,15 @@
if (error) goto Exit;
/* now add end point */
FT_Vector_From_Polar( &delta, stroker->radius, stroker->angle_out + rotate );
FT_Vector_From_Polar( &delta, stroker->radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, 1 );
}
}
Exit:
return error;
}
@ -879,6 +934,7 @@
FT_Angle turn;
FT_Int inside_side;
turn = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
/* no specific corner processing is required if the turn is 0 */
@ -894,7 +950,8 @@
/* process the inside side */
error = ft_stroker_inside( stroker, inside_side );
if (error) goto Exit;
if ( error )
goto Exit;
/* process the outside side */
error = ft_stroker_outside( stroker, 1 - inside_side );
@ -915,14 +972,17 @@
FT_Error error;
FT_StrokeBorder border;
FT_Vector_From_Polar( &delta, stroker->radius, start_angle + FT_ANGLE_PI2 );
FT_Vector_From_Polar( &delta, stroker->radius,
start_angle + FT_ANGLE_PI2 );
point.x = stroker->center.x + delta.x;
point.y = stroker->center.y + delta.y;
border = stroker->borders;
error = ft_stroke_border_moveto( border, &point );
if (error) goto Exit;
if ( error )
goto Exit;
point.x = stroker->center.x - delta.x;
point.y = stroker->center.y - delta.y;
@ -958,18 +1018,20 @@
/* process corner if necessary */
if ( stroker->first_point )
{
/* this is the first segment of a subpath. We need to */
/* This is the first segment of a subpath. We need to */
/* add a point to each border at their respective starting */
/* point locations.. */
/* point locations. */
error = ft_stroker_subpath_start( stroker, angle );
if (error) goto Exit;
if ( error )
goto Exit;
}
else
{
/* process the current corner */
stroker->angle_out = angle;
error = ft_stroker_process_corner( stroker );
if (error) goto Exit;
if ( error )
goto Exit;
}
/* now add a line segment to both the "inside" and "outside" paths */
@ -978,11 +1040,13 @@
{
FT_Vector point;
point.x = to->x + delta.x;
point.y = to->y + delta.y;
error = ft_stroke_border_lineto( border, &point, 1 );
if (error) goto Exit;
if ( error )
goto Exit;
delta.x = -delta.x;
delta.y = -delta.y;
@ -996,7 +1060,6 @@
}
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ConicTo( FT_Stroker stroker,
FT_Vector* control,
@ -1009,6 +1072,7 @@
FT_Angle start_angle;
FT_Bool first_arc = 1;
arc = bez_stack;
arc[0] = *to;
arc[1] = *control;
@ -1018,6 +1082,7 @@
{
FT_Angle angle_in, angle_out;
angle_in = angle_out = 0; /* remove compiler warnings */
if ( arc < limit &&
@ -1044,14 +1109,15 @@
}
}
/* the arc's angle is small enough, we can add it directly to each */
/* border.. */
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
FT_Vector ctrl, end;
FT_Angle theta, phi, rotate;
FT_Fixed length;
FT_Int side;
theta = FT_Angle_Diff( angle_in, angle_out ) / 2;
phi = angle_in + theta;
length = FT_DivFix( stroker->radius, FT_Cos( theta ) );
@ -1070,8 +1136,10 @@
end.x += arc[0].x;
end.y += arc[0].y;
error = ft_stroke_border_conicto( stroker->borders + side, &ctrl, &end );
if (error) goto Exit;
error = ft_stroke_border_conicto( stroker->borders + side,
&ctrl, &end );
if ( error )
goto Exit;
}
}
@ -1088,7 +1156,6 @@
}
FT_EXPORT_DEF( FT_Error )
FT_Stroker_CubicTo( FT_Stroker stroker,
FT_Vector* control1,
@ -1102,6 +1169,7 @@
FT_Angle start_angle;
FT_Bool first_arc = 1;
arc = bez_stack;
arc[0] = *to;
arc[1] = *control2;
@ -1112,11 +1180,13 @@
{
FT_Angle angle_in, angle_mid, angle_out;
/* remove compiler warnings */
angle_in = angle_out = angle_mid = 0;
if ( arc < limit &&
!ft_cubic_is_small_enough( arc, &angle_in, &angle_mid, &angle_out ) )
!ft_cubic_is_small_enough( arc, &angle_in,
&angle_mid, &angle_out ) )
{
ft_cubic_split( arc );
arc += 3;
@ -1137,17 +1207,19 @@
stroker->angle_out = start_angle;
error = ft_stroker_process_corner( stroker );
}
if (error) goto Exit;
if ( error )
goto Exit;
}
/* the arc's angle is small enough, we can add it directly to each */
/* border.. */
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
FT_Vector ctrl1, ctrl2, end;
FT_Angle theta1, phi1, theta2, phi2, rotate;
FT_Fixed length1, length2;
FT_Int side;
theta1 = ft_pos_abs( angle_mid - angle_in ) / 2;
theta2 = ft_pos_abs( angle_out - angle_mid ) / 2;
phi1 = (angle_mid + angle_in ) / 2;
@ -1173,8 +1245,10 @@
end.x += arc[0].x;
end.y += arc[0].y;
error = ft_stroke_border_cubicto( stroker->borders + side, &ctrl1, &ctrl2, &end );
if (error) goto Exit;
error = ft_stroke_border_cubicto( stroker->borders + side,
&ctrl1, &ctrl2, &end );
if ( error )
goto Exit;
}
}
@ -1195,9 +1269,9 @@
FT_Vector* to,
FT_Bool open )
{
/* we cannot process the first point, because there is not enough */
/* We cannot process the first point, because there is not enough */
/* information regarding its corner/cap. The latter will be processed */
/* in the "end_subpath" routine */
/* in the "end_subpath" routine. */
/* */
stroker->first_point = 1;
stroker->center = *to;
@ -1209,8 +1283,8 @@
}
static
FT_Error ft_stroker_add_reverse_left( FT_Stroker stroker,
static FT_Error
ft_stroker_add_reverse_left( FT_Stroker stroker,
FT_Bool open )
{
FT_StrokeBorder right = stroker->borders + 0;
@ -1218,13 +1292,16 @@
FT_Int new_points;
FT_Error error = 0;
FT_ASSERT( left->start >= 0 );
new_points = left->num_points - left->start;
if ( new_points > 0 )
{
error = ft_stroke_border_grow( right, (FT_UInt)new_points );
if (error) goto Exit;
if ( error )
goto Exit;
{
FT_Vector* dst_point = right->points + right->num_points;
FT_Byte* dst_tag = right->tags + right->num_points;
@ -1251,44 +1328,51 @@
dst_tag++;
}
}
left->num_points = left->start;
right->num_points += new_points;
right->movable = 0;
left->movable = 0;
}
Exit:
return error;
}
/* there's a lot of magic in this function !! */
/* there's a lot of magic in this function! */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_EndSubPath( FT_Stroker stroker )
{
FT_Error error = 0;
if ( stroker->subpath_open )
{
FT_StrokeBorder right = stroker->borders;
/* all right, this is an opened path, we need to add a cap between */
/* right & left, add the reverse of left, then add a final cap between */
/* left & right.. */
/* All right, this is an opened path, we need to add a cap between */
/* right & left, add the reverse of left, then add a final cap */
/* between left & right. */
error = ft_stroker_cap( stroker, stroker->angle_in, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
/* add reversed points from "left" to "right" */
error = ft_stroker_add_reverse_left( stroker, 1 );
if (error) goto Exit;
if ( error )
goto Exit;
/* now add the final cap */
stroker->center = stroker->subpath_start;
error = ft_stroker_cap( stroker, stroker->subpath_angle+FT_ANGLE_PI, 0 );
if (error) goto Exit;
error = ft_stroker_cap( stroker,
stroker->subpath_angle + FT_ANGLE_PI, 0 );
if ( error )
goto Exit;
/* now, end the right subpath accordingly. the left one is */
/* rewind and doesn't need further processing.. */
/* Now end the right subpath accordingly. The left one is */
/* rewind and doesn't need further processing. */
ft_stroke_border_close( right );
}
else
@ -1296,9 +1380,11 @@
FT_Angle turn;
FT_Int inside_side;
/* process the corner ... */
/* process the corner */
stroker->angle_out = stroker->subpath_angle;
turn = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
turn = FT_Angle_Diff( stroker->angle_in,
stroker->angle_out );
/* no specific corner processing is required if the turn is 0 */
if ( turn != 0 )
@ -1310,14 +1396,16 @@
if ( turn < 0 )
inside_side = 1;
/* IMPORTANT: WE DO NOT PROCESS THE INSIDE BORDER HERE !! */
/* IMPORTANT: WE DO NOT PROCESS THE INSIDE BORDER HERE! */
/* process the inside side */
/* error = ft_stroker_inside( stroker, inside_side );
if (error) goto Exit; */
/* error = ft_stroker_inside( stroker, inside_side ); */
/* if ( error ) */
/* goto Exit; */
/* process the outside side */
error = ft_stroker_outside( stroker, 1 - inside_side );
if (error) goto Exit;
if ( error )
goto Exit;
}
/* we will first end our two subpaths */
@ -1326,7 +1414,8 @@
/* now, add the reversed left subpath to "right" */
error = ft_stroker_add_reverse_left( stroker, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
}
Exit:
@ -1343,11 +1432,16 @@
FT_UInt count3, count4, num_contours = 0;
FT_Error error;
error = ft_stroke_border_get_counts( stroker->borders+0, &count1, &count2 );
if (error) goto Exit;
error = ft_stroke_border_get_counts( stroker->borders+1, &count3, &count4 );
if (error) goto Exit;
error = ft_stroke_border_get_counts( stroker->borders + 0,
&count1, &count2 );
if ( error )
goto Exit;
error = ft_stroke_border_get_counts( stroker->borders + 1,
&count3, &count4 );
if ( error )
goto Exit;
num_points = count1 + count3;
num_contours = count2 + count4;
@ -1373,12 +1467,9 @@
}
/*
* the following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline
* The following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline.
*/
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ParseOutline( FT_Stroker stroker,
@ -1400,6 +1491,7 @@
FT_Int tag; /* current point's state */
FT_Int in_path;
if ( !outline || !stroker )
return FT_Err_Invalid_Argument;
@ -1431,7 +1523,7 @@
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
/* First point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
@ -1575,3 +1667,6 @@
Invalid_Outline:
return FT_Err_Invalid_Outline;
}
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
/* Copyright 2000-2001 by */
/* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows FNT specific info (body). */
/* */
/* Copyright 2002 by */
/* Copyright 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -28,6 +28,7 @@
{
FT_Error error;
error = FT_Err_Invalid_Argument;
if ( face != NULL && face->driver != NULL )
@ -41,10 +42,11 @@
FNT_Size size = (FNT_Size)face->size;
FNT_Font font = size->font;
if ( font )
{
FT_MEM_COPY( header, &font->header, sizeof ( *header ) );
error = 0;
error = FT_Err_Ok;
}
}
}