2005-03-03 18:09:08 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* afhints.c */
|
|
|
|
/* */
|
|
|
|
/* Auto-fitter hinting routines (body). */
|
|
|
|
/* */
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Copyright 2003-2007, 2009-2011 by */
|
2005-03-03 18:09:08 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
#include "afhints.h"
|
2005-03-23 17:45:24 +01:00
|
|
|
#include "aferrors.h"
|
2006-11-02 18:21:02 +01:00
|
|
|
#include FT_INTERNAL_CALC_H
|
2005-03-01 16:48:29 +01:00
|
|
|
|
2006-11-03 10:40:12 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Get new segment for given axis. */
|
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
|
|
|
af_axis_hints_new_segment( AF_AxisHints axis,
|
|
|
|
FT_Memory memory,
|
|
|
|
AF_Segment *asegment )
|
|
|
|
{
|
2005-03-23 17:45:24 +01:00
|
|
|
FT_Error error = AF_Err_Ok;
|
2005-03-01 16:48:29 +01:00
|
|
|
AF_Segment segment = NULL;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
if ( axis->num_segments >= axis->max_segments )
|
|
|
|
{
|
|
|
|
FT_Int old_max = axis->max_segments;
|
|
|
|
FT_Int new_max = old_max;
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
|
|
|
|
if ( old_max >= big_max )
|
|
|
|
{
|
2005-03-23 17:45:24 +01:00
|
|
|
error = AF_Err_Out_Of_Memory;
|
2005-03-01 16:48:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-04-04 00:09:41 +02:00
|
|
|
new_max += ( new_max >> 2 ) + 4;
|
2005-03-01 16:48:29 +01:00
|
|
|
if ( new_max < old_max || new_max > big_max )
|
|
|
|
new_max = big_max;
|
|
|
|
|
|
|
|
if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
axis->max_segments = new_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
segment = axis->segments + axis->num_segments++;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
*asegment = segment;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Get new edge for given axis, direction, and position. */
|
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_LOCAL( FT_Error )
|
2005-03-01 16:48:29 +01:00
|
|
|
af_axis_hints_new_edge( AF_AxisHints axis,
|
|
|
|
FT_Int fpos,
|
2007-06-11 07:37:35 +02:00
|
|
|
AF_Direction dir,
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_Memory memory,
|
|
|
|
AF_Edge *aedge )
|
|
|
|
{
|
2005-03-23 17:45:24 +01:00
|
|
|
FT_Error error = AF_Err_Ok;
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_Edge edge = NULL;
|
|
|
|
AF_Edge edges;
|
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
|
|
|
|
if ( axis->num_edges >= axis->max_edges )
|
|
|
|
{
|
|
|
|
FT_Int old_max = axis->max_edges;
|
|
|
|
FT_Int new_max = old_max;
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
|
|
|
|
if ( old_max >= big_max )
|
|
|
|
{
|
2005-03-23 17:45:24 +01:00
|
|
|
error = AF_Err_Out_Of_Memory;
|
2005-03-01 16:48:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2005-04-04 00:09:41 +02:00
|
|
|
new_max += ( new_max >> 2 ) + 4;
|
2005-03-01 16:48:29 +01:00
|
|
|
if ( new_max < old_max || new_max > big_max )
|
|
|
|
new_max = big_max;
|
|
|
|
|
|
|
|
if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
axis->max_edges = new_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
edges = axis->edges;
|
|
|
|
edge = edges + axis->num_edges;
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
while ( edge > edges )
|
2005-03-01 16:48:29 +01:00
|
|
|
{
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( edge[-1].fpos < fpos )
|
2007-06-11 07:37:35 +02:00
|
|
|
break;
|
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
/* we want the edge with same position and minor direction */
|
|
|
|
/* to appear before those in the major one in the list */
|
|
|
|
if ( edge[-1].fpos == fpos && dir == axis->major_dir )
|
2007-06-11 07:37:35 +02:00
|
|
|
break;
|
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
edge[0] = edge[-1];
|
|
|
|
edge--;
|
|
|
|
}
|
|
|
|
|
|
|
|
axis->num_edges++;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
FT_ZERO( edge );
|
|
|
|
edge->fpos = (FT_Short)fpos;
|
2007-06-11 07:37:35 +02:00
|
|
|
edge->dir = (FT_Char)dir;
|
2005-03-01 16:48:29 +01:00
|
|
|
|
|
|
|
Exit:
|
|
|
|
*aedge = edge;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#ifdef FT_DEBUG_AUTOFIT
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2009-01-13 18:34:48 +01:00
|
|
|
#include FT_CONFIG_STANDARD_LIBRARY_H
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
static const char*
|
|
|
|
af_dir_str( AF_Direction dir )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
const char* result;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
|
|
|
switch ( dir )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
case AF_DIR_UP:
|
|
|
|
result = "up";
|
|
|
|
break;
|
|
|
|
case AF_DIR_DOWN:
|
|
|
|
result = "down";
|
|
|
|
break;
|
|
|
|
case AF_DIR_LEFT:
|
|
|
|
result = "left";
|
|
|
|
break;
|
|
|
|
case AF_DIR_RIGHT:
|
|
|
|
result = "right";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = "none";
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
|
|
|
#define AF_INDEX_NUM( ptr, base ) ( (ptr) ? ( (ptr) - (base) ) : -1 )
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_points( AF_GlyphHints hints )
|
|
|
|
{
|
|
|
|
AF_Point points = hints->points;
|
|
|
|
AF_Point limit = points + hints->num_points;
|
|
|
|
AF_Point point;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
printf( "Table of points:\n" );
|
2011-04-04 13:02:08 +02:00
|
|
|
printf( " [ index | xorg | yorg | xscale | yscale"
|
|
|
|
" | xfit | yfit | flags ]\n" );
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
for ( point = points; point < limit; point++ )
|
|
|
|
{
|
2011-04-04 13:02:08 +02:00
|
|
|
printf( " [ %5d | %5d | %5d | %6.2f | %6.2f"
|
|
|
|
" | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
|
2004-03-27 09:43:17 +01:00
|
|
|
point - points,
|
|
|
|
point->fx,
|
|
|
|
point->fy,
|
2011-02-16 21:59:44 +01:00
|
|
|
point->ox / 64.0,
|
|
|
|
point->oy / 64.0,
|
|
|
|
point->x / 64.0,
|
|
|
|
point->y / 64.0,
|
2005-03-02 12:24:23 +01:00
|
|
|
( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ',
|
|
|
|
( point->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ',
|
|
|
|
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
|
|
|
|
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
|
|
|
|
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
|
|
|
|
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ');
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
printf( "\n" );
|
|
|
|
}
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
static const char*
|
|
|
|
af_edge_flags_to_string( AF_Edge_Flags flags )
|
|
|
|
{
|
2007-06-11 23:15:09 +02:00
|
|
|
static char temp[32];
|
|
|
|
int pos = 0;
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
|
|
|
|
if ( flags & AF_EDGE_ROUND )
|
|
|
|
{
|
2009-01-12 21:01:10 +01:00
|
|
|
ft_memcpy( temp + pos, "round", 5 );
|
2007-06-11 07:37:35 +02:00
|
|
|
pos += 5;
|
|
|
|
}
|
|
|
|
if ( flags & AF_EDGE_SERIF )
|
|
|
|
{
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( pos > 0 )
|
2007-06-11 07:37:35 +02:00
|
|
|
temp[pos++] = ' ';
|
2009-01-12 21:01:10 +01:00
|
|
|
ft_memcpy( temp + pos, "serif", 5 );
|
2007-06-11 07:37:35 +02:00
|
|
|
pos += 5;
|
|
|
|
}
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( pos == 0 )
|
2007-06-11 07:37:35 +02:00
|
|
|
return "normal";
|
|
|
|
|
|
|
|
temp[pos] = 0;
|
2007-06-11 23:15:09 +02:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Dump the array of linked segments. */
|
|
|
|
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_segments( AF_GlyphHints hints )
|
|
|
|
{
|
2007-01-13 09:45:00 +01:00
|
|
|
FT_Int dimension;
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( dimension = 1; dimension >= 0; dimension-- )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_AxisHints axis = &hints->axis[dimension];
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_Segment segments = axis->segments;
|
|
|
|
AF_Segment limit = segments + axis->num_segments;
|
|
|
|
AF_Segment seg;
|
|
|
|
|
|
|
|
|
|
|
|
printf ( "Table of %s segments:\n",
|
|
|
|
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
2007-06-11 07:37:35 +02:00
|
|
|
printf ( " [ index | pos | dir | link | serif |"
|
2011-04-04 13:02:08 +02:00
|
|
|
" height | extra | flags ]\n" );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( seg = segments; seg < limit; seg++ )
|
|
|
|
{
|
2011-04-04 13:02:08 +02:00
|
|
|
printf ( " [ %5d | %5.2g | %5s | %4d | %5d | %6d | %5d | %11s ]\n",
|
2004-03-27 09:43:17 +01:00
|
|
|
seg - segments,
|
2007-06-11 23:15:09 +02:00
|
|
|
dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
|
|
|
|
: (int)seg->first->oy / 64.0,
|
2007-01-13 09:45:00 +01:00
|
|
|
af_dir_str( (AF_Direction)seg->dir ),
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_INDEX_NUM( seg->link, segments ),
|
|
|
|
AF_INDEX_NUM( seg->serif, segments ),
|
2006-11-23 15:49:48 +01:00
|
|
|
seg->height,
|
2007-06-11 07:37:35 +02:00
|
|
|
seg->height - ( seg->max_coord - seg->min_coord ),
|
2007-06-11 23:15:09 +02:00
|
|
|
af_edge_flags_to_string( seg->flags ) );
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
printf( "\n" );
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2011-05-01 13:44:44 +02:00
|
|
|
/* Fetch number of segments. */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
FT_Error
|
|
|
|
af_glyph_hints_get_num_segments( AF_GlyphHints hints,
|
|
|
|
FT_Int dimension,
|
|
|
|
FT_Int* num_segments )
|
|
|
|
{
|
|
|
|
AF_Dimension dim;
|
|
|
|
AF_AxisHints axis;
|
|
|
|
|
|
|
|
|
|
|
|
dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
|
|
|
|
|
|
|
|
axis = &hints->axis[dim];
|
|
|
|
*num_segments = axis->num_segments;
|
|
|
|
|
|
|
|
return AF_Err_Ok;
|
|
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Fetch offset of segments into user supplied offset array. */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
FT_Error
|
|
|
|
af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
|
|
|
|
FT_Int dimension,
|
|
|
|
FT_Int idx,
|
|
|
|
FT_Pos* offset )
|
|
|
|
{
|
|
|
|
AF_Dimension dim;
|
|
|
|
AF_AxisHints axis;
|
|
|
|
AF_Segment seg;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !offset )
|
|
|
|
return AF_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
|
|
|
|
|
|
|
|
axis = &hints->axis[dim];
|
|
|
|
|
|
|
|
if ( idx < 0 || idx >= axis->num_segments )
|
|
|
|
return AF_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
seg = &axis->segments[idx];
|
|
|
|
*offset = (dim == AF_DIMENSION_HORZ) ? seg->first->ox
|
|
|
|
: seg->first->oy;
|
|
|
|
|
|
|
|
return AF_Err_Ok;
|
|
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Dump the array of linked edges. */
|
|
|
|
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_edges( AF_GlyphHints hints )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
FT_Int dimension;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( dimension = 1; dimension >= 0; dimension-- )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_AxisHints axis = &hints->axis[dimension];
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_Edge edges = axis->edges;
|
|
|
|
AF_Edge limit = edges + axis->num_edges;
|
|
|
|
AF_Edge edge;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
|
2011-02-16 21:59:44 +01:00
|
|
|
* since they have a constant X coordinate.
|
2005-03-02 12:24:23 +01:00
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
printf ( "Table of %s edges:\n",
|
|
|
|
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
|
2007-06-11 07:37:35 +02:00
|
|
|
printf ( " [ index | pos | dir | link |"
|
2011-04-04 13:02:08 +02:00
|
|
|
" serif | blue | opos | pos | flags ]\n" );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( edge = edges; edge < limit; edge++ )
|
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
printf ( " [ %5d | %5.2g | %5s | %4d |"
|
2011-04-04 13:02:08 +02:00
|
|
|
" %5d | %c | %5.2f | %5.2f | %11s ]\n",
|
2004-03-27 09:43:17 +01:00
|
|
|
edge - edges,
|
2007-06-11 23:15:09 +02:00
|
|
|
(int)edge->opos / 64.0,
|
2007-01-13 09:45:00 +01:00
|
|
|
af_dir_str( (AF_Direction)edge->dir ),
|
2004-03-27 09:43:17 +01:00
|
|
|
AF_INDEX_NUM( edge->link, edges ),
|
|
|
|
AF_INDEX_NUM( edge->serif, edges ),
|
|
|
|
edge->blue_edge ? 'y' : 'n',
|
|
|
|
edge->opos / 64.0,
|
2007-06-11 07:37:35 +02:00
|
|
|
edge->pos / 64.0,
|
2007-06-11 23:15:09 +02:00
|
|
|
af_edge_flags_to_string( edge->flags ) );
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
printf( "\n" );
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#else /* !FT_DEBUG_AUTOFIT */
|
2006-12-01 09:20:47 +01:00
|
|
|
|
|
|
|
/* these empty stubs are only used to link the `ftgrid' test program */
|
2011-04-18 19:05:28 +02:00
|
|
|
/* if debugging is disabled */
|
2006-12-01 09:20:47 +01:00
|
|
|
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-11-25 02:30:40 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_points( AF_GlyphHints hints )
|
|
|
|
{
|
2006-12-01 09:20:47 +01:00
|
|
|
FT_UNUSED( hints );
|
2006-11-25 02:30:40 +01:00
|
|
|
}
|
|
|
|
|
2006-12-01 09:20:47 +01:00
|
|
|
|
2006-11-25 02:30:40 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_segments( AF_GlyphHints hints )
|
|
|
|
{
|
2006-12-01 09:20:47 +01:00
|
|
|
FT_UNUSED( hints );
|
2006-11-25 02:30:40 +01:00
|
|
|
}
|
|
|
|
|
2006-12-01 09:20:47 +01:00
|
|
|
|
2011-05-01 13:44:44 +02:00
|
|
|
FT_Error
|
|
|
|
af_glyph_hints_get_num_segments( AF_GlyphHints hints,
|
|
|
|
FT_Int dimension,
|
|
|
|
FT_Int* num_segments )
|
|
|
|
{
|
|
|
|
FT_UNUSED( hints );
|
|
|
|
FT_UNUSED( dimension );
|
|
|
|
FT_UNUSED( num_segments );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_Error
|
|
|
|
af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
|
|
|
|
FT_Int dimension,
|
|
|
|
FT_Int idx,
|
|
|
|
FT_Pos* offset )
|
|
|
|
{
|
|
|
|
FT_UNUSED( hints );
|
|
|
|
FT_UNUSED( dimension );
|
|
|
|
FT_UNUSED( idx );
|
|
|
|
FT_UNUSED( offset );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-25 02:30:40 +01:00
|
|
|
void
|
|
|
|
af_glyph_hints_dump_edges( AF_GlyphHints hints )
|
|
|
|
{
|
2006-12-01 09:20:47 +01:00
|
|
|
FT_UNUSED( hints );
|
2006-11-25 02:30:40 +01:00
|
|
|
}
|
|
|
|
|
2011-03-19 15:27:04 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#endif /* !FT_DEBUG_AUTOFIT */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Compute the direction value of a given vector. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( AF_Direction )
|
|
|
|
af_direction_compute( FT_Pos dx,
|
|
|
|
FT_Pos dy )
|
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
FT_Pos ll, ss; /* long and short arm lengths */
|
|
|
|
AF_Direction dir; /* candidate direction */
|
2005-10-28 18:14:14 +02:00
|
|
|
|
2006-05-18 00:55:04 +02:00
|
|
|
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
if ( dy >= dx )
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
if ( dy >= -dx )
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
dir = AF_DIR_UP;
|
|
|
|
ll = dy;
|
|
|
|
ss = dx;
|
2005-10-28 18:14:14 +02:00
|
|
|
}
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
else
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
dir = AF_DIR_LEFT;
|
|
|
|
ll = -dx;
|
|
|
|
ss = dy;
|
2005-10-28 18:14:14 +02:00
|
|
|
}
|
|
|
|
}
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
else /* dy < dx */
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
if ( dy >= -dx )
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
dir = AF_DIR_RIGHT;
|
|
|
|
ll = dx;
|
|
|
|
ss = dy;
|
2005-10-28 18:14:14 +02:00
|
|
|
}
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
else
|
2005-10-28 18:14:14 +02:00
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
dir = AF_DIR_DOWN;
|
|
|
|
ll = dy;
|
|
|
|
ss = dx;
|
2005-10-28 18:14:14 +02:00
|
|
|
}
|
|
|
|
}
|
2005-11-12 08:34:40 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* return no direction if arm lengths differ too much */
|
|
|
|
/* (value 14 is heuristic) */
|
2007-06-11 07:37:35 +02:00
|
|
|
ss *= 14;
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( FT_ABS( ll ) <= FT_ABS( ss ) )
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
dir = AF_DIR_NONE;
|
2005-11-12 08:34:40 +01:00
|
|
|
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
return dir;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_init( AF_GlyphHints hints,
|
|
|
|
FT_Memory memory )
|
|
|
|
{
|
|
|
|
FT_ZERO( hints );
|
|
|
|
hints->memory = memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_done( AF_GlyphHints hints )
|
|
|
|
{
|
|
|
|
if ( hints && hints->memory )
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
FT_Memory memory = hints->memory;
|
|
|
|
int dim;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* note that we don't need to free the segment and edge
|
2011-02-16 21:59:44 +01:00
|
|
|
* buffers since they are really within the hints->points array
|
2005-03-02 12:24:23 +01:00
|
|
|
*/
|
2005-03-03 18:09:08 +01:00
|
|
|
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_AxisHints axis = &hints->axis[dim];
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
axis->num_segments = 0;
|
2005-03-01 16:48:29 +01:00
|
|
|
axis->max_segments = 0;
|
|
|
|
FT_FREE( axis->segments );
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
axis->num_edges = 0;
|
|
|
|
axis->max_edges = 0;
|
2005-03-01 16:48:29 +01:00
|
|
|
FT_FREE( axis->edges );
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FT_FREE( hints->contours );
|
|
|
|
hints->max_contours = 0;
|
|
|
|
hints->num_contours = 0;
|
|
|
|
|
|
|
|
FT_FREE( hints->points );
|
|
|
|
hints->num_points = 0;
|
|
|
|
hints->max_points = 0;
|
|
|
|
|
|
|
|
hints->memory = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Reset metrics. */
|
|
|
|
|
2004-06-04 19:41:59 +02:00
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_rescale( AF_GlyphHints hints,
|
|
|
|
AF_ScriptMetrics metrics )
|
|
|
|
{
|
2005-12-14 17:37:15 +01:00
|
|
|
hints->metrics = metrics;
|
|
|
|
hints->scaler_flags = metrics->scaler.flags;
|
2004-06-04 19:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Recompute all AF_Point in AF_GlyphHints from the definitions */
|
|
|
|
/* in a source outline. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2005-03-02 12:24:23 +01:00
|
|
|
af_glyph_hints_reload( AF_GlyphHints hints,
|
2010-05-22 07:43:22 +02:00
|
|
|
FT_Outline* outline )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2005-03-23 17:45:24 +01:00
|
|
|
FT_Error error = AF_Err_Ok;
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_Point points;
|
|
|
|
FT_UInt old_max, new_max;
|
|
|
|
FT_Fixed x_scale = hints->x_scale;
|
|
|
|
FT_Fixed y_scale = hints->y_scale;
|
|
|
|
FT_Pos x_delta = hints->x_delta;
|
|
|
|
FT_Pos y_delta = hints->y_delta;
|
|
|
|
FT_Memory memory = hints->memory;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
hints->num_points = 0;
|
|
|
|
hints->num_contours = 0;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
hints->axis[0].num_segments = 0;
|
|
|
|
hints->axis[0].num_edges = 0;
|
|
|
|
hints->axis[1].num_segments = 0;
|
|
|
|
hints->axis[1].num_edges = 0;
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* first of all, reallocate the contours array if necessary */
|
2005-03-02 12:24:23 +01:00
|
|
|
new_max = (FT_UInt)outline->n_contours;
|
2004-03-27 09:43:17 +01:00
|
|
|
old_max = hints->max_contours;
|
|
|
|
if ( new_max > old_max )
|
|
|
|
{
|
2011-02-16 21:59:44 +01:00
|
|
|
new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
hints->max_contours = new_max;
|
|
|
|
}
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/*
|
2005-03-03 18:09:08 +01:00
|
|
|
* then reallocate the points arrays if necessary --
|
2005-03-02 12:24:23 +01:00
|
|
|
* note that we reserve two additional point positions, used to
|
|
|
|
* hint metrics appropriately
|
|
|
|
*/
|
2004-03-27 09:43:17 +01:00
|
|
|
new_max = (FT_UInt)( outline->n_points + 2 );
|
|
|
|
old_max = hints->max_points;
|
|
|
|
if ( new_max > old_max )
|
|
|
|
{
|
2011-02-16 21:59:44 +01:00
|
|
|
new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
|
2004-03-27 09:43:17 +01:00
|
|
|
goto Exit;
|
|
|
|
|
2005-03-01 16:48:29 +01:00
|
|
|
hints->max_points = new_max;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hints->num_points = outline->n_points;
|
|
|
|
hints->num_contours = outline->n_contours;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/* We can't rely on the value of `FT_Outline.flags' to know the fill */
|
|
|
|
/* direction used for a glyph, given that some fonts are broken (e.g., */
|
|
|
|
/* the Arphic ones). We thus recompute it each time we need to. */
|
|
|
|
/* */
|
|
|
|
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_UP;
|
|
|
|
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_LEFT;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_POSTSCRIPT )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_DOWN;
|
|
|
|
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_RIGHT;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hints->x_scale = x_scale;
|
|
|
|
hints->y_scale = y_scale;
|
|
|
|
hints->x_delta = x_delta;
|
|
|
|
hints->y_delta = y_delta;
|
|
|
|
|
2007-01-26 16:05:41 +01:00
|
|
|
hints->xmin_delta = 0;
|
|
|
|
hints->xmax_delta = 0;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
points = hints->points;
|
|
|
|
if ( hints->num_points == 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
{
|
|
|
|
AF_Point point;
|
|
|
|
AF_Point point_limit = points + hints->num_points;
|
|
|
|
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
/* compute coordinates & Bezier flags, next and prev */
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2007-06-11 23:15:09 +02:00
|
|
|
FT_Vector* vec = outline->points;
|
|
|
|
char* tag = outline->tags;
|
|
|
|
AF_Point end = points + outline->contours[0];
|
|
|
|
AF_Point prev = end;
|
2007-06-11 07:37:35 +02:00
|
|
|
FT_Int contour_index = 0;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
for ( point = points; point < point_limit; point++, vec++, tag++ )
|
|
|
|
{
|
* Jamfile: removing otvalid from the list of compiled modules
* include/freetype/internal/ftserv.h: added compiler pragmas to get rid
of annoying warnings with Visual C++ compiler in maximum warning mode
* src/autofit/afhints.c, src/autofit/aflatin.c, src/base/ftstroke.c,
src/bdf/bdfdrivr.c, src/cache/ftcbasic.c, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffload.c, src/cid/cidload.c,
src/lzw/zopen.c, src/otvalid/otvgdef.c, src/pcf/pcfread.c,
src/sfnt/sfobjs.c, src/truetype/ttgxvar.c: removing compiler warnings
2005-05-01 12:11:32 +02:00
|
|
|
point->fx = (FT_Short)vec->x;
|
|
|
|
point->fy = (FT_Short)vec->y;
|
2004-03-27 09:43:17 +01:00
|
|
|
point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
|
|
|
|
point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
|
|
|
|
|
|
|
|
switch ( FT_CURVE_TAG( *tag ) )
|
|
|
|
{
|
|
|
|
case FT_CURVE_TAG_CONIC:
|
|
|
|
point->flags = AF_FLAG_CONIC;
|
|
|
|
break;
|
|
|
|
case FT_CURVE_TAG_CUBIC:
|
|
|
|
point->flags = AF_FLAG_CUBIC;
|
|
|
|
break;
|
|
|
|
default:
|
2011-02-16 21:59:44 +01:00
|
|
|
point->flags = AF_FLAG_NONE;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
point->prev = prev;
|
2007-06-11 07:37:35 +02:00
|
|
|
prev->next = point;
|
|
|
|
prev = point;
|
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( point == end )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( ++contour_index < outline->n_contours )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2010-05-26 16:16:34 +02:00
|
|
|
end = points + outline->contours[contour_index];
|
|
|
|
prev = end;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* set up the contours array */
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_Point* contour = hints->contours;
|
|
|
|
AF_Point* contour_limit = contour + hints->num_contours;
|
|
|
|
short* end = outline->contours;
|
|
|
|
short idx = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for ( ; contour < contour_limit; contour++, end++ )
|
|
|
|
{
|
|
|
|
contour[0] = points + idx;
|
|
|
|
idx = (short)( end[0] + 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute directions of in & out vectors */
|
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
AF_Point first = points;
|
|
|
|
AF_Point prev = NULL;
|
|
|
|
FT_Pos in_x = 0;
|
|
|
|
FT_Pos in_y = 0;
|
|
|
|
AF_Direction in_dir = AF_DIR_NONE;
|
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
{
|
2005-03-02 12:24:23 +01:00
|
|
|
AF_Point next;
|
2007-06-11 07:37:35 +02:00
|
|
|
FT_Pos out_x, out_y;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( point == first )
|
|
|
|
{
|
|
|
|
prev = first->prev;
|
|
|
|
in_x = first->fx - prev->fx;
|
|
|
|
in_y = first->fy - prev->fy;
|
|
|
|
in_dir = af_direction_compute( in_x, in_y );
|
|
|
|
first = prev + 1;
|
|
|
|
}
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
point->in_dir = (FT_Char)in_dir;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
next = point->next;
|
|
|
|
out_x = next->fx - point->fx;
|
|
|
|
out_y = next->fy - point->fy;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
in_dir = af_direction_compute( out_x, out_y );
|
2007-06-11 23:15:09 +02:00
|
|
|
point->out_dir = (FT_Char)in_dir;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* check for weak points */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
|
|
|
|
{
|
|
|
|
Is_Weak_Point:
|
|
|
|
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
|
|
|
|
}
|
|
|
|
else if ( point->out_dir == point->in_dir )
|
|
|
|
{
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
if ( point->out_dir != AF_DIR_NONE )
|
|
|
|
goto Is_Weak_Point;
|
|
|
|
|
2006-11-02 18:21:02 +01:00
|
|
|
if ( ft_corner_is_flat( in_x, in_y, out_x, out_y ) )
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
goto Is_Weak_Point;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
else if ( point->in_dir == -point->out_dir )
|
|
|
|
goto Is_Weak_Point;
|
2007-06-11 07:37:35 +02:00
|
|
|
|
|
|
|
in_x = out_x;
|
|
|
|
in_y = out_y;
|
|
|
|
prev = point;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Store the hinted outline in an FT_Outline structure. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2005-03-02 12:24:23 +01:00
|
|
|
af_glyph_hints_save( AF_GlyphHints hints,
|
|
|
|
FT_Outline* outline )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_Point point = hints->points;
|
|
|
|
AF_Point limit = point + hints->num_points;
|
|
|
|
FT_Vector* vec = outline->points;
|
|
|
|
char* tag = outline->tags;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
for ( ; point < limit; point++, vec++, tag++ )
|
|
|
|
{
|
* Jamfile: removing otvalid from the list of compiled modules
* include/freetype/internal/ftserv.h: added compiler pragmas to get rid
of annoying warnings with Visual C++ compiler in maximum warning mode
* src/autofit/afhints.c, src/autofit/aflatin.c, src/base/ftstroke.c,
src/bdf/bdfdrivr.c, src/cache/ftcbasic.c, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffload.c, src/cid/cidload.c,
src/lzw/zopen.c, src/otvalid/otvgdef.c, src/pcf/pcfread.c,
src/sfnt/sfobjs.c, src/truetype/ttgxvar.c: removing compiler warnings
2005-05-01 12:11:32 +02:00
|
|
|
vec->x = point->x;
|
|
|
|
vec->y = point->y;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
if ( point->flags & AF_FLAG_CONIC )
|
|
|
|
tag[0] = FT_CURVE_TAG_CONIC;
|
|
|
|
else if ( point->flags & AF_FLAG_CUBIC )
|
|
|
|
tag[0] = FT_CURVE_TAG_CUBIC;
|
|
|
|
else
|
|
|
|
tag[0] = FT_CURVE_TAG_ON;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* EDGE POINT GRID-FITTING
|
|
|
|
*
|
|
|
|
****************************************************************/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Align all points of an edge to the same coordinate value, */
|
|
|
|
/* either horizontally or vertically. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim )
|
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
AF_AxisHints axis = & hints->axis[dim];
|
|
|
|
AF_Segment segments = axis->segments;
|
|
|
|
AF_Segment segment_limit = segments + axis->num_segments;
|
|
|
|
AF_Segment seg;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
for ( seg = segments; seg < segment_limit; seg++ )
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
AF_Edge edge = seg->edge;
|
|
|
|
AF_Point point, first, last;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( edge == NULL )
|
|
|
|
continue;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
first = seg->first;
|
|
|
|
last = seg->last;
|
|
|
|
point = first;
|
2004-03-27 09:43:17 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
point->x = edge->pos;
|
|
|
|
point->flags |= AF_FLAG_TOUCH_X;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( point == last )
|
2004-03-27 09:43:17 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
point = point->next;
|
|
|
|
}
|
2007-06-11 07:37:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( seg = segments; seg < segment_limit; seg++ )
|
|
|
|
{
|
|
|
|
AF_Edge edge = seg->edge;
|
|
|
|
AF_Point point, first, last;
|
|
|
|
|
|
|
|
|
|
|
|
if ( edge == NULL )
|
|
|
|
continue;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
first = seg->first;
|
|
|
|
last = seg->last;
|
|
|
|
point = first;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
point->y = edge->pos;
|
|
|
|
point->flags |= AF_FLAG_TOUCH_Y;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( point == last )
|
|
|
|
break;
|
|
|
|
|
|
|
|
point = point->next;
|
|
|
|
}
|
|
|
|
}
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* STRONG POINT INTERPOLATION
|
|
|
|
*
|
|
|
|
****************************************************************/
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Hint the strong points -- this is equivalent to the TrueType `IP' */
|
|
|
|
/* hinting instruction. */
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim )
|
|
|
|
{
|
|
|
|
AF_Point points = hints->points;
|
|
|
|
AF_Point point_limit = points + hints->num_points;
|
|
|
|
AF_AxisHints axis = &hints->axis[dim];
|
|
|
|
AF_Edge edges = axis->edges;
|
|
|
|
AF_Edge edge_limit = edges + axis->num_edges;
|
|
|
|
AF_Flags touch_flag;
|
|
|
|
|
|
|
|
|
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
|
|
|
touch_flag = AF_FLAG_TOUCH_X;
|
|
|
|
else
|
|
|
|
touch_flag = AF_FLAG_TOUCH_Y;
|
|
|
|
|
|
|
|
if ( edges < edge_limit )
|
|
|
|
{
|
|
|
|
AF_Point point;
|
|
|
|
AF_Edge edge;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
{
|
|
|
|
FT_Pos u, ou, fu; /* point position */
|
|
|
|
FT_Pos delta;
|
|
|
|
|
|
|
|
|
|
|
|
if ( point->flags & touch_flag )
|
|
|
|
continue;
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/* if this point is candidate to weak interpolation, we */
|
2004-03-27 09:43:17 +01:00
|
|
|
/* interpolate it after all strong points have been processed */
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) &&
|
|
|
|
!( point->flags & AF_FLAG_INFLECTION ) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( dim == AF_DIMENSION_VERT )
|
|
|
|
{
|
|
|
|
u = point->fy;
|
|
|
|
ou = point->oy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u = point->fx;
|
|
|
|
ou = point->ox;
|
|
|
|
}
|
|
|
|
|
|
|
|
fu = u;
|
|
|
|
|
|
|
|
/* is the point before the first edge? */
|
|
|
|
edge = edges;
|
|
|
|
delta = edge->fpos - u;
|
|
|
|
if ( delta >= 0 )
|
|
|
|
{
|
|
|
|
u = edge->pos - ( edge->opos - ou );
|
|
|
|
goto Store_Point;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is the point after the last edge? */
|
|
|
|
edge = edge_limit - 1;
|
|
|
|
delta = u - edge->fpos;
|
|
|
|
if ( delta >= 0 )
|
|
|
|
{
|
|
|
|
u = edge->pos + ( ou - edge->opos );
|
|
|
|
goto Store_Point;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2009-07-31 17:32:07 +02:00
|
|
|
FT_PtrDist min, max, mid;
|
|
|
|
FT_Pos fpos;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* find enclosing edges */
|
|
|
|
min = 0;
|
|
|
|
max = edge_limit - edges;
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
#if 1
|
2011-02-16 21:59:44 +01:00
|
|
|
/* for a small number of edges, a linear search is better */
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( max <= 8 )
|
|
|
|
{
|
2009-07-31 17:32:07 +02:00
|
|
|
FT_PtrDist nn;
|
2007-06-11 07:37:35 +02:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
for ( nn = 0; nn < max; nn++ )
|
|
|
|
if ( edges[nn].fpos >= u )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( edges[nn].fpos == u )
|
|
|
|
{
|
|
|
|
u = edges[nn].pos;
|
|
|
|
goto Store_Point;
|
|
|
|
}
|
|
|
|
min = nn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2004-03-27 09:43:17 +01:00
|
|
|
while ( min < max )
|
|
|
|
{
|
|
|
|
mid = ( max + min ) >> 1;
|
|
|
|
edge = edges + mid;
|
|
|
|
fpos = edge->fpos;
|
|
|
|
|
|
|
|
if ( u < fpos )
|
|
|
|
max = mid;
|
|
|
|
else if ( u > fpos )
|
|
|
|
min = mid + 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* we are on the edge */
|
|
|
|
u = edge->pos;
|
|
|
|
goto Store_Point;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* point is not on an edge */
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
|
|
|
AF_Edge before = edges + min - 1;
|
|
|
|
AF_Edge after = edges + min + 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* assert( before && after && before != after ) */
|
|
|
|
if ( before->scale == 0 )
|
|
|
|
before->scale = FT_DivFix( after->pos - before->pos,
|
|
|
|
after->fpos - before->fpos );
|
|
|
|
|
|
|
|
u = before->pos + FT_MulFix( fu - before->fpos,
|
|
|
|
before->scale );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Store_Point:
|
|
|
|
/* save the point position */
|
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
|
|
|
point->x = u;
|
|
|
|
else
|
|
|
|
point->y = u;
|
|
|
|
|
|
|
|
point->flags |= touch_flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* WEAK POINT INTERPOLATION
|
|
|
|
*
|
|
|
|
****************************************************************/
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Shift the original coordinates of all points between `p1' and */
|
|
|
|
/* `p2' to get hinted coordinates, using the same difference as */
|
|
|
|
/* given by `ref'. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
static void
|
|
|
|
af_iup_shift( AF_Point p1,
|
|
|
|
AF_Point p2,
|
|
|
|
AF_Point ref )
|
|
|
|
{
|
|
|
|
AF_Point p;
|
|
|
|
FT_Pos delta = ref->u - ref->v;
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( delta == 0 )
|
2007-06-11 07:37:35 +02:00
|
|
|
return;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( p = p1; p < ref; p++ )
|
|
|
|
p->u = p->v + delta;
|
|
|
|
|
|
|
|
for ( p = ref + 1; p <= p2; p++ )
|
|
|
|
p->u = p->v + delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Interpolate the original coordinates of all points between `p1' and */
|
|
|
|
/* `p2' to get hinted coordinates, using `ref1' and `ref2' as the */
|
|
|
|
/* reference points. The `u' and `v' members are the current and */
|
|
|
|
/* original coordinate values, respectively. */
|
|
|
|
/* */
|
|
|
|
/* Details can be found in the TrueType bytecode specification. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
static void
|
|
|
|
af_iup_interp( AF_Point p1,
|
|
|
|
AF_Point p2,
|
|
|
|
AF_Point ref1,
|
|
|
|
AF_Point ref2 )
|
|
|
|
{
|
|
|
|
AF_Point p;
|
|
|
|
FT_Pos u;
|
|
|
|
FT_Pos v1 = ref1->v;
|
|
|
|
FT_Pos v2 = ref2->v;
|
|
|
|
FT_Pos d1 = ref1->u - v1;
|
|
|
|
FT_Pos d2 = ref2->u - v2;
|
|
|
|
|
|
|
|
|
|
|
|
if ( p1 > p2 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( v1 == v2 )
|
|
|
|
{
|
|
|
|
for ( p = p1; p <= p2; p++ )
|
|
|
|
{
|
|
|
|
u = p->v;
|
|
|
|
|
|
|
|
if ( u <= v1 )
|
|
|
|
u += d1;
|
|
|
|
else
|
|
|
|
u += d2;
|
|
|
|
|
|
|
|
p->u = u;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( v1 < v2 )
|
|
|
|
{
|
|
|
|
for ( p = p1; p <= p2; p++ )
|
|
|
|
{
|
|
|
|
u = p->v;
|
|
|
|
|
|
|
|
if ( u <= v1 )
|
|
|
|
u += d1;
|
|
|
|
else if ( u >= v2 )
|
|
|
|
u += d2;
|
|
|
|
else
|
|
|
|
u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 );
|
|
|
|
|
|
|
|
p->u = u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( p = p1; p <= p2; p++ )
|
|
|
|
{
|
|
|
|
u = p->v;
|
|
|
|
|
|
|
|
if ( u <= v2 )
|
|
|
|
u += d2;
|
|
|
|
else if ( u >= v1 )
|
|
|
|
u += d1;
|
|
|
|
else
|
|
|
|
u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 );
|
|
|
|
|
|
|
|
p->u = u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* Hint the weak points -- this is equivalent to the TrueType `IUP' */
|
|
|
|
/* hinting instruction. */
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim )
|
|
|
|
{
|
2005-03-03 18:09:08 +01:00
|
|
|
AF_Point points = hints->points;
|
|
|
|
AF_Point point_limit = points + hints->num_points;
|
|
|
|
AF_Point* contour = hints->contours;
|
|
|
|
AF_Point* contour_limit = contour + hints->num_contours;
|
|
|
|
AF_Flags touch_flag;
|
|
|
|
AF_Point point;
|
|
|
|
AF_Point end_point;
|
|
|
|
AF_Point first_point;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* PASS 1: Move segment points to edge positions */
|
|
|
|
|
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
|
|
|
{
|
|
|
|
touch_flag = AF_FLAG_TOUCH_X;
|
|
|
|
|
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
{
|
|
|
|
point->u = point->x;
|
|
|
|
point->v = point->ox;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
touch_flag = AF_FLAG_TOUCH_Y;
|
|
|
|
|
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
{
|
|
|
|
point->u = point->y;
|
|
|
|
point->v = point->oy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-02 12:24:23 +01:00
|
|
|
point = points;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
|
|
|
for ( ; contour < contour_limit; contour++ )
|
|
|
|
{
|
2007-06-11 23:15:09 +02:00
|
|
|
AF_Point first_touched, last_touched;
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
point = *contour;
|
|
|
|
end_point = point->prev;
|
|
|
|
first_point = point;
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
/* find first touched point */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ( point > end_point ) /* no touched point in contour */
|
|
|
|
goto NextContour;
|
|
|
|
|
|
|
|
if ( point->flags & touch_flag )
|
|
|
|
break;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
point++;
|
2007-06-11 07:37:35 +02:00
|
|
|
}
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
first_touched = point;
|
|
|
|
last_touched = point;
|
|
|
|
|
|
|
|
for (;;)
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2011-02-16 21:59:44 +01:00
|
|
|
FT_ASSERT( point <= end_point &&
|
2007-06-11 23:15:09 +02:00
|
|
|
( point->flags & touch_flag ) != 0 );
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2011-02-16 21:59:44 +01:00
|
|
|
/* skip any touched neighbours */
|
|
|
|
while ( point < end_point &&
|
|
|
|
( point[1].flags & touch_flag ) != 0 )
|
2007-06-11 07:37:35 +02:00
|
|
|
point++;
|
2004-03-27 09:43:17 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
last_touched = point;
|
|
|
|
|
|
|
|
/* find the next touched point, if any */
|
2011-02-16 21:59:44 +01:00
|
|
|
point++;
|
2007-06-11 07:37:35 +02:00
|
|
|
for (;;)
|
2004-03-27 09:43:17 +01:00
|
|
|
{
|
2007-06-11 07:37:35 +02:00
|
|
|
if ( point > end_point )
|
|
|
|
goto EndContour;
|
|
|
|
|
2007-06-11 23:15:09 +02:00
|
|
|
if ( ( point->flags & touch_flag ) != 0 )
|
2007-06-11 07:37:35 +02:00
|
|
|
break;
|
|
|
|
|
2004-03-27 09:43:17 +01:00
|
|
|
point++;
|
|
|
|
}
|
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
/* interpolate between last_touched and point */
|
|
|
|
af_iup_interp( last_touched + 1, point - 1,
|
|
|
|
last_touched, point );
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
2007-06-11 07:37:35 +02:00
|
|
|
|
|
|
|
EndContour:
|
|
|
|
/* special case: only one point was touched */
|
|
|
|
if ( last_touched == first_touched )
|
|
|
|
af_iup_shift( first_point, end_point, first_touched );
|
2011-02-16 21:59:44 +01:00
|
|
|
|
2007-06-11 07:37:35 +02:00
|
|
|
else /* interpolate the last part */
|
|
|
|
{
|
|
|
|
if ( last_touched < end_point )
|
|
|
|
af_iup_interp( last_touched + 1, end_point,
|
|
|
|
last_touched, first_touched );
|
|
|
|
|
|
|
|
if ( first_touched > points )
|
|
|
|
af_iup_interp( first_point, first_touched - 1,
|
|
|
|
last_touched, first_touched );
|
|
|
|
}
|
|
|
|
|
|
|
|
NextContour:
|
|
|
|
;
|
2004-03-27 09:43:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now save the interpolated values back to x/y */
|
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
|
|
|
{
|
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
point->x = point->u;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( point = points; point < point_limit; point++ )
|
|
|
|
point->y = point->u;
|
|
|
|
}
|
|
|
|
}
|
2005-03-02 12:24:23 +01:00
|
|
|
|
2006-01-22 07:58:16 +01:00
|
|
|
|
2011-03-02 03:52:36 +01:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
2006-01-22 07:58:16 +01:00
|
|
|
|
2011-02-20 07:30:46 +01:00
|
|
|
/* Apply (small) warp scale and warp delta for given dimension. */
|
|
|
|
|
2006-01-21 15:31:45 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
|
|
|
af_glyph_hints_scale_dim( AF_GlyphHints hints,
|
|
|
|
AF_Dimension dim,
|
|
|
|
FT_Fixed scale,
|
|
|
|
FT_Pos delta )
|
|
|
|
{
|
|
|
|
AF_Point points = hints->points;
|
|
|
|
AF_Point points_limit = points + hints->num_points;
|
|
|
|
AF_Point point;
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
|
2006-01-22 07:58:16 +01:00
|
|
|
|
2006-01-21 15:31:45 +01:00
|
|
|
if ( dim == AF_DIMENSION_HORZ )
|
|
|
|
{
|
|
|
|
for ( point = points; point < points_limit; point++ )
|
|
|
|
point->x = FT_MulFix( point->fx, scale ) + delta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( point = points; point < points_limit; point++ )
|
|
|
|
point->y = FT_MulFix( point->fy, scale ) + delta;
|
|
|
|
}
|
|
|
|
}
|
2006-01-22 07:58:16 +01:00
|
|
|
|
2011-03-02 03:52:36 +01:00
|
|
|
#endif /* AF_CONFIG_OPTION_USE_WARPER */
|
2005-03-02 12:24:23 +01:00
|
|
|
|
|
|
|
/* END */
|