| 1 | /**************************************************************************** |
| 2 | * |
| 3 | * pshrec.h |
| 4 | * |
| 5 | * Postscript (Type1/Type2) hints recorder (specification). |
| 6 | * |
| 7 | * Copyright (C) 2001-2023 by |
| 8 | * David Turner, Robert Wilhelm, and Werner Lemberg. |
| 9 | * |
| 10 | * This file is part of the FreeType project, and may only be used, |
| 11 | * modified, and distributed under the terms of the FreeType project |
| 12 | * license, LICENSE.TXT. By continuing to use, modify, or distribute |
| 13 | * this file you indicate that you have read the license and |
| 14 | * understand and accept it fully. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | /*************************************************************************** |
| 20 | * |
| 21 | * The functions defined here are called from the Type 1, CID and CFF |
| 22 | * font drivers to record the hints of a given character/glyph. |
| 23 | * |
| 24 | * The hints are recorded in a unified format, and are later processed |
| 25 | * by the `optimizer' and `fitter' to adjust the outlines to the pixel |
| 26 | * grid. |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | #ifndef PSHREC_H_ |
| 32 | #define PSHREC_H_ |
| 33 | |
| 34 | |
| 35 | #include <freetype/internal/pshints.h> |
| 36 | #include "pshglob.h" |
| 37 | |
| 38 | |
| 39 | FT_BEGIN_HEADER |
| 40 | |
| 41 | |
| 42 | /*************************************************************************/ |
| 43 | /*************************************************************************/ |
| 44 | /***** *****/ |
| 45 | /***** GLYPH HINTS RECORDER INTERNALS *****/ |
| 46 | /***** *****/ |
| 47 | /*************************************************************************/ |
| 48 | /*************************************************************************/ |
| 49 | |
| 50 | /* handle to hint record */ |
| 51 | typedef struct PS_HintRec_* PS_Hint; |
| 52 | |
| 53 | /* hint types */ |
| 54 | typedef enum PS_Hint_Type_ |
| 55 | { |
| 56 | PS_HINT_TYPE_1 = 1, |
| 57 | PS_HINT_TYPE_2 = 2 |
| 58 | |
| 59 | } PS_Hint_Type; |
| 60 | |
| 61 | |
| 62 | /* hint flags */ |
| 63 | #define PS_HINT_FLAG_GHOST 1U |
| 64 | #define PS_HINT_FLAG_BOTTOM 2U |
| 65 | |
| 66 | |
| 67 | /* hint descriptor */ |
| 68 | typedef struct PS_HintRec_ |
| 69 | { |
| 70 | FT_Int pos; |
| 71 | FT_Int len; |
| 72 | FT_UInt flags; |
| 73 | |
| 74 | } PS_HintRec; |
| 75 | |
| 76 | |
| 77 | #define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE ) |
| 78 | #define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST ) |
| 79 | #define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM ) |
| 80 | |
| 81 | |
| 82 | /* hints table descriptor */ |
| 83 | typedef struct PS_Hint_TableRec_ |
| 84 | { |
| 85 | FT_UInt num_hints; |
| 86 | FT_UInt max_hints; |
| 87 | PS_Hint hints; |
| 88 | |
| 89 | } PS_Hint_TableRec, *PS_Hint_Table; |
| 90 | |
| 91 | |
| 92 | /* hint and counter mask descriptor */ |
| 93 | typedef struct PS_MaskRec_ |
| 94 | { |
| 95 | FT_UInt num_bits; |
| 96 | FT_UInt max_bits; |
| 97 | FT_Byte* bytes; |
| 98 | FT_UInt end_point; |
| 99 | |
| 100 | } PS_MaskRec, *PS_Mask; |
| 101 | |
| 102 | |
| 103 | /* masks and counters table descriptor */ |
| 104 | typedef struct PS_Mask_TableRec_ |
| 105 | { |
| 106 | FT_UInt num_masks; |
| 107 | FT_UInt max_masks; |
| 108 | PS_Mask masks; |
| 109 | |
| 110 | } PS_Mask_TableRec, *PS_Mask_Table; |
| 111 | |
| 112 | |
| 113 | /* dimension-specific hints descriptor */ |
| 114 | typedef struct PS_DimensionRec_ |
| 115 | { |
| 116 | PS_Hint_TableRec hints; |
| 117 | PS_Mask_TableRec masks; |
| 118 | PS_Mask_TableRec counters; |
| 119 | |
| 120 | } PS_DimensionRec, *PS_Dimension; |
| 121 | |
| 122 | |
| 123 | /* glyph hints descriptor */ |
| 124 | /* dimension 0 => X coordinates + vertical hints/stems */ |
| 125 | /* dimension 1 => Y coordinates + horizontal hints/stems */ |
| 126 | typedef struct PS_HintsRec_ |
| 127 | { |
| 128 | FT_Memory memory; |
| 129 | FT_Error error; |
| 130 | FT_UInt32 magic; |
| 131 | PS_Hint_Type hint_type; |
| 132 | PS_DimensionRec dimension[2]; |
| 133 | |
| 134 | } PS_HintsRec, *PS_Hints; |
| 135 | |
| 136 | /* */ |
| 137 | |
| 138 | /* initialize hints recorder */ |
| 139 | FT_LOCAL( void ) |
| 140 | ps_hints_init( PS_Hints hints, |
| 141 | FT_Memory memory ); |
| 142 | |
| 143 | /* finalize hints recorder */ |
| 144 | FT_LOCAL( void ) |
| 145 | ps_hints_done( PS_Hints hints ); |
| 146 | |
| 147 | /* initialize Type1 hints recorder interface */ |
| 148 | FT_LOCAL( void ) |
| 149 | t1_hints_funcs_init( T1_Hints_FuncsRec* funcs ); |
| 150 | |
| 151 | /* initialize Type2 hints recorder interface */ |
| 152 | FT_LOCAL( void ) |
| 153 | t2_hints_funcs_init( T2_Hints_FuncsRec* funcs ); |
| 154 | |
| 155 | |
| 156 | #ifdef DEBUG_HINTER |
| 157 | extern PS_Hints ps_debug_hints; |
| 158 | extern int ps_debug_no_horz_hints; |
| 159 | extern int ps_debug_no_vert_hints; |
| 160 | #endif |
| 161 | |
| 162 | /* */ |
| 163 | |
| 164 | |
| 165 | FT_END_HEADER |
| 166 | |
| 167 | |
| 168 | #endif /* PSHREC_H_ */ |
| 169 | |
| 170 | |
| 171 | /* END */ |
| 172 | |