"Fossies" - the Fresh Open Source Software Archive 
Member "SDL2_ttf-2.20.2/external/freetype/src/autofit/afindic.c" (25 May 2022, 4548 Bytes) of package /linux/misc/SDL2_ttf-2.20.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "afindic.c" see the
Fossies "Dox" file reference documentation.
1 /****************************************************************************
2 *
3 * afindic.c
4 *
5 * Auto-fitter hinting routines for Indic writing system (body).
6 *
7 * Copyright (C) 2007-2022 by
8 * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
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 "aftypes.h"
20 #include "aflatin.h"
21 #include "afcjk.h"
22
23
24 #ifdef AF_CONFIG_OPTION_INDIC
25
26 #include "afindic.h"
27 #include "aferrors.h"
28
29
30 static FT_Error
31 af_indic_metrics_init( AF_CJKMetrics metrics,
32 FT_Face face )
33 {
34 /* skip blue zone init in CJK routines */
35 FT_CharMap oldmap = face->charmap;
36
37
38 metrics->units_per_em = face->units_per_EM;
39
40 if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
41 face->charmap = NULL;
42 else
43 {
44 af_cjk_metrics_init_widths( metrics, face );
45 #if 0
46 /* either need indic specific blue_chars[] or just skip blue zones */
47 af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
48 #endif
49 af_cjk_metrics_check_digits( metrics, face );
50 }
51
52 FT_Set_Charmap( face, oldmap );
53
54 return FT_Err_Ok;
55 }
56
57
58 static void
59 af_indic_metrics_scale( AF_CJKMetrics metrics,
60 AF_Scaler scaler )
61 {
62 /* use CJK routines */
63 af_cjk_metrics_scale( metrics, scaler );
64 }
65
66
67 static FT_Error
68 af_indic_hints_init( AF_GlyphHints hints,
69 AF_CJKMetrics metrics )
70 {
71 /* use CJK routines */
72 return af_cjk_hints_init( hints, metrics );
73 }
74
75
76 static FT_Error
77 af_indic_hints_apply( FT_UInt glyph_index,
78 AF_GlyphHints hints,
79 FT_Outline* outline,
80 AF_CJKMetrics metrics )
81 {
82 /* use CJK routines */
83 return af_cjk_hints_apply( glyph_index, hints, outline, metrics );
84 }
85
86
87 /* Extract standard_width from writing system/script specific */
88 /* metrics class. */
89
90 static void
91 af_indic_get_standard_widths( AF_CJKMetrics metrics,
92 FT_Pos* stdHW,
93 FT_Pos* stdVW )
94 {
95 if ( stdHW )
96 *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
97
98 if ( stdVW )
99 *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
100 }
101
102
103 /*************************************************************************/
104 /*************************************************************************/
105 /***** *****/
106 /***** I N D I C S C R I P T C L A S S *****/
107 /***** *****/
108 /*************************************************************************/
109 /*************************************************************************/
110
111
112 AF_DEFINE_WRITING_SYSTEM_CLASS(
113 af_indic_writing_system_class,
114
115 AF_WRITING_SYSTEM_INDIC,
116
117 sizeof ( AF_CJKMetricsRec ),
118
119 (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */
120 (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */
121 (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
122 (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */
123
124 (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */
125 (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */
126 )
127
128
129 #else /* !AF_CONFIG_OPTION_INDIC */
130
131
132 AF_DEFINE_WRITING_SYSTEM_CLASS(
133 af_indic_writing_system_class,
134
135 AF_WRITING_SYSTEM_INDIC,
136
137 sizeof ( AF_CJKMetricsRec ),
138
139 (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
140 (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
141 (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
142 (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
143
144 (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
145 (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
146 )
147
148
149 #endif /* !AF_CONFIG_OPTION_INDIC */
150
151
152 /* END */