mirror of
https://github.com/mcneel/opennurbs.git
synced 2026-04-20 21:26:36 +08:00
Add source code for rhino 6.8 release
This commit is contained in:
2195
freetype263/src/pshinter/pshalgo.c
Normal file
2195
freetype263/src/pshinter/pshalgo.c
Normal file
File diff suppressed because it is too large
Load Diff
241
freetype263/src/pshinter/pshalgo.h
Normal file
241
freetype263/src/pshinter/pshalgo.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshalgo.h */
|
||||
/* */
|
||||
/* PostScript hinting algorithm (specification). */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSHALGO_H_
|
||||
#define PSHALGO_H_
|
||||
|
||||
|
||||
#include "pshrec.h"
|
||||
#include "pshglob.h"
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/* handle to Hint structure */
|
||||
typedef struct PSH_HintRec_* PSH_Hint;
|
||||
|
||||
|
||||
/* hint bit-flags */
|
||||
#define PSH_HINT_GHOST PS_HINT_FLAG_GHOST
|
||||
#define PSH_HINT_BOTTOM PS_HINT_FLAG_BOTTOM
|
||||
#define PSH_HINT_ACTIVE 4U
|
||||
#define PSH_HINT_FITTED 8U
|
||||
|
||||
|
||||
#define psh_hint_is_active( x ) ( ( (x)->flags & PSH_HINT_ACTIVE ) != 0 )
|
||||
#define psh_hint_is_ghost( x ) ( ( (x)->flags & PSH_HINT_GHOST ) != 0 )
|
||||
#define psh_hint_is_fitted( x ) ( ( (x)->flags & PSH_HINT_FITTED ) != 0 )
|
||||
|
||||
#define psh_hint_activate( x ) (x)->flags |= PSH_HINT_ACTIVE
|
||||
#define psh_hint_deactivate( x ) (x)->flags &= ~PSH_HINT_ACTIVE
|
||||
#define psh_hint_set_fitted( x ) (x)->flags |= PSH_HINT_FITTED
|
||||
|
||||
|
||||
/* hint structure */
|
||||
typedef struct PSH_HintRec_
|
||||
{
|
||||
FT_Int org_pos;
|
||||
FT_Int org_len;
|
||||
FT_Pos cur_pos;
|
||||
FT_Pos cur_len;
|
||||
FT_UInt flags;
|
||||
PSH_Hint parent;
|
||||
FT_Int order;
|
||||
|
||||
} PSH_HintRec;
|
||||
|
||||
|
||||
/* this is an interpolation zone used for strong points; */
|
||||
/* weak points are interpolated according to their strong */
|
||||
/* neighbours */
|
||||
typedef struct PSH_ZoneRec_
|
||||
{
|
||||
FT_Fixed scale;
|
||||
FT_Fixed delta;
|
||||
FT_Pos min;
|
||||
FT_Pos max;
|
||||
|
||||
} PSH_ZoneRec, *PSH_Zone;
|
||||
|
||||
|
||||
typedef struct PSH_Hint_TableRec_
|
||||
{
|
||||
FT_UInt max_hints;
|
||||
FT_UInt num_hints;
|
||||
PSH_Hint hints;
|
||||
PSH_Hint* sort;
|
||||
PSH_Hint* sort_global;
|
||||
FT_UInt num_zones;
|
||||
PSH_ZoneRec* zones;
|
||||
PSH_Zone zone;
|
||||
PS_Mask_Table hint_masks;
|
||||
PS_Mask_Table counter_masks;
|
||||
|
||||
} PSH_Hint_TableRec, *PSH_Hint_Table;
|
||||
|
||||
|
||||
typedef struct PSH_PointRec_* PSH_Point;
|
||||
typedef struct PSH_ContourRec_* PSH_Contour;
|
||||
|
||||
enum
|
||||
{
|
||||
PSH_DIR_NONE = 4,
|
||||
PSH_DIR_UP = -1,
|
||||
PSH_DIR_DOWN = 1,
|
||||
PSH_DIR_LEFT = -2,
|
||||
PSH_DIR_RIGHT = 2
|
||||
};
|
||||
|
||||
#define PSH_DIR_HORIZONTAL 2
|
||||
#define PSH_DIR_VERTICAL 1
|
||||
|
||||
#define PSH_DIR_COMPARE( d1, d2 ) ( (d1) == (d2) || (d1) == -(d2) )
|
||||
#define PSH_DIR_IS_HORIZONTAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_HORIZONTAL )
|
||||
#define PSH_DIR_IS_VERTICAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_VERTICAL )
|
||||
|
||||
|
||||
/* the following bit-flags are computed once by the glyph */
|
||||
/* analyzer, for both dimensions */
|
||||
#define PSH_POINT_OFF 1U /* point is off the curve */
|
||||
#define PSH_POINT_SMOOTH 2U /* point is smooth */
|
||||
#define PSH_POINT_INFLEX 4U /* point is inflection */
|
||||
|
||||
|
||||
#define psh_point_is_smooth( p ) ( (p)->flags & PSH_POINT_SMOOTH )
|
||||
#define psh_point_is_off( p ) ( (p)->flags & PSH_POINT_OFF )
|
||||
#define psh_point_is_inflex( p ) ( (p)->flags & PSH_POINT_INFLEX )
|
||||
|
||||
#define psh_point_set_smooth( p ) (p)->flags |= PSH_POINT_SMOOTH
|
||||
#define psh_point_set_off( p ) (p)->flags |= PSH_POINT_OFF
|
||||
#define psh_point_set_inflex( p ) (p)->flags |= PSH_POINT_INFLEX
|
||||
|
||||
|
||||
/* the following bit-flags are re-computed for each dimension */
|
||||
#define PSH_POINT_STRONG 16U /* point is strong */
|
||||
#define PSH_POINT_FITTED 32U /* point is already fitted */
|
||||
#define PSH_POINT_EXTREMUM 64U /* point is local extremum */
|
||||
#define PSH_POINT_POSITIVE 128U /* extremum has positive contour flow */
|
||||
#define PSH_POINT_NEGATIVE 256U /* extremum has negative contour flow */
|
||||
#define PSH_POINT_EDGE_MIN 512U /* point is aligned to left/bottom stem edge */
|
||||
#define PSH_POINT_EDGE_MAX 1024U /* point is aligned to top/right stem edge */
|
||||
|
||||
|
||||
#define psh_point_is_strong( p ) ( (p)->flags2 & PSH_POINT_STRONG )
|
||||
#define psh_point_is_fitted( p ) ( (p)->flags2 & PSH_POINT_FITTED )
|
||||
#define psh_point_is_extremum( p ) ( (p)->flags2 & PSH_POINT_EXTREMUM )
|
||||
#define psh_point_is_positive( p ) ( (p)->flags2 & PSH_POINT_POSITIVE )
|
||||
#define psh_point_is_negative( p ) ( (p)->flags2 & PSH_POINT_NEGATIVE )
|
||||
#define psh_point_is_edge_min( p ) ( (p)->flags2 & PSH_POINT_EDGE_MIN )
|
||||
#define psh_point_is_edge_max( p ) ( (p)->flags2 & PSH_POINT_EDGE_MAX )
|
||||
|
||||
#define psh_point_set_strong( p ) (p)->flags2 |= PSH_POINT_STRONG
|
||||
#define psh_point_set_fitted( p ) (p)->flags2 |= PSH_POINT_FITTED
|
||||
#define psh_point_set_extremum( p ) (p)->flags2 |= PSH_POINT_EXTREMUM
|
||||
#define psh_point_set_positive( p ) (p)->flags2 |= PSH_POINT_POSITIVE
|
||||
#define psh_point_set_negative( p ) (p)->flags2 |= PSH_POINT_NEGATIVE
|
||||
#define psh_point_set_edge_min( p ) (p)->flags2 |= PSH_POINT_EDGE_MIN
|
||||
#define psh_point_set_edge_max( p ) (p)->flags2 |= PSH_POINT_EDGE_MAX
|
||||
|
||||
|
||||
typedef struct PSH_PointRec_
|
||||
{
|
||||
PSH_Point prev;
|
||||
PSH_Point next;
|
||||
PSH_Contour contour;
|
||||
FT_UInt flags;
|
||||
FT_UInt flags2;
|
||||
FT_Char dir_in;
|
||||
FT_Char dir_out;
|
||||
PSH_Hint hint;
|
||||
FT_Pos org_u;
|
||||
FT_Pos org_v;
|
||||
FT_Pos cur_u;
|
||||
#ifdef DEBUG_HINTER
|
||||
FT_Pos org_x;
|
||||
FT_Pos cur_x;
|
||||
FT_Pos org_y;
|
||||
FT_Pos cur_y;
|
||||
FT_UInt flags_x;
|
||||
FT_UInt flags_y;
|
||||
#endif
|
||||
|
||||
} PSH_PointRec;
|
||||
|
||||
|
||||
typedef struct PSH_ContourRec_
|
||||
{
|
||||
PSH_Point start;
|
||||
FT_UInt count;
|
||||
|
||||
} PSH_ContourRec;
|
||||
|
||||
|
||||
typedef struct PSH_GlyphRec_
|
||||
{
|
||||
FT_UInt num_points;
|
||||
FT_UInt num_contours;
|
||||
|
||||
PSH_Point points;
|
||||
PSH_Contour contours;
|
||||
|
||||
FT_Memory memory;
|
||||
FT_Outline* outline;
|
||||
PSH_Globals globals;
|
||||
PSH_Hint_TableRec hint_tables[2];
|
||||
|
||||
FT_Bool vertical;
|
||||
FT_Int major_dir;
|
||||
FT_Int minor_dir;
|
||||
|
||||
FT_Bool do_horz_hints;
|
||||
FT_Bool do_vert_hints;
|
||||
FT_Bool do_horz_snapping;
|
||||
FT_Bool do_vert_snapping;
|
||||
FT_Bool do_stem_adjust;
|
||||
|
||||
} PSH_GlyphRec, *PSH_Glyph;
|
||||
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
extern PSH_Hint_Table ps_debug_hint_table;
|
||||
|
||||
typedef void
|
||||
(*PSH_HintFunc)( PSH_Hint hint,
|
||||
FT_Bool vertical );
|
||||
|
||||
extern PSH_HintFunc ps_debug_hint_func;
|
||||
|
||||
extern PSH_Glyph ps_debug_glyph;
|
||||
#endif
|
||||
|
||||
|
||||
extern FT_Error
|
||||
ps_hints_apply( PS_Hints ps_hints,
|
||||
FT_Outline* outline,
|
||||
PSH_Globals globals,
|
||||
FT_Render_Mode hint_mode );
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* PSHALGO_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
795
freetype263/src/pshinter/pshglob.c
Normal file
795
freetype263/src/pshinter/pshglob.c
Normal file
@@ -0,0 +1,795 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshglob.c */
|
||||
/* */
|
||||
/* PostScript hinter global hinting management (body). */
|
||||
/* Inspired by the new auto-hinter module. */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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_FREETYPE_H
|
||||
#include FT_INTERNAL_OBJECTS_H
|
||||
#include "pshglob.h"
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
PSH_Globals ps_debug_globals = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** STANDARD WIDTHS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* scale the widths/heights table */
|
||||
static void
|
||||
psh_globals_scale_widths( PSH_Globals globals,
|
||||
FT_UInt direction )
|
||||
{
|
||||
PSH_Dimension dim = &globals->dimension[direction];
|
||||
PSH_Widths stdw = &dim->stdw;
|
||||
FT_UInt count = stdw->count;
|
||||
PSH_Width width = stdw->widths;
|
||||
PSH_Width stand = width; /* standard width/height */
|
||||
FT_Fixed scale = dim->scale_mult;
|
||||
|
||||
|
||||
if ( count > 0 )
|
||||
{
|
||||
width->cur = FT_MulFix( width->org, scale );
|
||||
width->fit = FT_PIX_ROUND( width->cur );
|
||||
|
||||
width++;
|
||||
count--;
|
||||
|
||||
for ( ; count > 0; count--, width++ )
|
||||
{
|
||||
FT_Pos w, dist;
|
||||
|
||||
|
||||
w = FT_MulFix( width->org, scale );
|
||||
dist = w - stand->cur;
|
||||
|
||||
if ( dist < 0 )
|
||||
dist = -dist;
|
||||
|
||||
if ( dist < 128 )
|
||||
w = stand->cur;
|
||||
|
||||
width->cur = w;
|
||||
width->fit = FT_PIX_ROUND( w );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* org_width is is font units, result in device pixels, 26.6 format */
|
||||
FT_LOCAL_DEF( FT_Pos )
|
||||
psh_dimension_snap_width( PSH_Dimension dimension,
|
||||
FT_Int org_width )
|
||||
{
|
||||
FT_UInt n;
|
||||
FT_Pos width = FT_MulFix( org_width, dimension->scale_mult );
|
||||
FT_Pos best = 64 + 32 + 2;
|
||||
FT_Pos reference = width;
|
||||
|
||||
|
||||
for ( n = 0; n < dimension->stdw.count; n++ )
|
||||
{
|
||||
FT_Pos w;
|
||||
FT_Pos dist;
|
||||
|
||||
|
||||
w = dimension->stdw.widths[n].cur;
|
||||
dist = width - w;
|
||||
if ( dist < 0 )
|
||||
dist = -dist;
|
||||
if ( dist < best )
|
||||
{
|
||||
best = dist;
|
||||
reference = w;
|
||||
}
|
||||
}
|
||||
|
||||
if ( width >= reference )
|
||||
{
|
||||
width -= 0x21;
|
||||
if ( width < reference )
|
||||
width = reference;
|
||||
}
|
||||
else
|
||||
{
|
||||
width += 0x21;
|
||||
if ( width > reference )
|
||||
width = reference;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** BLUE ZONES *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
static void
|
||||
psh_blues_set_zones_0( PSH_Blues target,
|
||||
FT_Bool is_others,
|
||||
FT_UInt read_count,
|
||||
FT_Short* read,
|
||||
PSH_Blue_Table top_table,
|
||||
PSH_Blue_Table bot_table )
|
||||
{
|
||||
FT_UInt count_top = top_table->count;
|
||||
FT_UInt count_bot = bot_table->count;
|
||||
FT_Bool first = 1;
|
||||
|
||||
FT_UNUSED( target );
|
||||
|
||||
|
||||
for ( ; read_count > 1; read_count -= 2 )
|
||||
{
|
||||
FT_Int reference, delta;
|
||||
FT_UInt count;
|
||||
PSH_Blue_Zone zones, zone;
|
||||
FT_Bool top;
|
||||
|
||||
|
||||
/* read blue zone entry, and select target top/bottom zone */
|
||||
top = 0;
|
||||
if ( first || is_others )
|
||||
{
|
||||
reference = read[1];
|
||||
delta = read[0] - reference;
|
||||
|
||||
zones = bot_table->zones;
|
||||
count = count_bot;
|
||||
first = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
reference = read[0];
|
||||
delta = read[1] - reference;
|
||||
|
||||
zones = top_table->zones;
|
||||
count = count_top;
|
||||
top = 1;
|
||||
}
|
||||
|
||||
/* insert into sorted table */
|
||||
zone = zones;
|
||||
for ( ; count > 0; count--, zone++ )
|
||||
{
|
||||
if ( reference < zone->org_ref )
|
||||
break;
|
||||
|
||||
if ( reference == zone->org_ref )
|
||||
{
|
||||
FT_Int delta0 = zone->org_delta;
|
||||
|
||||
|
||||
/* we have two zones on the same reference position -- */
|
||||
/* only keep the largest one */
|
||||
if ( delta < 0 )
|
||||
{
|
||||
if ( delta < delta0 )
|
||||
zone->org_delta = delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( delta > delta0 )
|
||||
zone->org_delta = delta;
|
||||
}
|
||||
goto Skip;
|
||||
}
|
||||
}
|
||||
|
||||
for ( ; count > 0; count-- )
|
||||
zone[count] = zone[count-1];
|
||||
|
||||
zone->org_ref = reference;
|
||||
zone->org_delta = delta;
|
||||
|
||||
if ( top )
|
||||
count_top++;
|
||||
else
|
||||
count_bot++;
|
||||
|
||||
Skip:
|
||||
read += 2;
|
||||
}
|
||||
|
||||
top_table->count = count_top;
|
||||
bot_table->count = count_bot;
|
||||
}
|
||||
|
||||
|
||||
/* Re-read blue zones from the original fonts and store them into out */
|
||||
/* private structure. This function re-orders, sanitizes and */
|
||||
/* fuzz-expands the zones as well. */
|
||||
static void
|
||||
psh_blues_set_zones( PSH_Blues target,
|
||||
FT_UInt count,
|
||||
FT_Short* blues,
|
||||
FT_UInt count_others,
|
||||
FT_Short* other_blues,
|
||||
FT_Int fuzz,
|
||||
FT_Int family )
|
||||
{
|
||||
PSH_Blue_Table top_table, bot_table;
|
||||
FT_UInt count_top, count_bot;
|
||||
|
||||
|
||||
if ( family )
|
||||
{
|
||||
top_table = &target->family_top;
|
||||
bot_table = &target->family_bottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
top_table = &target->normal_top;
|
||||
bot_table = &target->normal_bottom;
|
||||
}
|
||||
|
||||
/* read the input blue zones, and build two sorted tables */
|
||||
/* (one for the top zones, the other for the bottom zones) */
|
||||
top_table->count = 0;
|
||||
bot_table->count = 0;
|
||||
|
||||
/* first, the blues */
|
||||
psh_blues_set_zones_0( target, 0,
|
||||
count, blues, top_table, bot_table );
|
||||
psh_blues_set_zones_0( target, 1,
|
||||
count_others, other_blues, top_table, bot_table );
|
||||
|
||||
count_top = top_table->count;
|
||||
count_bot = bot_table->count;
|
||||
|
||||
/* sanitize top table */
|
||||
if ( count_top > 0 )
|
||||
{
|
||||
PSH_Blue_Zone zone = top_table->zones;
|
||||
|
||||
|
||||
for ( count = count_top; count > 0; count--, zone++ )
|
||||
{
|
||||
FT_Int delta;
|
||||
|
||||
|
||||
if ( count > 1 )
|
||||
{
|
||||
delta = zone[1].org_ref - zone[0].org_ref;
|
||||
if ( zone->org_delta > delta )
|
||||
zone->org_delta = delta;
|
||||
}
|
||||
|
||||
zone->org_bottom = zone->org_ref;
|
||||
zone->org_top = zone->org_delta + zone->org_ref;
|
||||
}
|
||||
}
|
||||
|
||||
/* sanitize bottom table */
|
||||
if ( count_bot > 0 )
|
||||
{
|
||||
PSH_Blue_Zone zone = bot_table->zones;
|
||||
|
||||
|
||||
for ( count = count_bot; count > 0; count--, zone++ )
|
||||
{
|
||||
FT_Int delta;
|
||||
|
||||
|
||||
if ( count > 1 )
|
||||
{
|
||||
delta = zone[0].org_ref - zone[1].org_ref;
|
||||
if ( zone->org_delta < delta )
|
||||
zone->org_delta = delta;
|
||||
}
|
||||
|
||||
zone->org_top = zone->org_ref;
|
||||
zone->org_bottom = zone->org_delta + zone->org_ref;
|
||||
}
|
||||
}
|
||||
|
||||
/* expand top and bottom tables with blue fuzz */
|
||||
{
|
||||
FT_Int dim, top, bot, delta;
|
||||
PSH_Blue_Zone zone;
|
||||
|
||||
|
||||
zone = top_table->zones;
|
||||
count = count_top;
|
||||
|
||||
for ( dim = 1; dim >= 0; dim-- )
|
||||
{
|
||||
if ( count > 0 )
|
||||
{
|
||||
/* expand the bottom of the lowest zone normally */
|
||||
zone->org_bottom -= fuzz;
|
||||
|
||||
/* expand the top and bottom of intermediate zones; */
|
||||
/* checking that the interval is smaller than the fuzz */
|
||||
top = zone->org_top;
|
||||
|
||||
for ( count--; count > 0; count-- )
|
||||
{
|
||||
bot = zone[1].org_bottom;
|
||||
delta = bot - top;
|
||||
|
||||
if ( delta / 2 < fuzz )
|
||||
zone[0].org_top = zone[1].org_bottom = top + delta / 2;
|
||||
else
|
||||
{
|
||||
zone[0].org_top = top + fuzz;
|
||||
zone[1].org_bottom = bot - fuzz;
|
||||
}
|
||||
|
||||
zone++;
|
||||
top = zone->org_top;
|
||||
}
|
||||
|
||||
/* expand the top of the highest zone normally */
|
||||
zone->org_top = top + fuzz;
|
||||
}
|
||||
zone = bot_table->zones;
|
||||
count = count_bot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* reset the blues table when the device transform changes */
|
||||
static void
|
||||
psh_blues_scale_zones( PSH_Blues blues,
|
||||
FT_Fixed scale,
|
||||
FT_Pos delta )
|
||||
{
|
||||
FT_UInt count;
|
||||
FT_UInt num;
|
||||
PSH_Blue_Table table = NULL;
|
||||
|
||||
/* */
|
||||
/* Determine whether we need to suppress overshoots or */
|
||||
/* not. We simply need to compare the vertical scale */
|
||||
/* parameter to the raw bluescale value. Here is why: */
|
||||
/* */
|
||||
/* We need to suppress overshoots for all pointsizes. */
|
||||
/* At 300dpi that satisfies: */
|
||||
/* */
|
||||
/* pointsize < 240*bluescale + 0.49 */
|
||||
/* */
|
||||
/* This corresponds to: */
|
||||
/* */
|
||||
/* pixelsize < 1000*bluescale + 49/24 */
|
||||
/* */
|
||||
/* scale*EM_Size < 1000*bluescale + 49/24 */
|
||||
/* */
|
||||
/* However, for normal Type 1 fonts, EM_Size is 1000! */
|
||||
/* We thus only check: */
|
||||
/* */
|
||||
/* scale < bluescale + 49/24000 */
|
||||
/* */
|
||||
/* which we shorten to */
|
||||
/* */
|
||||
/* "scale < bluescale" */
|
||||
/* */
|
||||
/* Note that `blue_scale' is stored 1000 times its real */
|
||||
/* value, and that `scale' converts from font units to */
|
||||
/* fractional pixels. */
|
||||
/* */
|
||||
|
||||
/* 1000 / 64 = 125 / 8 */
|
||||
if ( scale >= 0x20C49BAL )
|
||||
blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 );
|
||||
else
|
||||
blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 );
|
||||
|
||||
/* */
|
||||
/* The blue threshold is the font units distance under */
|
||||
/* which overshoots are suppressed due to the BlueShift */
|
||||
/* even if the scale is greater than BlueScale. */
|
||||
/* */
|
||||
/* It is the smallest distance such that */
|
||||
/* */
|
||||
/* dist <= BlueShift && dist*scale <= 0.5 pixels */
|
||||
/* */
|
||||
{
|
||||
FT_Int threshold = blues->blue_shift;
|
||||
|
||||
|
||||
while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 )
|
||||
threshold--;
|
||||
|
||||
blues->blue_threshold = threshold;
|
||||
}
|
||||
|
||||
for ( num = 0; num < 4; num++ )
|
||||
{
|
||||
PSH_Blue_Zone zone;
|
||||
|
||||
|
||||
switch ( num )
|
||||
{
|
||||
case 0:
|
||||
table = &blues->normal_top;
|
||||
break;
|
||||
case 1:
|
||||
table = &blues->normal_bottom;
|
||||
break;
|
||||
case 2:
|
||||
table = &blues->family_top;
|
||||
break;
|
||||
default:
|
||||
table = &blues->family_bottom;
|
||||
break;
|
||||
}
|
||||
|
||||
zone = table->zones;
|
||||
count = table->count;
|
||||
for ( ; count > 0; count--, zone++ )
|
||||
{
|
||||
zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta;
|
||||
zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta;
|
||||
zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta;
|
||||
zone->cur_delta = FT_MulFix( zone->org_delta, scale );
|
||||
|
||||
/* round scaled reference position */
|
||||
zone->cur_ref = FT_PIX_ROUND( zone->cur_ref );
|
||||
|
||||
#if 0
|
||||
if ( zone->cur_ref > zone->cur_top )
|
||||
zone->cur_ref -= 64;
|
||||
else if ( zone->cur_ref < zone->cur_bottom )
|
||||
zone->cur_ref += 64;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* process the families now */
|
||||
|
||||
for ( num = 0; num < 2; num++ )
|
||||
{
|
||||
PSH_Blue_Zone zone1, zone2;
|
||||
FT_UInt count1, count2;
|
||||
PSH_Blue_Table normal, family;
|
||||
|
||||
|
||||
switch ( num )
|
||||
{
|
||||
case 0:
|
||||
normal = &blues->normal_top;
|
||||
family = &blues->family_top;
|
||||
break;
|
||||
|
||||
default:
|
||||
normal = &blues->normal_bottom;
|
||||
family = &blues->family_bottom;
|
||||
}
|
||||
|
||||
zone1 = normal->zones;
|
||||
count1 = normal->count;
|
||||
|
||||
for ( ; count1 > 0; count1--, zone1++ )
|
||||
{
|
||||
/* try to find a family zone whose reference position is less */
|
||||
/* than 1 pixel far from the current zone */
|
||||
zone2 = family->zones;
|
||||
count2 = family->count;
|
||||
|
||||
for ( ; count2 > 0; count2--, zone2++ )
|
||||
{
|
||||
FT_Pos Delta;
|
||||
|
||||
|
||||
Delta = zone1->org_ref - zone2->org_ref;
|
||||
if ( Delta < 0 )
|
||||
Delta = -Delta;
|
||||
|
||||
if ( FT_MulFix( Delta, scale ) < 64 )
|
||||
{
|
||||
zone1->cur_top = zone2->cur_top;
|
||||
zone1->cur_bottom = zone2->cur_bottom;
|
||||
zone1->cur_ref = zone2->cur_ref;
|
||||
zone1->cur_delta = zone2->cur_delta;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* calculate the maximum height of given blue zones */
|
||||
static FT_Short
|
||||
psh_calc_max_height( FT_UInt num,
|
||||
const FT_Short* values,
|
||||
FT_Short cur_max )
|
||||
{
|
||||
FT_UInt count;
|
||||
|
||||
|
||||
for ( count = 0; count < num; count += 2 )
|
||||
{
|
||||
FT_Short cur_height = values[count + 1] - values[count];
|
||||
|
||||
|
||||
if ( cur_height > cur_max )
|
||||
cur_max = cur_height;
|
||||
}
|
||||
|
||||
return cur_max;
|
||||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( void )
|
||||
psh_blues_snap_stem( PSH_Blues blues,
|
||||
FT_Int stem_top,
|
||||
FT_Int stem_bot,
|
||||
PSH_Alignment alignment )
|
||||
{
|
||||
PSH_Blue_Table table;
|
||||
FT_UInt count;
|
||||
FT_Pos delta;
|
||||
PSH_Blue_Zone zone;
|
||||
FT_Int no_shoots;
|
||||
|
||||
|
||||
alignment->align = PSH_BLUE_ALIGN_NONE;
|
||||
|
||||
no_shoots = blues->no_overshoots;
|
||||
|
||||
/* look up stem top in top zones table */
|
||||
table = &blues->normal_top;
|
||||
count = table->count;
|
||||
zone = table->zones;
|
||||
|
||||
for ( ; count > 0; count--, zone++ )
|
||||
{
|
||||
delta = stem_top - zone->org_bottom;
|
||||
if ( delta < -blues->blue_fuzz )
|
||||
break;
|
||||
|
||||
if ( stem_top <= zone->org_top + blues->blue_fuzz )
|
||||
{
|
||||
if ( no_shoots || delta <= blues->blue_threshold )
|
||||
{
|
||||
alignment->align |= PSH_BLUE_ALIGN_TOP;
|
||||
alignment->align_top = zone->cur_ref;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* look up stem bottom in bottom zones table */
|
||||
table = &blues->normal_bottom;
|
||||
count = table->count;
|
||||
zone = table->zones + count-1;
|
||||
|
||||
for ( ; count > 0; count--, zone-- )
|
||||
{
|
||||
delta = zone->org_top - stem_bot;
|
||||
if ( delta < -blues->blue_fuzz )
|
||||
break;
|
||||
|
||||
if ( stem_bot >= zone->org_bottom - blues->blue_fuzz )
|
||||
{
|
||||
if ( no_shoots || delta < blues->blue_threshold )
|
||||
{
|
||||
alignment->align |= PSH_BLUE_ALIGN_BOT;
|
||||
alignment->align_bot = zone->cur_ref;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** GLOBAL HINTS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
static void
|
||||
psh_globals_destroy( PSH_Globals globals )
|
||||
{
|
||||
if ( globals )
|
||||
{
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
memory = globals->memory;
|
||||
globals->dimension[0].stdw.count = 0;
|
||||
globals->dimension[1].stdw.count = 0;
|
||||
|
||||
globals->blues.normal_top.count = 0;
|
||||
globals->blues.normal_bottom.count = 0;
|
||||
globals->blues.family_top.count = 0;
|
||||
globals->blues.family_bottom.count = 0;
|
||||
|
||||
FT_FREE( globals );
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
ps_debug_globals = NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
psh_globals_new( FT_Memory memory,
|
||||
T1_Private* priv,
|
||||
PSH_Globals *aglobals )
|
||||
{
|
||||
PSH_Globals globals = NULL;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
if ( !FT_NEW( globals ) )
|
||||
{
|
||||
FT_UInt count;
|
||||
FT_Short* read;
|
||||
|
||||
|
||||
globals->memory = memory;
|
||||
|
||||
/* copy standard widths */
|
||||
{
|
||||
PSH_Dimension dim = &globals->dimension[1];
|
||||
PSH_Width write = dim->stdw.widths;
|
||||
|
||||
|
||||
write->org = priv->standard_width[0];
|
||||
write++;
|
||||
|
||||
read = priv->snap_widths;
|
||||
for ( count = priv->num_snap_widths; count > 0; count-- )
|
||||
{
|
||||
write->org = *read;
|
||||
write++;
|
||||
read++;
|
||||
}
|
||||
|
||||
dim->stdw.count = priv->num_snap_widths + 1;
|
||||
}
|
||||
|
||||
/* copy standard heights */
|
||||
{
|
||||
PSH_Dimension dim = &globals->dimension[0];
|
||||
PSH_Width write = dim->stdw.widths;
|
||||
|
||||
|
||||
write->org = priv->standard_height[0];
|
||||
write++;
|
||||
read = priv->snap_heights;
|
||||
for ( count = priv->num_snap_heights; count > 0; count-- )
|
||||
{
|
||||
write->org = *read;
|
||||
write++;
|
||||
read++;
|
||||
}
|
||||
|
||||
dim->stdw.count = priv->num_snap_heights + 1;
|
||||
}
|
||||
|
||||
/* copy blue zones */
|
||||
psh_blues_set_zones( &globals->blues, priv->num_blue_values,
|
||||
priv->blue_values, priv->num_other_blues,
|
||||
priv->other_blues, priv->blue_fuzz, 0 );
|
||||
|
||||
psh_blues_set_zones( &globals->blues, priv->num_family_blues,
|
||||
priv->family_blues, priv->num_family_other_blues,
|
||||
priv->family_other_blues, priv->blue_fuzz, 1 );
|
||||
|
||||
/* limit the BlueScale value to `1 / max_of_blue_zone_heights' */
|
||||
{
|
||||
FT_Fixed max_scale;
|
||||
FT_Short max_height = 1;
|
||||
|
||||
|
||||
max_height = psh_calc_max_height( priv->num_blue_values,
|
||||
priv->blue_values,
|
||||
max_height );
|
||||
max_height = psh_calc_max_height( priv->num_other_blues,
|
||||
priv->other_blues,
|
||||
max_height );
|
||||
max_height = psh_calc_max_height( priv->num_family_blues,
|
||||
priv->family_blues,
|
||||
max_height );
|
||||
max_height = psh_calc_max_height( priv->num_family_other_blues,
|
||||
priv->family_other_blues,
|
||||
max_height );
|
||||
|
||||
/* BlueScale is scaled 1000 times */
|
||||
max_scale = FT_DivFix( 1000, max_height );
|
||||
globals->blues.blue_scale = priv->blue_scale < max_scale
|
||||
? priv->blue_scale
|
||||
: max_scale;
|
||||
}
|
||||
|
||||
globals->blues.blue_shift = priv->blue_shift;
|
||||
globals->blues.blue_fuzz = priv->blue_fuzz;
|
||||
|
||||
globals->dimension[0].scale_mult = 0;
|
||||
globals->dimension[0].scale_delta = 0;
|
||||
globals->dimension[1].scale_mult = 0;
|
||||
globals->dimension[1].scale_delta = 0;
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
ps_debug_globals = globals;
|
||||
#endif
|
||||
}
|
||||
|
||||
*aglobals = globals;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( void )
|
||||
psh_globals_set_scale( PSH_Globals globals,
|
||||
FT_Fixed x_scale,
|
||||
FT_Fixed y_scale,
|
||||
FT_Fixed x_delta,
|
||||
FT_Fixed y_delta )
|
||||
{
|
||||
PSH_Dimension dim;
|
||||
|
||||
|
||||
dim = &globals->dimension[0];
|
||||
if ( x_scale != dim->scale_mult ||
|
||||
x_delta != dim->scale_delta )
|
||||
{
|
||||
dim->scale_mult = x_scale;
|
||||
dim->scale_delta = x_delta;
|
||||
|
||||
psh_globals_scale_widths( globals, 0 );
|
||||
}
|
||||
|
||||
dim = &globals->dimension[1];
|
||||
if ( y_scale != dim->scale_mult ||
|
||||
y_delta != dim->scale_delta )
|
||||
{
|
||||
dim->scale_mult = y_scale;
|
||||
dim->scale_delta = y_delta;
|
||||
|
||||
psh_globals_scale_widths( globals, 1 );
|
||||
psh_blues_scale_zones( &globals->blues, y_scale, y_delta );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( void )
|
||||
psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs )
|
||||
{
|
||||
funcs->create = psh_globals_new;
|
||||
funcs->set_scale = psh_globals_set_scale;
|
||||
funcs->destroy = psh_globals_destroy;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
196
freetype263/src/pshinter/pshglob.h
Normal file
196
freetype263/src/pshinter/pshglob.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshglob.h */
|
||||
/* */
|
||||
/* PostScript hinter global hinting management. */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSHGLOB_H_
|
||||
#define PSHGLOB_H_
|
||||
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** GLOBAL HINTS INTERNALS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* @constant: */
|
||||
/* PS_GLOBALS_MAX_BLUE_ZONES */
|
||||
/* */
|
||||
/* @description: */
|
||||
/* The maximum number of blue zones in a font global hints structure. */
|
||||
/* See @PS_Globals_BluesRec. */
|
||||
/* */
|
||||
#define PS_GLOBALS_MAX_BLUE_ZONES 16
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* @constant: */
|
||||
/* PS_GLOBALS_MAX_STD_WIDTHS */
|
||||
/* */
|
||||
/* @description: */
|
||||
/* The maximum number of standard and snap widths in either the */
|
||||
/* horizontal or vertical direction. See @PS_Globals_WidthsRec. */
|
||||
/* */
|
||||
#define PS_GLOBALS_MAX_STD_WIDTHS 16
|
||||
|
||||
|
||||
/* standard and snap width */
|
||||
typedef struct PSH_WidthRec_
|
||||
{
|
||||
FT_Int org;
|
||||
FT_Pos cur;
|
||||
FT_Pos fit;
|
||||
|
||||
} PSH_WidthRec, *PSH_Width;
|
||||
|
||||
|
||||
/* standard and snap widths table */
|
||||
typedef struct PSH_WidthsRec_
|
||||
{
|
||||
FT_UInt count;
|
||||
PSH_WidthRec widths[PS_GLOBALS_MAX_STD_WIDTHS];
|
||||
|
||||
} PSH_WidthsRec, *PSH_Widths;
|
||||
|
||||
|
||||
typedef struct PSH_DimensionRec_
|
||||
{
|
||||
PSH_WidthsRec stdw;
|
||||
FT_Fixed scale_mult;
|
||||
FT_Fixed scale_delta;
|
||||
|
||||
} PSH_DimensionRec, *PSH_Dimension;
|
||||
|
||||
|
||||
/* blue zone descriptor */
|
||||
typedef struct PSH_Blue_ZoneRec_
|
||||
{
|
||||
FT_Int org_ref;
|
||||
FT_Int org_delta;
|
||||
FT_Int org_top;
|
||||
FT_Int org_bottom;
|
||||
|
||||
FT_Pos cur_ref;
|
||||
FT_Pos cur_delta;
|
||||
FT_Pos cur_bottom;
|
||||
FT_Pos cur_top;
|
||||
|
||||
} PSH_Blue_ZoneRec, *PSH_Blue_Zone;
|
||||
|
||||
|
||||
typedef struct PSH_Blue_TableRec_
|
||||
{
|
||||
FT_UInt count;
|
||||
PSH_Blue_ZoneRec zones[PS_GLOBALS_MAX_BLUE_ZONES];
|
||||
|
||||
} PSH_Blue_TableRec, *PSH_Blue_Table;
|
||||
|
||||
|
||||
/* blue zones table */
|
||||
typedef struct PSH_BluesRec_
|
||||
{
|
||||
PSH_Blue_TableRec normal_top;
|
||||
PSH_Blue_TableRec normal_bottom;
|
||||
PSH_Blue_TableRec family_top;
|
||||
PSH_Blue_TableRec family_bottom;
|
||||
|
||||
FT_Fixed blue_scale;
|
||||
FT_Int blue_shift;
|
||||
FT_Int blue_threshold;
|
||||
FT_Int blue_fuzz;
|
||||
FT_Bool no_overshoots;
|
||||
|
||||
} PSH_BluesRec, *PSH_Blues;
|
||||
|
||||
|
||||
/* font globals. */
|
||||
/* dimension 0 => X coordinates + vertical hints/stems */
|
||||
/* dimension 1 => Y coordinates + horizontal hints/stems */
|
||||
typedef struct PSH_GlobalsRec_
|
||||
{
|
||||
FT_Memory memory;
|
||||
PSH_DimensionRec dimension[2];
|
||||
PSH_BluesRec blues;
|
||||
|
||||
} PSH_GlobalsRec;
|
||||
|
||||
|
||||
#define PSH_BLUE_ALIGN_NONE 0
|
||||
#define PSH_BLUE_ALIGN_TOP 1
|
||||
#define PSH_BLUE_ALIGN_BOT 2
|
||||
|
||||
|
||||
typedef struct PSH_AlignmentRec_
|
||||
{
|
||||
int align;
|
||||
FT_Pos align_top;
|
||||
FT_Pos align_bot;
|
||||
|
||||
} PSH_AlignmentRec, *PSH_Alignment;
|
||||
|
||||
|
||||
FT_LOCAL( void )
|
||||
psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs );
|
||||
|
||||
|
||||
#if 0
|
||||
/* snap a stem width to fitter coordinates. `org_width' is in font */
|
||||
/* units. The result is in device pixels (26.6 format). */
|
||||
FT_LOCAL( FT_Pos )
|
||||
psh_dimension_snap_width( PSH_Dimension dimension,
|
||||
FT_Int org_width );
|
||||
#endif
|
||||
|
||||
FT_LOCAL( void )
|
||||
psh_globals_set_scale( PSH_Globals globals,
|
||||
FT_Fixed x_scale,
|
||||
FT_Fixed y_scale,
|
||||
FT_Fixed x_delta,
|
||||
FT_Fixed y_delta );
|
||||
|
||||
/* snap a stem to one or two blue zones */
|
||||
FT_LOCAL( void )
|
||||
psh_blues_snap_stem( PSH_Blues blues,
|
||||
FT_Int stem_top,
|
||||
FT_Int stem_bot,
|
||||
PSH_Alignment alignment );
|
||||
/* */
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
extern PSH_Globals ps_debug_globals;
|
||||
#endif
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* PSHGLOB_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
29
freetype263/src/pshinter/pshinter.c
Normal file
29
freetype263/src/pshinter/pshinter.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshinter.c */
|
||||
/* */
|
||||
/* FreeType PostScript Hinting module */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#define FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#include <ft2build.h>
|
||||
#include "pshpic.c"
|
||||
#include "pshrec.c"
|
||||
#include "pshglob.c"
|
||||
#include "pshalgo.c"
|
||||
#include "pshmod.c"
|
||||
|
||||
|
||||
/* END */
|
||||
119
freetype263/src/pshinter/pshmod.c
Normal file
119
freetype263/src/pshinter/pshmod.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshmod.c */
|
||||
/* */
|
||||
/* FreeType PostScript hinter module implementation (body). */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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_INTERNAL_OBJECTS_H
|
||||
#include "pshrec.h"
|
||||
#include "pshalgo.h"
|
||||
#include "pshpic.h"
|
||||
|
||||
|
||||
/* the Postscript Hinter module structure */
|
||||
typedef struct PS_Hinter_Module_Rec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
PS_HintsRec ps_hints;
|
||||
|
||||
PSH_Globals_FuncsRec globals_funcs;
|
||||
T1_Hints_FuncsRec t1_funcs;
|
||||
T2_Hints_FuncsRec t2_funcs;
|
||||
|
||||
} PS_Hinter_ModuleRec, *PS_Hinter_Module;
|
||||
|
||||
|
||||
/* finalize module */
|
||||
FT_CALLBACK_DEF( void )
|
||||
ps_hinter_done( PS_Hinter_Module module )
|
||||
{
|
||||
module->t1_funcs.hints = NULL;
|
||||
module->t2_funcs.hints = NULL;
|
||||
|
||||
ps_hints_done( &module->ps_hints );
|
||||
}
|
||||
|
||||
|
||||
/* initialize module, create hints recorder and the interface */
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
ps_hinter_init( PS_Hinter_Module module )
|
||||
{
|
||||
FT_Memory memory = module->root.memory;
|
||||
void* ph = &module->ps_hints;
|
||||
|
||||
|
||||
ps_hints_init( &module->ps_hints, memory );
|
||||
|
||||
psh_globals_funcs_init( &module->globals_funcs );
|
||||
|
||||
t1_hints_funcs_init( &module->t1_funcs );
|
||||
module->t1_funcs.hints = (T1_Hints)ph;
|
||||
|
||||
t2_hints_funcs_init( &module->t2_funcs );
|
||||
module->t2_funcs.hints = (T2_Hints)ph;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* returns global hints interface */
|
||||
FT_CALLBACK_DEF( PSH_Globals_Funcs )
|
||||
pshinter_get_globals_funcs( FT_Module module )
|
||||
{
|
||||
return &((PS_Hinter_Module)module)->globals_funcs;
|
||||
}
|
||||
|
||||
|
||||
/* return Type 1 hints interface */
|
||||
FT_CALLBACK_DEF( T1_Hints_Funcs )
|
||||
pshinter_get_t1_funcs( FT_Module module )
|
||||
{
|
||||
return &((PS_Hinter_Module)module)->t1_funcs;
|
||||
}
|
||||
|
||||
|
||||
/* return Type 2 hints interface */
|
||||
FT_CALLBACK_DEF( T2_Hints_Funcs )
|
||||
pshinter_get_t2_funcs( FT_Module module )
|
||||
{
|
||||
return &((PS_Hinter_Module)module)->t2_funcs;
|
||||
}
|
||||
|
||||
|
||||
FT_DEFINE_PSHINTER_INTERFACE(
|
||||
pshinter_interface,
|
||||
pshinter_get_globals_funcs,
|
||||
pshinter_get_t1_funcs,
|
||||
pshinter_get_t2_funcs )
|
||||
|
||||
|
||||
FT_DEFINE_MODULE(
|
||||
pshinter_module_class,
|
||||
|
||||
0,
|
||||
sizeof ( PS_Hinter_ModuleRec ),
|
||||
"pshinter",
|
||||
0x10000L,
|
||||
0x20000L,
|
||||
|
||||
&PSHINTER_INTERFACE_GET, /* module-specific interface */
|
||||
|
||||
(FT_Module_Constructor)ps_hinter_init,
|
||||
(FT_Module_Destructor) ps_hinter_done,
|
||||
(FT_Module_Requester) NULL ) /* no additional interface for now */
|
||||
|
||||
|
||||
/* END */
|
||||
39
freetype263/src/pshinter/pshmod.h
Normal file
39
freetype263/src/pshinter/pshmod.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshmod.h */
|
||||
/* */
|
||||
/* PostScript hinter module interface (specification). */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSHMOD_H_
|
||||
#define PSHMOD_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_MODULE_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
FT_DECLARE_MODULE( pshinter_module_class )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* PSHMOD_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
41
freetype263/src/pshinter/pshnterr.h
Normal file
41
freetype263/src/pshinter/pshnterr.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshnterr.h */
|
||||
/* */
|
||||
/* PS Hinter error codes (specification only). */
|
||||
/* */
|
||||
/* Copyright 2003-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file is used to define the PSHinter error enumeration constants. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef PSHNTERR_H_
|
||||
#define PSHNTERR_H_
|
||||
|
||||
#include FT_MODULE_ERRORS_H
|
||||
|
||||
#undef FTERRORS_H_
|
||||
|
||||
#undef FT_ERR_PREFIX
|
||||
#define FT_ERR_PREFIX PSH_Err_
|
||||
#define FT_ERR_BASE FT_Mod_Err_PShinter
|
||||
|
||||
#include FT_ERRORS_H
|
||||
|
||||
#endif /* PSHNTERR_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
76
freetype263/src/pshinter/pshpic.c
Normal file
76
freetype263/src/pshinter/pshpic.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshpic.c */
|
||||
/* */
|
||||
/* The FreeType position independent code services for pshinter module. */
|
||||
/* */
|
||||
/* Copyright 2009-2016 by */
|
||||
/* Oran Agra and Mickey Gabel. */
|
||||
/* */
|
||||
/* 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_FREETYPE_H
|
||||
#include FT_INTERNAL_OBJECTS_H
|
||||
#include "pshpic.h"
|
||||
#include "pshnterr.h"
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_PIC
|
||||
|
||||
/* forward declaration of PIC init functions from pshmod.c */
|
||||
void
|
||||
FT_Init_Class_pshinter_interface( FT_Library library,
|
||||
PSHinter_Interface* clazz );
|
||||
|
||||
void
|
||||
pshinter_module_class_pic_free( FT_Library library )
|
||||
{
|
||||
FT_PIC_Container* pic_container = &library->pic_container;
|
||||
FT_Memory memory = library->memory;
|
||||
|
||||
|
||||
if ( pic_container->pshinter )
|
||||
{
|
||||
FT_FREE( pic_container->pshinter );
|
||||
pic_container->pshinter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FT_Error
|
||||
pshinter_module_class_pic_init( FT_Library library )
|
||||
{
|
||||
FT_PIC_Container* pic_container = &library->pic_container;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
PSHinterPIC* container = NULL;
|
||||
FT_Memory memory = library->memory;
|
||||
|
||||
|
||||
/* allocate pointer, clear and set global container pointer */
|
||||
if ( FT_ALLOC( container, sizeof ( *container ) ) )
|
||||
return error;
|
||||
FT_MEM_SET( container, 0, sizeof ( *container ) );
|
||||
pic_container->pshinter = container;
|
||||
|
||||
/* add call to initialization function when you add new scripts */
|
||||
FT_Init_Class_pshinter_interface(
|
||||
library, &container->pshinter_interface );
|
||||
|
||||
if ( error )
|
||||
pshinter_module_class_pic_free( library );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
|
||||
/* END */
|
||||
63
freetype263/src/pshinter/pshpic.h
Normal file
63
freetype263/src/pshinter/pshpic.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshpic.h */
|
||||
/* */
|
||||
/* The FreeType position independent code services for pshinter module. */
|
||||
/* */
|
||||
/* Copyright 2009-2016 by */
|
||||
/* Oran Agra and Mickey Gabel. */
|
||||
/* */
|
||||
/* 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSHPIC_H_
|
||||
#define PSHPIC_H_
|
||||
|
||||
|
||||
#include FT_INTERNAL_PIC_H
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_PIC
|
||||
|
||||
#define PSHINTER_INTERFACE_GET pshinter_interface
|
||||
|
||||
#else /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
typedef struct PSHinterPIC_
|
||||
{
|
||||
PSHinter_Interface pshinter_interface;
|
||||
|
||||
} PSHinterPIC;
|
||||
|
||||
|
||||
#define GET_PIC( lib ) ( (PSHinterPIC*)( (lib)->pic_container.pshinter ) )
|
||||
|
||||
#define PSHINTER_INTERFACE_GET ( GET_PIC( library )->pshinter_interface )
|
||||
|
||||
/* see pshpic.c for the implementation */
|
||||
void
|
||||
pshinter_module_class_pic_free( FT_Library library );
|
||||
|
||||
FT_Error
|
||||
pshinter_module_class_pic_init( FT_Library library );
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_PIC */
|
||||
|
||||
/* */
|
||||
|
||||
#endif /* PSHPIC_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
1220
freetype263/src/pshinter/pshrec.c
Normal file
1220
freetype263/src/pshinter/pshrec.c
Normal file
File diff suppressed because it is too large
Load Diff
172
freetype263/src/pshinter/pshrec.h
Normal file
172
freetype263/src/pshinter/pshrec.h
Normal file
@@ -0,0 +1,172 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* pshrec.h */
|
||||
/* */
|
||||
/* Postscript (Type1/Type2) hints recorder (specification). */
|
||||
/* */
|
||||
/* Copyright 2001-2016 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. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* The functions defined here are called from the Type 1, CID and CFF */
|
||||
/* font drivers to record the hints of a given character/glyph. */
|
||||
/* */
|
||||
/* The hints are recorded in a unified format, and are later processed */
|
||||
/* by the `optimizer' and `fitter' to adjust the outlines to the pixel */
|
||||
/* grid. */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
#ifndef PSHREC_H_
|
||||
#define PSHREC_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
|
||||
#include "pshglob.h"
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** GLYPH HINTS RECORDER INTERNALS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* handle to hint record */
|
||||
typedef struct PS_HintRec_* PS_Hint;
|
||||
|
||||
/* hint types */
|
||||
typedef enum PS_Hint_Type_
|
||||
{
|
||||
PS_HINT_TYPE_1 = 1,
|
||||
PS_HINT_TYPE_2 = 2
|
||||
|
||||
} PS_Hint_Type;
|
||||
|
||||
|
||||
/* hint flags */
|
||||
#define PS_HINT_FLAG_GHOST 1U
|
||||
#define PS_HINT_FLAG_BOTTOM 2U
|
||||
|
||||
|
||||
/* hint descriptor */
|
||||
typedef struct PS_HintRec_
|
||||
{
|
||||
FT_Int pos;
|
||||
FT_Int len;
|
||||
FT_UInt flags;
|
||||
|
||||
} PS_HintRec;
|
||||
|
||||
|
||||
#define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE )
|
||||
#define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST )
|
||||
#define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM )
|
||||
|
||||
|
||||
/* hints table descriptor */
|
||||
typedef struct PS_Hint_TableRec_
|
||||
{
|
||||
FT_UInt num_hints;
|
||||
FT_UInt max_hints;
|
||||
PS_Hint hints;
|
||||
|
||||
} PS_Hint_TableRec, *PS_Hint_Table;
|
||||
|
||||
|
||||
/* hint and counter mask descriptor */
|
||||
typedef struct PS_MaskRec_
|
||||
{
|
||||
FT_UInt num_bits;
|
||||
FT_UInt max_bits;
|
||||
FT_Byte* bytes;
|
||||
FT_UInt end_point;
|
||||
|
||||
} PS_MaskRec, *PS_Mask;
|
||||
|
||||
|
||||
/* masks and counters table descriptor */
|
||||
typedef struct PS_Mask_TableRec_
|
||||
{
|
||||
FT_UInt num_masks;
|
||||
FT_UInt max_masks;
|
||||
PS_Mask masks;
|
||||
|
||||
} PS_Mask_TableRec, *PS_Mask_Table;
|
||||
|
||||
|
||||
/* dimension-specific hints descriptor */
|
||||
typedef struct PS_DimensionRec_
|
||||
{
|
||||
PS_Hint_TableRec hints;
|
||||
PS_Mask_TableRec masks;
|
||||
PS_Mask_TableRec counters;
|
||||
|
||||
} PS_DimensionRec, *PS_Dimension;
|
||||
|
||||
|
||||
/* glyph hints descriptor */
|
||||
/* dimension 0 => X coordinates + vertical hints/stems */
|
||||
/* dimension 1 => Y coordinates + horizontal hints/stems */
|
||||
typedef struct PS_HintsRec_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_Error error;
|
||||
FT_UInt32 magic;
|
||||
PS_Hint_Type hint_type;
|
||||
PS_DimensionRec dimension[2];
|
||||
|
||||
} PS_HintsRec, *PS_Hints;
|
||||
|
||||
/* */
|
||||
|
||||
/* initialize hints recorder */
|
||||
FT_LOCAL( void )
|
||||
ps_hints_init( PS_Hints hints,
|
||||
FT_Memory memory );
|
||||
|
||||
/* finalize hints recorder */
|
||||
FT_LOCAL( void )
|
||||
ps_hints_done( PS_Hints hints );
|
||||
|
||||
/* initialize Type1 hints recorder interface */
|
||||
FT_LOCAL( void )
|
||||
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs );
|
||||
|
||||
/* initialize Type2 hints recorder interface */
|
||||
FT_LOCAL( void )
|
||||
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs );
|
||||
|
||||
|
||||
#ifdef DEBUG_HINTER
|
||||
extern PS_Hints ps_debug_hints;
|
||||
extern int ps_debug_no_horz_hints;
|
||||
extern int ps_debug_no_vert_hints;
|
||||
#endif
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* PSHREC_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
Reference in New Issue
Block a user