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, 2005, 2006, 2007 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 rewinds the recorder and prepare it for new input.
92 * - For each hint found in the glyph charstring, call the corresponding
93 * method (`stem', `stem3', or `reset'). Note that these functions do
94 * not return an error code.
96 * - Close the recording session by calling the `close' method. It
97 * returns 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
104 typedef struct T1_HintsRec_
* T1_Hints
;
107 /*************************************************************************
113 * A pointer to the @T1_Hints_FuncsRec structure that defines the API of
114 * a given @T1_Hints object.
117 typedef const struct T1_Hints_FuncsRec_
* T1_Hints_Funcs
;
120 /*************************************************************************
126 * A method of the @T1_Hints class used to prepare it for a new Type 1
127 * hints recording session.
131 * A handle to the Type 1 hints recorder.
134 * You should always call the @T1_Hints_CloseFunc method in order to
135 * close an opened recording session.
139 (*T1_Hints_OpenFunc
)( T1_Hints hints
);
142 /*************************************************************************
145 * T1_Hints_SetStemFunc
148 * A method of the @T1_Hints class used to record a new horizontal or
149 * vertical stem. This corresponds to the Type 1 `hstem' and `vstem'
154 * A handle to the Type 1 hints recorder.
157 * 0 for horizontal stems (hstem), 1 for vertical ones (vstem).
160 * Array of 2 integers, used as (position,length) stem descriptor.
163 * Use vertical coordinates (y) for horizontal stems (dim=0). Use
164 * horizontal coordinates (x) for vertical stems (dim=1).
166 * `coords[0]' is the absolute stem position (lowest coordinate);
167 * `coords[1]' is the length.
169 * The length can be negative, in which case it must be either -20 or
170 * -21. It is interpreted as a `ghost' stem, according to the Type 1
173 * If the length is -21 (corresponding to a bottom ghost stem), then
174 * the real stem position is `coords[0]+coords[1]'.
178 (*T1_Hints_SetStemFunc
)( T1_Hints hints
,
183 /*************************************************************************
186 * T1_Hints_SetStem3Func
189 * A method of the @T1_Hints class used to record three
190 * counter-controlled horizontal or vertical stems at once.
194 * A handle to the Type 1 hints recorder.
197 * 0 for horizontal stems, 1 for vertical ones.
200 * An array of 6 integers, holding 3 (position,length) pairs for the
201 * counter-controlled stems.
204 * Use vertical coordinates (y) for horizontal stems (dim=0). Use
205 * horizontal coordinates (x) for vertical stems (dim=1).
207 * The lengths cannot be negative (ghost stems are never
208 * counter-controlled).
212 (*T1_Hints_SetStem3Func
)( T1_Hints hints
,
217 /*************************************************************************
223 * A method of the @T1_Hints class used to reset the stems hints in a
228 * A handle to the Type 1 hints recorder.
231 * The index of the last point in the input glyph in which the
232 * previously defined hints apply.
236 (*T1_Hints_ResetFunc
)( T1_Hints hints
,
240 /*************************************************************************
246 * A method of the @T1_Hints class used to close a hint recording
251 * A handle to the Type 1 hints recorder.
254 * The index of the last point in the input glyph.
257 * FreeType error code. 0 means success.
260 * The error code is set to indicate that an error occurred during the
265 (*T1_Hints_CloseFunc
)( T1_Hints hints
,
269 /*************************************************************************
275 * A method of the @T1_Hints class used to apply hints to the
276 * corresponding glyph outline. Must be called once all hints have been
281 * A handle to the Type 1 hints recorder.
284 * A pointer to the target outline descriptor.
287 * The hinter globals for this font.
290 * Hinting information.
293 * FreeType error code. 0 means success.
296 * On input, all points within the outline are in font coordinates. On
297 * output, they are in 1/64th of pixels.
299 * The scaling transformation is taken from the `globals' object which
300 * must correspond to the same font as the glyph.
304 (*T1_Hints_ApplyFunc
)( T1_Hints hints
,
307 FT_Render_Mode hint_mode
);
310 /*************************************************************************
316 * The structure used to provide the API to @T1_Hints objects.
320 * A handle to the T1 Hints recorder.
323 * The function to open a recording session.
326 * The function to close a recording session.
329 * The function to set a simple stem.
332 * The function to set counter-controlled stems.
335 * The function to reset stem hints.
338 * The function to apply the hints to the corresponding glyph outline.
341 typedef struct T1_Hints_FuncsRec_
344 T1_Hints_OpenFunc open
;
345 T1_Hints_CloseFunc close
;
346 T1_Hints_SetStemFunc stem
;
347 T1_Hints_SetStem3Func stem3
;
348 T1_Hints_ResetFunc reset
;
349 T1_Hints_ApplyFunc apply
;
354 /*************************************************************************/
355 /*************************************************************************/
357 /***** PUBLIC TYPE 2 HINTS RECORDER *****/
359 /*************************************************************************/
360 /*************************************************************************/
362 /*************************************************************************
368 * This is a handle to an opaque structure used to record glyph hints
369 * from a Type 2 character glyph character string.
371 * The methods used to operate on this object are defined by the
372 * @T2_Hints_FuncsRec structure. Recording glyph hints is normally
373 * achieved through the following scheme:
375 * - Open a new hint recording session by calling the `open' method.
376 * This rewinds the recorder and prepare it for new input.
378 * - For each hint found in the glyph charstring, call the corresponding
379 * method (`stems', `hintmask', `counters'). Note that these
380 * functions do not return an error code.
382 * - Close the recording session by calling the `close' method. It
383 * returns an error code if the hints were invalid or something
384 * strange happened (e.g., memory shortage).
386 * The hints accumulated in the object can later be used by the
390 typedef struct T2_HintsRec_
* T2_Hints
;
393 /*************************************************************************
399 * A pointer to the @T2_Hints_FuncsRec structure that defines the API of
400 * a given @T2_Hints object.
403 typedef const struct T2_Hints_FuncsRec_
* T2_Hints_Funcs
;
406 /*************************************************************************
412 * A method of the @T2_Hints class used to prepare it for a new Type 2
413 * hints recording session.
417 * A handle to the Type 2 hints recorder.
420 * You should always call the @T2_Hints_CloseFunc method in order to
421 * close an opened recording session.
425 (*T2_Hints_OpenFunc
)( T2_Hints hints
);
428 /*************************************************************************
434 * A method of the @T2_Hints class used to set the table of stems in
435 * either the vertical or horizontal dimension. Equivalent to the
436 * `hstem', `vstem', `hstemhm', and `vstemhm' Type 2 operators.
440 * A handle to the Type 2 hints recorder.
443 * 0 for horizontal stems (hstem), 1 for vertical ones (vstem).
446 * The number of stems.
449 * An array of `count' (position,length) pairs.
452 * Use vertical coordinates (y) for horizontal stems (dim=0). Use
453 * horizontal coordinates (x) for vertical stems (dim=1).
455 * There are `2*count' elements in the `coords' array. Each even
456 * element is an absolute position in font units, each odd element is a
457 * length in font units.
459 * A length can be negative, in which case it must be either -20 or
460 * -21. It is interpreted as a `ghost' stem, according to the Type 1
465 (*T2_Hints_StemsFunc
)( T2_Hints hints
,
468 FT_Fixed
* coordinates
);
471 /*************************************************************************
477 * A method of the @T2_Hints class used to set a given hintmask (this
478 * corresponds to the `hintmask' Type 2 operator).
482 * A handle to the Type 2 hints recorder.
485 * The glyph index of the last point to which the previously defined
486 * or activated hints apply.
489 * The number of bits in the hint mask.
492 * An array of bytes modelling the hint mask.
495 * If the hintmask starts the charstring (before any glyph point
496 * definition), the value of `end_point' should be 0.
498 * `bit_count' is the number of meaningful bits in the `bytes' array; it
499 * must be equal to the total number of hints defined so far (i.e.,
500 * horizontal+verticals).
502 * The `bytes' array can come directly from the Type 2 charstring and
503 * respects the same format.
507 (*T2_Hints_MaskFunc
)( T2_Hints hints
,
510 const FT_Byte
* bytes
);
513 /*************************************************************************
516 * T2_Hints_CounterFunc
519 * A method of the @T2_Hints class used to set a given counter mask
520 * (this corresponds to the `hintmask' Type 2 operator).
524 * A handle to the Type 2 hints recorder.
527 * A glyph index of the last point to which the previously defined or
528 * active hints apply.
531 * The number of bits in the hint mask.
534 * An array of bytes modelling the hint mask.
537 * If the hintmask starts the charstring (before any glyph point
538 * definition), the value of `end_point' should be 0.
540 * `bit_count' is the number of meaningful bits in the `bytes' array; it
541 * must be equal to the total number of hints defined so far (i.e.,
542 * horizontal+verticals).
544 * The `bytes' array can come directly from the Type 2 charstring and
545 * respects the same format.
549 (*T2_Hints_CounterFunc
)( T2_Hints hints
,
551 const FT_Byte
* bytes
);
554 /*************************************************************************
560 * A method of the @T2_Hints class used to close a hint recording
565 * A handle to the Type 2 hints recorder.
568 * The index of the last point in the input glyph.
571 * FreeType error code. 0 means success.
574 * The error code is set to indicate that an error occurred during the
579 (*T2_Hints_CloseFunc
)( T2_Hints hints
,
583 /*************************************************************************
589 * A method of the @T2_Hints class used to apply hints to the
590 * corresponding glyph outline. Must be called after the `close'
595 * A handle to the Type 2 hints recorder.
598 * A pointer to the target outline descriptor.
601 * The hinter globals for this font.
604 * Hinting information.
607 * FreeType error code. 0 means success.
610 * On input, all points within the outline are in font coordinates. On
611 * output, they are in 1/64th of pixels.
613 * The scaling transformation is taken from the `globals' object which
614 * must correspond to the same font than the glyph.
618 (*T2_Hints_ApplyFunc
)( T2_Hints hints
,
621 FT_Render_Mode hint_mode
);
624 /*************************************************************************
630 * The structure used to provide the API to @T2_Hints objects.
634 * A handle to the T2 hints recorder object.
637 * The function to open a recording session.
640 * The function to close a recording session.
643 * The function to set the dimension's stems table.
646 * The function to set hint masks.
649 * The function to set counter masks.
652 * The function to apply the hints on the corresponding glyph outline.
655 typedef struct T2_Hints_FuncsRec_
658 T2_Hints_OpenFunc open
;
659 T2_Hints_CloseFunc close
;
660 T2_Hints_StemsFunc stems
;
661 T2_Hints_MaskFunc hintmask
;
662 T2_Hints_CounterFunc counter
;
663 T2_Hints_ApplyFunc apply
;
671 typedef struct PSHinter_Interface_
673 PSH_Globals_Funcs (*get_globals_funcs
)( FT_Module module
);
674 T1_Hints_Funcs (*get_t1_funcs
) ( FT_Module module
);
675 T2_Hints_Funcs (*get_t2_funcs
) ( FT_Module module
);
677 } PSHinter_Interface
;
679 typedef PSHinter_Interface
* PSHinter_Service
;
684 #endif /* __PSHINTS_H__ */