1 /***************************************************************************/
5 /* Interface to Postscript-specific (Type 1 and Type 2) hints */
6 /* recorders (specification only). These are used to support native */
7 /* T1/T2 hints in the "type1", "cid" and "cff" font drivers. */
9 /* Copyright 2001, 2002, 2003 by */
10 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
12 /* This file is part of the FreeType project, and may only be used, */
13 /* modified, and distributed under the terms of the FreeType project */
14 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
15 /* this file you indicate that you have read the license and */
16 /* understand and accept it fully. */
18 /***************************************************************************/
26 #include FT_FREETYPE_H
27 #include FT_TYPE1_TABLES_H
33 /*************************************************************************/
34 /*************************************************************************/
36 /***** INTERNAL REPRESENTATION OF GLOBALS *****/
38 /*************************************************************************/
39 /*************************************************************************/
41 typedef struct PSH_GlobalsRec_* PSH_Globals;
44 (*PSH_Globals_NewFunc)( FT_Memory memory,
45 T1_Private* private_dict,
46 PSH_Globals* aglobals );
49 (*PSH_Globals_SetScaleFunc)( PSH_Globals globals,
56 (*PSH_Globals_DestroyFunc)( PSH_Globals globals );
59 typedef struct PSH_Globals_FuncsRec_
61 PSH_Globals_NewFunc create;
62 PSH_Globals_SetScaleFunc set_scale;
63 PSH_Globals_DestroyFunc destroy;
65 } PSH_Globals_FuncsRec, *PSH_Globals_Funcs;
68 /*************************************************************************/
69 /*************************************************************************/
71 /***** PUBLIC TYPE 1 HINTS RECORDER *****/
73 /*************************************************************************/
74 /*************************************************************************/
76 /*************************************************************************/
82 /* This is a handle to an opaque structure used to record glyph hints */
83 /* from a Type 1 character glyph character string. */
85 /* The methods used to operate on this object are defined by the */
86 /* @T1_Hints_FuncsRec structure. Recording glyph hints is normally */
87 /* achieved through the following scheme: */
89 /* - Open a new hint recording session by calling the "open" method. */
90 /* This will rewind the recorder and prepare it for new input. */
92 /* - For each hint found in the glyph charstring, call the */
93 /* corresponding method ("stem", "stem3", or "reset"). Note that */
94 /* these functions do not return an error code. */
96 /* - Close the recording session by calling the "close" method. It */
97 /* will return an error code if the hints were invalid or something */
98 /* strange happened (e.g. memory shortage). */
100 /* The hints accumulated in the object can later be used by the */
101 /* PostScript hinter. */
103 typedef struct T1_HintsRec_* T1_Hints;
106 /*************************************************************************/
112 /* A pointer to the @T1_Hints_FuncsRec structure that defines the */
113 /* API of a given @T1_Hints object. */
115 typedef const struct T1_Hints_FuncsRec_* T1_Hints_Funcs;
118 /*************************************************************************/
121 /* T1_Hints_OpenFunc */
124 /* A method of the @T1_Hints class used to prepare it for a new */
125 /* Type 1 hints recording session. */
128 /* hints :: A handle to the Type 1 hints recorder. */
131 /* You should always call the @T1_Hints_CloseFunc method in order to */
132 /* close an opened recording session. */
135 (*T1_Hints_OpenFunc)( T1_Hints hints );
138 /*************************************************************************/
141 /* T1_Hints_SetStemFunc */
144 /* A method of the @T1_Hints class used to record a new horizontal or */
145 /* vertical stem. This corresponds to the Type 1 "hstem" and "vstem" */
149 /* hints :: A handle to the Type 1 hints recorder. */
151 /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */
154 /* coords :: Array of 2 integers, used as (position,length) stem */
158 /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
159 /* horizontal coordinates (x) for vertical stems (dim=1). */
161 /* "coords[0]" is the absolute stem position (lowest coordinate); */
162 /* "coords[1]" is the length. */
164 /* The length can be negative, in which case it must be either -20 or */
165 /* -21. It will be interpreted as a "ghost" stem, according to */
166 /* Type 1 specification. */
168 /* If the length is -21 (corresponding to a bottom ghost stem), then */
169 /* the real stem position is "coords[0]+coords[1]". */
172 (*T1_Hints_SetStemFunc)( T1_Hints hints,
177 /*************************************************************************/
180 /* T1_Hints_SetStem3Func */
183 /* A method of the @T1_Hints class used to record three */
184 /* counter-controlled horizontal or vertical stems at once. */
187 /* hints :: A handle to the Type 1 hints recorder. */
189 /* dimension :: 0 for horizontal stems, 1 for vertical ones. */
191 /* coords :: An array of 6 integers, holding 3 (position,length) */
192 /* pairs for the counter-controlled stems. */
195 /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
196 /* horizontal coordinates (x) for vertical stems (dim=1). */
198 /* The lengths cannot be negative (ghost stems are never */
199 /* counter-controlled). */
202 (*T1_Hints_SetStem3Func)( T1_Hints hints,
207 /*************************************************************************/
210 /* T1_Hints_ResetFunc */
213 /* A method of the @T1_Hints class used to reset the stems hints in a */
214 /* recording session. */
217 /* hints :: A handle to the Type 1 hints recorder. */
219 /* end_point :: The index of the last point in the input glyph in */
220 /* which the previously defined hints apply. */
223 (*T1_Hints_ResetFunc)( T1_Hints hints,
227 /*************************************************************************/
230 /* T1_Hints_CloseFunc */
233 /* A method of the @T1_Hints class used to close a hint recording */
237 /* hints :: A handle to the Type 1 hints recorder. */
239 /* end_point :: The index of the last point in the input glyph. */
242 /* FreeType error code. 0 means success. */
245 /* The error code will be set to indicate that an error occured */
246 /* during the recording session. */
249 (*T1_Hints_CloseFunc)( T1_Hints hints,
253 /*************************************************************************/
256 /* T1_Hints_ApplyFunc */
259 /* A method of the @T1_Hints class used to apply hints to the */
260 /* corresponding glyph outline. Must be called once all hints have */
264 /* hints :: A handle to the Type 1 hints recorder. */
266 /* outline :: A pointer to the target outline descriptor. */
268 /* globals :: The hinter globals for this font. */
270 /* hint_mode :: Hinting information. */
273 /* FreeType error code. 0 means success. */
276 /* On input, all points within the outline are in font coordinates. */
277 /* On output, they are in 1/64th of pixels. */
279 /* The scaling transformation is taken from the "globals" object */
280 /* which must correspond to the same font as the glyph. */
283 (*T1_Hints_ApplyFunc)( T1_Hints hints,
286 FT_Render_Mode hint_mode );
289 /*************************************************************************/
292 /* T1_Hints_FuncsRec */
295 /* The structure used to provide the API to @T1_Hints objects. */
298 /* hints :: A handle to the T1 Hints recorder. */
300 /* open :: The function to open a recording session. */
302 /* close :: The function to close a recording session. */
304 /* stem :: The function to set a simple stem. */
306 /* stem3 :: The function to set counter-controlled stems. */
308 /* reset :: The function to reset stem hints. */
310 /* apply :: The function to apply the hints to the corresponding */
313 typedef struct T1_Hints_FuncsRec_
316 T1_Hints_OpenFunc open;
317 T1_Hints_CloseFunc close;
318 T1_Hints_SetStemFunc stem;
319 T1_Hints_SetStem3Func stem3;
320 T1_Hints_ResetFunc reset;
321 T1_Hints_ApplyFunc apply;
326 /*************************************************************************/
327 /*************************************************************************/
329 /***** PUBLIC TYPE 2 HINTS RECORDER *****/
331 /*************************************************************************/
332 /*************************************************************************/
334 /*************************************************************************/
340 /* This is a handle to an opaque structure used to record glyph hints */
341 /* from a Type 2 character glyph character string. */
343 /* The methods used to operate on this object are defined by the */
344 /* @T2_Hints_FuncsRec structure. Recording glyph hints is normally */
345 /* achieved through the following scheme: */
347 /* - Open a new hint recording session by calling the "open" method. */
348 /* This will rewind the recorder and prepare it for new input. */
350 /* - For each hint found in the glyph charstring, call the */
351 /* corresponding method ("stems", "hintmask", "counters"). Note */
352 /* that these functions do not return an error code. */
354 /* - Close the recording session by calling the "close" method. It */
355 /* will return an error code if the hints were invalid or something */
356 /* strange happened (e.g. memory shortage). */
358 /* The hints accumulated in the object can later be used by the */
359 /* Postscript hinter. */
361 typedef struct T2_HintsRec_* T2_Hints;
364 /*************************************************************************/
370 /* A pointer to the @T2_Hints_FuncsRec structure that defines the API */
371 /* of a given @T2_Hints object. */
373 typedef const struct T2_Hints_FuncsRec_* T2_Hints_Funcs;
376 /*************************************************************************/
379 /* T2_Hints_OpenFunc */
382 /* A method of the @T2_Hints class used to prepare it for a new */
383 /* Type 2 hints recording session. */
386 /* hints :: A handle to the Type 2 hints recorder. */
389 /* You should always call the @T2_Hints_CloseFunc method in order to */
390 /* close an opened recording session. */
393 (*T2_Hints_OpenFunc)( T2_Hints hints );
396 /*************************************************************************/
399 /* T2_Hints_StemsFunc */
402 /* A method of the @T2_Hints class used to set the table of stems in */
403 /* either the vertical or horizontal dimension. Equivalent to the */
404 /* "hstem", "vstem", "hstemhm", and "vstemhm" Type 2 operators. */
407 /* hints :: A handle to the Type 2 hints recorder. */
409 /* dimension :: 0 for horizontal stems (hstem), 1 for vertical ones */
412 /* count :: The number of stems. */
414 /* coords :: An array of "count" (position,length) pairs. */
417 /* Use vertical coordinates (y) for horizontal stems (dim=0). Use */
418 /* horizontal coordinates (x) for vertical stems (dim=1). */
420 /* There are "2*count" elements in the "coords" aray. Each even */
421 /* element is an absolute position in font units, each odd element is */
422 /* a length in font units. */
424 /* A length can be negative, in which case it must be either -20 or */
425 /* -21. It will be interpreted as a "ghost" stem, according to the */
426 /* Type 1 specification. */
429 (*T2_Hints_StemsFunc)( T2_Hints hints,
432 FT_Fixed* coordinates );
435 /*************************************************************************/
438 /* T2_Hints_MaskFunc */
441 /* A method of the @T2_Hints class used to set a given hintmask */
442 /* (this corresponds to the "hintmask" Type 2 operator). */
445 /* hints :: A handle to the Type 2 hints recorder. */
447 /* end_point :: The glyph index of the last point to which the */
448 /* previously defined/activated hints apply. */
450 /* bit_count :: The number of bits in the hint mask. */
452 /* bytes :: An array of bytes modelling the hint mask. */
455 /* If the hintmask starts the charstring (before any glyph point */
456 /* definition), the value of "end_point" should be 0. */
458 /* "bit_count" is the number of meaningful bits in the "bytes" array; */
459 /* it must be equal to the total number of hints defined so far */
460 /* (i.e. horizontal+verticals). */
462 /* The "bytes" array can come directly from the Type 2 charstring and */
463 /* respects the same format. */
466 (*T2_Hints_MaskFunc)( T2_Hints hints,
469 const FT_Byte* bytes );
472 /*************************************************************************/
475 /* T2_Hints_CounterFunc */
478 /* A method of the @T2_Hints class used to set a given counter mask */
479 /* (this corresponds to the "hintmask" Type 2 operator). */
482 /* hints :: A handle to the Type 2 hints recorder. */
484 /* end_point :: A glyph index of the last point to which the */
485 /* previously defined/active hints apply. */
487 /* bit_count :: The number of bits in the hint mask. */
489 /* bytes :: An array of bytes modelling the hint mask. */
492 /* If the hintmask starts the charstring (before any glyph point */
493 /* definition), the value of "end_point" should be 0. */
495 /* "bit_count" is the number of meaningful bits in the "bytes" array; */
496 /* it must be equal to the total number of hints defined so far */
497 /* (i.e. horizontal+verticals). */
499 /* The "bytes" array can come directly from the Type 2 charstring and */
500 /* respects the same format. */
503 (*T2_Hints_CounterFunc)( T2_Hints hints,
505 const FT_Byte* bytes );
508 /*************************************************************************/
511 /* T2_Hints_CloseFunc */
514 /* A method of the @T2_Hints class used to close a hint recording */
518 /* hints :: A handle to the Type 2 hints recorder. */
520 /* end_point :: The index of the last point in the input glyph. */
523 /* FreeType error code. 0 means success. */
526 /* The error code will be set to indicate that an error occured */
527 /* during the recording session. */
530 (*T2_Hints_CloseFunc)( T2_Hints hints,
534 /*************************************************************************/
537 /* T2_Hints_ApplyFunc */
540 /* A method of the @T2_Hints class used to apply hints to the */
541 /* corresponding glyph outline. Must be called after the "close" */
545 /* hints :: A handle to the Type 2 hints recorder. */
547 /* outline :: A pointer to the target outline descriptor. */
549 /* globals :: The hinter globals for this font. */
551 /* hint_mode :: Hinting information. */
554 /* FreeType error code. 0 means success. */
557 /* On input, all points within the outline are in font coordinates. */
558 /* On output, they are in 1/64th of pixels. */
560 /* The scaling transformation is taken from the "globals" object */
561 /* which must correspond to the same font than the glyph. */
564 (*T2_Hints_ApplyFunc)( T2_Hints hints,
567 FT_Render_Mode hint_mode );
570 /*************************************************************************/
573 /* T2_Hints_FuncsRec */
576 /* The structure used to provide the API to @T2_Hints objects. */
579 /* hints :: A handle to the T2 hints recorder object. */
581 /* open :: The function to open a recording session. */
583 /* close :: The function to close a recording session. */
585 /* stems :: The function to set the dimension's stems table. */
587 /* hintmask :: The function to set hint masks. */
589 /* counter :: The function to set counter masks. */
591 /* apply :: The function to apply the hints on the corresponding */
594 typedef struct T2_Hints_FuncsRec_
597 T2_Hints_OpenFunc open;
598 T2_Hints_CloseFunc close;
599 T2_Hints_StemsFunc stems;
600 T2_Hints_MaskFunc hintmask;
601 T2_Hints_CounterFunc counter;
602 T2_Hints_ApplyFunc apply;
610 typedef struct PSHinter_Interface_
612 PSH_Globals_Funcs (*get_globals_funcs)( FT_Module module );
613 T1_Hints_Funcs (*get_t1_funcs) ( FT_Module module );
614 T2_Hints_Funcs (*get_t2_funcs) ( FT_Module module );
616 } PSHinter_Interface;
618 typedef PSHinter_Interface* PSHinter_Service;
623 #endif /* __PSHINTS_H__ */