1 /***************************************************************************/
2 /* */
3 /* pshrec.c */
4 /* */
5 /* FreeType PostScript hints recorder (body). */
6 /* */
7 /* Copyright 2001-2018 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 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_INTERNAL_DEBUG_H
23 #include FT_INTERNAL_CALC_H
24
25 #include "pshrec.h"
26 #include "pshalgo.h"
27
28 #include "pshnterr.h"
29
30 #undef FT_COMPONENT
31 #define FT_COMPONENT trace_pshrec
32
33 #ifdef DEBUG_HINTER
34 PS_Hints ps_debug_hints = NULL;
35 int ps_debug_no_horz_hints = 0;
36 int ps_debug_no_vert_hints = 0;
37 #endif
38
39
40 /*************************************************************************/
41 /*************************************************************************/
42 /***** *****/
43 /***** PS_HINT MANAGEMENT *****/
44 /***** *****/
45 /*************************************************************************/
46 /*************************************************************************/
47
48 /* destroy hints table */
49 static void
50 ps_hint_table_done( PS_Hint_Table table,
51 FT_Memory memory )
649
650 /* add a new single stem (called from "T1Stem" method) */
651 static FT_Error
652 ps_dimension_add_t1stem( PS_Dimension dim,
653 FT_Int pos,
654 FT_Int len,
655 FT_Memory memory,
656 FT_Int *aindex )
657 {
658 FT_Error error = FT_Err_Ok;
659 FT_UInt flags = 0;
660
661
662 /* detect ghost stem */
663 if ( len < 0 )
664 {
665 flags |= PS_HINT_FLAG_GHOST;
666 if ( len == -21 )
667 {
668 flags |= PS_HINT_FLAG_BOTTOM;
669 pos += len;
670 }
671 len = 0;
672 }
673
674 if ( aindex )
675 *aindex = -1;
676
677 /* now, lookup stem in the current hints table */
678 {
679 PS_Mask mask;
680 FT_UInt idx;
681 FT_UInt max = dim->hints.num_hints;
682 PS_Hint hint = dim->hints.hints;
683
684
685 for ( idx = 0; idx < max; idx++, hint++ )
686 {
687 if ( hint->pos == pos && hint->len == len )
688 break;
689 }
1170 t2_hints_stems( T2_Hints hints,
1171 FT_UInt dimension,
1172 FT_Int count,
1173 FT_Fixed* coords )
1174 {
1175 FT_Pos stems[32], y;
1176 FT_Int total = count, n;
1177
1178
1179 y = 0;
1180 while ( total > 0 )
1181 {
1182 /* determine number of stems to write */
1183 count = total;
1184 if ( count > 16 )
1185 count = 16;
1186
1187 /* compute integer stem positions in font units */
1188 for ( n = 0; n < count * 2; n++ )
1189 {
1190 y += coords[n];
1191 stems[n] = FIXED_TO_INT( y );
1192 }
1193
1194 /* compute lengths */
1195 for ( n = 0; n < count * 2; n += 2 )
1196 stems[n + 1] = stems[n + 1] - stems[n];
1197
1198 /* add them to the current dimension */
1199 ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
1200
1201 total -= count;
1202 }
1203 }
1204
1205
1206 FT_LOCAL_DEF( void )
1207 t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
1208 {
1209 FT_ZERO( funcs );
1210
|
1 /****************************************************************************
2 *
3 * pshrec.c
4 *
5 * FreeType PostScript hints recorder (body).
6 *
7 * Copyright (C) 2001-2019 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 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_INTERNAL_DEBUG_H
23 #include FT_INTERNAL_CALC_H
24
25 #include "pshrec.h"
26 #include "pshalgo.h"
27
28 #include "pshnterr.h"
29
30 #undef FT_COMPONENT
31 #define FT_COMPONENT pshrec
32
33 #ifdef DEBUG_HINTER
34 PS_Hints ps_debug_hints = NULL;
35 int ps_debug_no_horz_hints = 0;
36 int ps_debug_no_vert_hints = 0;
37 #endif
38
39
40 /*************************************************************************/
41 /*************************************************************************/
42 /***** *****/
43 /***** PS_HINT MANAGEMENT *****/
44 /***** *****/
45 /*************************************************************************/
46 /*************************************************************************/
47
48 /* destroy hints table */
49 static void
50 ps_hint_table_done( PS_Hint_Table table,
51 FT_Memory memory )
649
650 /* add a new single stem (called from "T1Stem" method) */
651 static FT_Error
652 ps_dimension_add_t1stem( PS_Dimension dim,
653 FT_Int pos,
654 FT_Int len,
655 FT_Memory memory,
656 FT_Int *aindex )
657 {
658 FT_Error error = FT_Err_Ok;
659 FT_UInt flags = 0;
660
661
662 /* detect ghost stem */
663 if ( len < 0 )
664 {
665 flags |= PS_HINT_FLAG_GHOST;
666 if ( len == -21 )
667 {
668 flags |= PS_HINT_FLAG_BOTTOM;
669 pos = ADD_INT( pos, len );
670 }
671 len = 0;
672 }
673
674 if ( aindex )
675 *aindex = -1;
676
677 /* now, lookup stem in the current hints table */
678 {
679 PS_Mask mask;
680 FT_UInt idx;
681 FT_UInt max = dim->hints.num_hints;
682 PS_Hint hint = dim->hints.hints;
683
684
685 for ( idx = 0; idx < max; idx++, hint++ )
686 {
687 if ( hint->pos == pos && hint->len == len )
688 break;
689 }
1170 t2_hints_stems( T2_Hints hints,
1171 FT_UInt dimension,
1172 FT_Int count,
1173 FT_Fixed* coords )
1174 {
1175 FT_Pos stems[32], y;
1176 FT_Int total = count, n;
1177
1178
1179 y = 0;
1180 while ( total > 0 )
1181 {
1182 /* determine number of stems to write */
1183 count = total;
1184 if ( count > 16 )
1185 count = 16;
1186
1187 /* compute integer stem positions in font units */
1188 for ( n = 0; n < count * 2; n++ )
1189 {
1190 y = ADD_LONG( y, coords[n] );
1191 stems[n] = FIXED_TO_INT( y );
1192 }
1193
1194 /* compute lengths */
1195 for ( n = 0; n < count * 2; n += 2 )
1196 stems[n + 1] = stems[n + 1] - stems[n];
1197
1198 /* add them to the current dimension */
1199 ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
1200
1201 total -= count;
1202 }
1203 }
1204
1205
1206 FT_LOCAL_DEF( void )
1207 t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
1208 {
1209 FT_ZERO( funcs );
1210
|