ReactOS  0.4.15-dev-3203-gacde1e0
pshalgo.h File Reference
#include "pshrec.h"
#include "pshglob.h"
Include dependency graph for pshalgo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PSH_HintRec_
 
struct  PSH_ZoneRec_
 
struct  PSH_Hint_TableRec_
 
struct  PSH_PointRec_
 
struct  PSH_ContourRec_
 
struct  PSH_GlyphRec_
 

Macros

#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
 
#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 )
 
#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
 
#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
 

Typedefs

typedef typedefFT_BEGIN_HEADER struct PSH_HintRec_PSH_Hint
 
typedef struct PSH_HintRec_ PSH_HintRec
 
typedef struct PSH_ZoneRec_ PSH_ZoneRec
 
typedef struct PSH_ZoneRec_PSH_Zone
 
typedef struct PSH_Hint_TableRec_ PSH_Hint_TableRec
 
typedef struct PSH_Hint_TableRec_PSH_Hint_Table
 
typedef struct PSH_PointRec_PSH_Point
 
typedef struct PSH_ContourRec_PSH_Contour
 
typedef struct PSH_PointRec_ PSH_PointRec
 
typedef struct PSH_ContourRec_ PSH_ContourRec
 
typedef struct PSH_GlyphRec_ PSH_GlyphRec
 
typedef struct PSH_GlyphRec_PSH_Glyph
 

Enumerations

enum  {
  PSH_DIR_NONE = 4, PSH_DIR_UP = -1, PSH_DIR_DOWN = 1, PSH_DIR_LEFT = -2,
  PSH_DIR_RIGHT = 2
}
 

Functions

FT_Error ps_hints_apply (PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
 

Macro Definition Documentation

◆ PSH_DIR_COMPARE

#define PSH_DIR_COMPARE (   d1,
  d2 
)    ( (d1) == (d2) || (d1) == -(d2) )

Definition at line 108 of file pshalgo.h.

◆ PSH_DIR_HORIZONTAL

#define PSH_DIR_HORIZONTAL   2

Definition at line 105 of file pshalgo.h.

◆ PSH_DIR_IS_HORIZONTAL

#define PSH_DIR_IS_HORIZONTAL (   d)    PSH_DIR_COMPARE( d, PSH_DIR_HORIZONTAL )

Definition at line 109 of file pshalgo.h.

◆ PSH_DIR_IS_VERTICAL

#define PSH_DIR_IS_VERTICAL (   d)    PSH_DIR_COMPARE( d, PSH_DIR_VERTICAL )

Definition at line 110 of file pshalgo.h.

◆ PSH_DIR_VERTICAL

#define PSH_DIR_VERTICAL   1

Definition at line 106 of file pshalgo.h.

◆ psh_hint_activate

#define psh_hint_activate (   x)    (x)->flags |= PSH_HINT_ACTIVE

Definition at line 45 of file pshalgo.h.

◆ PSH_HINT_ACTIVE

#define PSH_HINT_ACTIVE   4U

Definition at line 37 of file pshalgo.h.

◆ PSH_HINT_BOTTOM

#define PSH_HINT_BOTTOM   PS_HINT_FLAG_BOTTOM

Definition at line 36 of file pshalgo.h.

◆ psh_hint_deactivate

#define psh_hint_deactivate (   x)    (x)->flags &= ~PSH_HINT_ACTIVE

Definition at line 46 of file pshalgo.h.

◆ PSH_HINT_FITTED

#define PSH_HINT_FITTED   8U

Definition at line 38 of file pshalgo.h.

◆ PSH_HINT_GHOST

#define PSH_HINT_GHOST   PS_HINT_FLAG_GHOST

Definition at line 35 of file pshalgo.h.

◆ psh_hint_is_active

#define psh_hint_is_active (   x)    ( ( (x)->flags & PSH_HINT_ACTIVE ) != 0 )

Definition at line 41 of file pshalgo.h.

◆ psh_hint_is_fitted

#define psh_hint_is_fitted (   x)    ( ( (x)->flags & PSH_HINT_FITTED ) != 0 )

Definition at line 43 of file pshalgo.h.

◆ psh_hint_is_ghost

#define psh_hint_is_ghost (   x)    ( ( (x)->flags & PSH_HINT_GHOST ) != 0 )

Definition at line 42 of file pshalgo.h.

◆ psh_hint_set_fitted

#define psh_hint_set_fitted (   x)    (x)->flags |= PSH_HINT_FITTED

Definition at line 47 of file pshalgo.h.

