ReactOS 0.4.16-dev-2384-gff6bd79
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 };
@ PSH_DIR_LEFT
Definition: pshalgo.h:101
@ PSH_DIR_UP
Definition: pshalgo.h:99
@ PSH_DIR_RIGHT
Definition: pshalgo.h:102
@ PSH_DIR_DOWN
Definition: pshalgo.h:100
@ PSH_DIR_NONE
Definition: pshalgo.h:98

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 2069 of file pshalgo.c.

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

Referenced by t1_hints_funcs_init(), and t2_hints_funcs_init().