◆ PSH_POINT_EDGE_MAX

#define PSH_POINT_EDGE_MAX   1024U /* point is aligned to top/right stem edge */

Definition at line 136 of file pshalgo.h.

◆ PSH_POINT_EDGE_MIN

#define PSH_POINT_EDGE_MIN   512U /* point is aligned to left/bottom stem edge */

Definition at line 135 of file pshalgo.h.

◆ PSH_POINT_EXTREMUM

#define PSH_POINT_EXTREMUM   64U /* point is local extremum */

Definition at line 132 of file pshalgo.h.

◆ PSH_POINT_FITTED

#define PSH_POINT_FITTED   32U /* point is already fitted */

Definition at line 131 of file pshalgo.h.

◆ PSH_POINT_INFLEX

#define PSH_POINT_INFLEX   4U /* point is inflection */

Definition at line 117 of file pshalgo.h.

◆ psh_point_is_edge_max

#define psh_point_is_edge_max (   p)    ( (p)->flags2 & PSH_POINT_EDGE_MAX )

Definition at line 145 of file pshalgo.h.

◆ psh_point_is_edge_min

#define psh_point_is_edge_min (   p)    ( (p)->flags2 & PSH_POINT_EDGE_MIN )

Definition at line 144 of file pshalgo.h.

◆ psh_point_is_extremum

#define psh_point_is_extremum (   p)    ( (p)->flags2 & PSH_POINT_EXTREMUM )

Definition at line 141 of file pshalgo.h.

◆ psh_point_is_fitted

#define psh_point_is_fitted (   p)    ( (p)->flags2 & PSH_POINT_FITTED )

Definition at line 140 of file pshalgo.h.

◆ psh_point_is_inflex

#define psh_point_is_inflex (   p)    ( (p)->flags & PSH_POINT_INFLEX )

Definition at line 122 of file pshalgo.h.

◆ psh_point_is_negative

#define psh_point_is_negative (   p)    ( (p)->flags2 & PSH_POINT_NEGATIVE )

Definition at line 143 of file pshalgo.h.

◆ psh_point_is_off

#define psh_point_is_off (   p)    ( (p)->flags & PSH_POINT_OFF )

Definition at line 121 of file pshalgo.h.

◆ psh_point_is_positive

#define psh_point_is_positive (   p)    ( (p)->flags2 & PSH_POINT_POSITIVE )

Definition at line 142 of file pshalgo.h.

◆ psh_point_is_smooth

#define psh_point_is_smooth (   p)    ( (p)->flags & PSH_POINT_SMOOTH )

Definition at line 120 of file pshalgo.h.

◆ psh_point_is_strong

#define psh_point_is_strong (   p)    ( (p)->flags2 & PSH_POINT_STRONG )

Definition at line 139 of file pshalgo.h.

◆ PSH_POINT_NEGATIVE

#define PSH_POINT_NEGATIVE   256U /* extremum has negative contour flow */

Definition at line 134 of file pshalgo.h.

◆ PSH_POINT_OFF

#define PSH_POINT_OFF   1U /* point is off the curve */

Definition at line 115 of file pshalgo.h.

◆ PSH_POINT_POSITIVE

#define PSH_POINT_POSITIVE   128U /* extremum has positive contour flow */

Definition at line 133 of file pshalgo.h.

◆ psh_point_set_edge_max

#define psh_point_set_edge_max (   p)    (p)->flags2 |= PSH_POINT_EDGE_MAX

Definition at line 153 of file pshalgo.h.

◆ psh_point_set_edge_min

#define psh_point_set_edge_min (   p)    (p)->flags2 |= PSH_POINT_EDGE_MIN

Definition at line 152 of file pshalgo.h.

◆ psh_point_set_extremum

#define psh_point_set_extremum (   p)    (p)->flags2 |= PSH_POINT_EXTREMUM

Definition at line 149 of file pshalgo.h.

◆ psh_point_set_fitted

#define psh_point_set_fitted (   p)    (p)->flags2 |= PSH_POINT_FITTED

Definition at line 148 of file pshalgo.h.

◆ psh_point_set_inflex

#define psh_point_set_inflex (   p)    (p)->flags |= PSH_POINT_INFLEX

Definition at line 126 of file pshalgo.h.

◆ psh_point_set_negative

#define psh_point_set_negative (   p)    (p)->flags2 |= PSH_POINT_NEGATIVE

Definition at line 151 of file pshalgo.h.

◆ psh_point_set_off

#define psh_point_set_off (   p)    (p)->flags |= PSH_POINT_OFF

Definition at line 125 of file pshalgo.h.

◆ psh_point_set_positive

#define psh_point_set_positive (   p)    (p)->flags2 |= PSH_POINT_POSITIVE

Definition at line 150 of file pshalgo.h.

◆ psh_point_set_smooth

#define psh_point_set_smooth (   p)    (p)->flags |= PSH_POINT_SMOOTH

Definition at line 124 of file pshalgo.h.

◆ psh_point_set_strong

#define psh_point_set_strong (   p)    (p)->flags2 |= PSH_POINT_STRONG

Definition at line 147 of file pshalgo.h.

◆ PSH_POINT_SMOOTH

#define PSH_POINT_SMOOTH   2U /* point is smooth */

Definition at line 116 of file pshalgo.h.

◆ PSH_POINT_STRONG

#define PSH_POINT_STRONG   16U /* point is strong */

Definition at line 130 of file pshalgo.h.

Typedef Documentation

◆ PSH_Contour

Definition at line 94 of file pshalgo.h.

◆ PSH_ContourRec

◆ PSH_Glyph

◆ PSH_GlyphRec

◆ PSH_Hint

typedef typedefFT_BEGIN_HEADER struct PSH_HintRec_* PSH_Hint

Definition at line 31 of file pshalgo.h.

◆ PSH_Hint_Table

◆ PSH_Hint_TableRec

◆ PSH_HintRec

◆ PSH_Point

Definition at line 93 of file pshalgo.h.

◆ PSH_PointRec

◆ PSH_Zone

◆ PSH_ZoneRec

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PSH_DIR_NONE 
PSH_DIR_UP 
PSH_DIR_DOWN 
PSH_DIR_LEFT 
PSH_DIR_RIGHT 

Definition at line 96 of file pshalgo.h.

97  {
98  PSH_DIR_NONE = 4,
99  PSH_DIR_UP = -1,
100  PSH_DIR_DOWN = 1,
101  PSH_DIR_LEFT = -2,
102  PSH_DIR_RIGHT = 2
103  };

Function Documentation

◆ ps_hints_apply()

FT_Error ps_hints_apply ( PS_Hints  ps_hints,
FT_Outline outline,
PSH_Globals  globals,
FT_Render_Mode  hint_mode 
)

Definition at line 2070 of file pshalgo.c.

2074  {
2075  PSH_GlyphRec glyphrec;
2076  PSH_Glyph glyph = &glyphrec;
2077  FT_Error error;
2078 #ifdef DEBUG_HINTER
2079  FT_Memory memory;
2080 #endif
2081  FT_Int dimension;
2082 
2083 
2084  /* something to do? */
2085  if ( outline->n_points == 0 || outline->n_contours == 0 )
2086  return FT_Err_Ok;
2087 
2088 #ifdef DEBUG_HINTER
2089 
2090  memory = globals->memory;
2091 
2092  if ( ps_debug_glyph )
2093  {
2094  psh_glyph_done( ps_debug_glyph );
2095  FT_FREE( ps_debug_glyph );
2096  }
2097 
2098  if ( FT_NEW( glyph ) )
2099  return error;
2100 
2101  ps_debug_glyph = glyph;
2102 
2103 #endif /* DEBUG_HINTER */
2104 
2105  error = psh_glyph_init( glyph, outline, ps_hints, globals );
2106  if ( error )
2107  goto Exit;
2108 
2109  /* try to optimize the y_scale so that the top of non-capital letters
2110  * is aligned on a pixel boundary whenever possible
2111  */
2112  {
2113  PSH_Dimension dim_x = &glyph->globals->dimension[0];
2114  PSH_Dimension dim_y = &glyph->globals->dimension[1];
2115 
2116  FT_Fixed x_scale = dim_x->scale_mult;
2117  FT_Fixed y_scale = dim_y->scale_mult;
2118 
2119  FT_Fixed old_x_scale = x_scale;
2120  FT_Fixed old_y_scale = y_scale;
2121 
2122  FT_Fixed scaled;
2123  FT_Fixed fitted;
2124 
2125  FT_Bool rescale = FALSE;
2126 
2127 
2128  scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
2129  fitted = FT_PIX_ROUND( scaled );
2130 
2131  if ( fitted != 0 && scaled != fitted )
2132  {
2133  rescale = TRUE;
2134 
2135  y_scale = FT_MulDiv( y_scale, fitted, scaled );
2136 
2137  if ( fitted < scaled )
2138  x_scale -= x_scale / 50;
2139 
2140  psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
2141  }
2142 
2143  glyph->do_horz_hints = 1;
2144  glyph->do_vert_hints = 1;
2145 
2146  glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
2147  hint_mode == FT_RENDER_MODE_LCD );
2148 
2149  glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
2150  hint_mode == FT_RENDER_MODE_LCD_V );
2151 
2152  glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
2153 
2154  for ( dimension = 0; dimension < 2; dimension++ )
2155  {
2156  /* load outline coordinates into glyph */
2157  psh_glyph_load_points( glyph, dimension );
2158 
2159  /* compute local extrema */
2160  psh_glyph_compute_extrema( glyph );
2161 
2162  /* compute aligned stem/hints positions */
2163  psh_hint_table_align_hints( &glyph->hint_tables[dimension],
2164  glyph->globals,
2165  dimension,
2166  glyph );
2167 
2168  /* find strong points, align them, then interpolate others */
2169  psh_glyph_find_strong_points( glyph, dimension );
2170  if ( dimension == 1 )
2171  psh_glyph_find_blue_points( &globals->blues, glyph );
2172  psh_glyph_interpolate_strong_points( glyph, dimension );
2173  psh_glyph_interpolate_normal_points( glyph, dimension );
2174  psh_glyph_interpolate_other_points( glyph, dimension );
2175 
2176  /* save hinted coordinates back to outline */
2177  psh_glyph_save_points( glyph, dimension );
2178 
2179  if ( rescale )
2181  old_x_scale, old_y_scale, 0, 0 );
2182  }
2183  }
2184 
2185  Exit:
2186 
2187 #ifndef DEBUG_HINTER
2188  psh_glyph_done( glyph );
2189 #endif
2190 
2191  return error;
2192  }
FT_Bool do_vert_snapping
Definition: pshalgo.h:209
static void psh_glyph_find_blue_points(PSH_Blues blues, PSH_Glyph glyph)
Definition: pshalgo.c:1644
int FT_Error
Definition: fttypes.h:300
static void psh_glyph_interpolate_strong_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1719
#define error(str)
Definition: mkdosfs.c:1605
#define TRUE
Definition: types.h:120
signed int FT_Int
Definition: fttypes.h:220
return FT_Err_Ok
Definition: ftbbox.c:511
static char memory[1024 *256]
Definition: process.c:116
FT_Fixed scale_mult
Definition: pshglob.h:85
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
#define FALSE
Definition: types.h:117
static void psh_hint_table_align_hints(PSH_Hint_Table table, PSH_Globals globals, FT_Int dimension, PSH_Glyph glyph)
Definition: pshalgo.c:846
static void psh_glyph_done(PSH_Glyph glyph)
Definition: pshalgo.c:1035
static void psh_glyph_interpolate_normal_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1770
#define FT_FREE(ptr)
Definition: ftmemory.h:329
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
Definition: ftcalc.c:416
FT_Bool do_vert_hints
Definition: pshalgo.h:207
static void Exit(void)
Definition: sock.c:1331
static void psh_glyph_interpolate_other_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1924
static void psh_glyph_find_strong_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1565
FT_Bool do_horz_snapping
Definition: pshalgo.h:208
FT_Bool do_stem_adjust
Definition: pshalgo.h:210
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
#define FT_BOOL(x)
Definition: fttypes.h:578
Definition: mesh.c:5329
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
FT_Bool do_horz_hints
Definition: pshalgo.h:206
static void psh_glyph_load_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1081
signed long FT_Fixed
Definition: fttypes.h:288
PSH_Hint_TableRec hint_tables[2]
Definition: pshalgo.h:200
PSH_Globals globals
Definition: pshalgo.h:199
static void psh_glyph_save_points(PSH_Glyph glyph, FT_Int dimension)
Definition: pshalgo.c:1115
#define FT_NEW(ptr)
Definition: ftmemory.h:331
static void psh_glyph_compute_extrema(PSH_Glyph glyph)
Definition: pshalgo.c:1289
static FT_Error psh_glyph_init(PSH_Glyph glyph, FT_Outline *outline, PS_Hints ps_hints, PSH_Globals globals)
Definition: pshalgo.c:1155
#define FT_PIX_ROUND(x)
Definition: ftobjs.h:93
psh_globals_set_scale(PSH_Globals globals, FT_Fixed x_scale, FT_Fixed y_scale, FT_Fixed x_delta, FT_Fixed y_delta)
Definition: pshglob.c:754

Referenced by t1_hints_funcs_init(), and t2_hints_funcs_init().