Commit 7723dc34d3fd0b1b437a1371c6ea589bdb49f047

Werner Lemberg 2007-06-26T04:44:35

Add autofit module for Indic scripts. This currently just reuses the CJK-specific functions. * include/freetype/config/ftoption.h (AF_CONFIG_OPTION_INDIC): New macro. * devel/ftoption.h: Synchronize with include/freetype/config/ftoption.h. * src/autofit/afindic.c, src/autofit/afindic.h: New files. * src/autofit/afglobal.c, src/autofit/aftypes.h, src/autofit/autofit.c: Updated. * src/autofit/Jamfile (_sources), * src/autofit/rules.mk (AUTOF_DRV_SRC): Updated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
diff --git a/ChangeLog b/ChangeLog
index 8dba825..38493fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-06-26  Rahul Bhalerao  <b.rahul.pm@gmail.com>
+
+	Add autofit module for Indic scripts.  This currently just reuses
+	the CJK-specific functions.
+
+	* include/freetype/config/ftoption.h (AF_CONFIG_OPTION_INDIC): New
+	macro.
+	* devel/ftoption.h: Synchronize with
+	include/freetype/config/ftoption.h.
+
+	* src/autofit/afindic.c, src/autofit/afindic.h: New files.
+
+	* src/autofit/afglobal.c, src/autofit/aftypes.h,
+	src/autofit/autofit.c: Updated.
+
+	* src/autofit/Jamfile (_sources), * src/autofit/rules.mk
+	(AUTOF_DRV_SRC): Updated.
+
 2007-06-23  David Turner  <david@freetype.org>
 
 	* src/truetype/ttgload.c (TT_Load_Simple): Fix change from
diff --git a/devel/ftoption.h b/devel/ftoption.h
index 0add36a..6cf1af2 100644
--- a/devel/ftoption.h
+++ b/devel/ftoption.h
@@ -302,7 +302,9 @@ FT_BEGIN_HEADER
   /* The size in bytes of the render pool used by the scan-line converter  */
   /* to do all of its work.                                                */
   /*                                                                       */
-  /* This must be greater than 4KByte.                                     */
+  /* This must be greater than 4KByte if you use FreeType to rasterize     */
+  /* glyphs; otherwise, you may set it to zero to avoid unnecessary        */
+  /* allocation of the render pool.                                        */
   /*                                                                       */
 #define FT_RENDER_POOL_SIZE  16384L
 
@@ -461,12 +463,47 @@ FT_BEGIN_HEADER
 
   /*************************************************************************/
   /*                                                                       */
-  /* Define TT_CONFIG_OPTION_UNPATENTED_HINTING (in addition to            */
-  /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER) to compile the unpatented      */
-  /* work-around hinting system.  Note that for the moment, the algorithm  */
-  /* is only used when selected at runtime through the parameter tag       */
-  /* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook               */
-  /* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally activated.               */
+  /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version  */
+  /* of the TrueType bytecode interpreter is used that doesn't implement   */
+  /* any of the patented opcodes and algorithms.  Note that the            */
+  /* the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you     */
+  /* define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; with other words,       */
+  /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or                */
+  /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time.    */
+  /*                                                                       */
+  /* This macro is only useful for a small number of font files (mostly    */
+  /* for Asian scripts) that require bytecode interpretation to properly   */
+  /* load glyphs.  For all other fonts, this produces unpleasant results,  */
+  /* thus the unpatented interpreter is never used to load glyphs from     */
+  /* TrueType fonts unless one of the following two options is used.       */
+  /*                                                                       */
+  /*   - The unpatented interpreter is explicitly activated by the user    */
+  /*     through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag         */
+  /*     when opening the FT_Face.                                         */
+  /*                                                                       */
+  /*   - FreeType detects that the FT_Face corresponds to one of the       */
+  /*     `trick' fonts (e.g., `Mingliu') it knows about.  The font engine  */
+  /*     contains a hard-coded list of font names and other matching       */
+  /*     parameters (see function `tt_face_init' in file                   */
+  /*     `src/truetype/ttobjs.c').                                         */
+  /*                                                                       */
+  /* Here a sample code snippet for using FT_PARAM_TAG_UNPATENTED_HINTING. */
+  /*                                                                       */
+  /*   {                                                                   */
+  /*     FT_Parameter  parameter;                                          */
+  /*     FT_Open_Args  open_args;                                          */
+  /*                                                                       */
+  /*                                                                       */
+  /*     parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING;                  */
+  /*                                                                       */
+  /*     open_args.flags      = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;         */
+  /*     open_args.pathname   = my_font_pathname;                          */
+  /*     open_args.num_params = 1;                                         */
+  /*     open_args.params     = &parameter;                                */
+  /*                                                                       */
+  /*     error = FT_Open_Face( library, &open_args, index, &face );        */
+  /*     ...                                                               */
+  /*   }                                                                   */
   /*                                                                       */
 /* #define TT_CONFIG_OPTION_UNPATENTED_HINTING */
 
@@ -592,6 +629,12 @@ FT_BEGIN_HEADER
 #define AF_CONFIG_OPTION_CJK
 
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* Compile autofit module with Indic script support.                     */
+  /*                                                                       */
+#define AF_CONFIG_OPTION_INDIC
+
   /* */
 
 
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 9d1a743..532848d 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -628,6 +628,11 @@ FT_BEGIN_HEADER
   /*                                                                       */
 #define AF_CONFIG_OPTION_CJK
 
+  /*************************************************************************/
+  /*                                                                       */
+  /* Compile autofit module with Indic script support.                     */
+  /*                                                                       */
+#define AF_CONFIG_OPTION_INDIC
 
   /* */
 
diff --git a/src/autofit/Jamfile b/src/autofit/Jamfile
index 550f3d1..acee8bf 100644
--- a/src/autofit/Jamfile
+++ b/src/autofit/Jamfile
@@ -1,6 +1,6 @@
 # FreeType 2 src/autofit Jamfile
 #
-# Copyright 2003, 2004, 2005, 2006 by
+# Copyright 2003, 2004, 2005, 2006, 2007 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -21,7 +21,7 @@ SubDir FT2_TOP src autofit ;
   }
   if $(FT2_MULTI)
   {
-    _sources = afangles afglobal afhints aflatin afloader afmodule afdummy afwarp ;
+    _sources = afangles afglobal afhints aflatin afcjk afindic afloader afmodule afdummy afwarp ;
 
     if $(FT2_AUTOFIT2)
     {
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index a272d50..ad3baa1 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -20,6 +20,8 @@
 #include "afdummy.h"
 #include "aflatin.h"
 #include "afcjk.h"
+#include "afindic.h"
+
 #include "aferrors.h"
 
 #ifdef FT_OPTION_AUTOFIT2
@@ -35,7 +37,7 @@
 #endif
     &af_latin_script_class,
     &af_cjk_script_class,
-
+    &af_indic_script_class, 
     NULL  /* do not remove */
   };
 
diff --git a/src/autofit/afindic.c b/src/autofit/afindic.c
new file mode 100644
index 0000000..c6e7522
--- /dev/null
+++ b/src/autofit/afindic.c
@@ -0,0 +1,134 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afindic.c                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines for Indic scripts (body).               */
+/*                                                                         */
+/*  Copyright 2007 by                                                      */
+/*  Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.    */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#include "aftypes.h"
+#include "aflatin.h"
+
+
+#ifdef AF_CONFIG_OPTION_INDIC
+
+#include "afindic.h"
+#include "aferrors.h"
+#include "afcjk.h"
+
+
+#ifdef AF_USE_WARPER
+#include "afwarp.h"
+#endif
+
+
+  static FT_Error
+  af_indic_metrics_init( AF_LatinMetrics  metrics,
+                         FT_Face          face )
+  {
+    /* use CJK routines */
+    return af_cjk_metrics_init( metrics, face );
+  }
+
+
+  static void
+  af_indic_metrics_scale( AF_LatinMetrics  metrics,
+			  AF_Scaler        scaler )
+  {
+    /* use CJK routines */
+    af_cjk_metrics_scale( metrics, scaler );
+  }
+
+
+  static FT_Error
+  af_indic_hints_init( AF_GlyphHints    hints,
+		       AF_LatinMetrics  metrics )
+  {
+    /* use CJK routines */
+    return af_cjk_hints_init( hints, metrics );
+  }
+
+
+  static FT_Error
+  af_indic_hints_apply( AF_GlyphHints    hints,
+			FT_Outline*      outline,
+			AF_LatinMetrics  metrics)
+  {
+    /* use CJK routines */
+    return af_cjk_hints_apply( hints, outline, metrics );
+  }
+
+
+  /*************************************************************************/
+  /*************************************************************************/
+  /*****                                                               *****/
+  /*****                I N D I C   S C R I P T   C L A S S            *****/
+  /*****                                                               *****/
+  /*************************************************************************/
+  /*************************************************************************/
+
+
+  static const AF_Script_UniRangeRec  af_indic_uniranges[] =
+  {
+#if 0
+    { 0x0100,  0xFFFF },  /* why this? */
+#endif
+    { 0x0900, 0x0DFF},    /* Indic Range */
+    { 0,       0 }
+  };
+
+
+  FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
+  af_indic_script_class =
+  {
+    AF_SCRIPT_INDIC,
+    af_indic_uniranges,
+
+    sizeof( AF_LatinMetricsRec ),
+
+    (AF_Script_InitMetricsFunc) af_indic_metrics_init,
+    (AF_Script_ScaleMetricsFunc)af_indic_metrics_scale,
+    (AF_Script_DoneMetricsFunc) NULL,
+
+    (AF_Script_InitHintsFunc)   af_indic_hints_init,
+    (AF_Script_ApplyHintsFunc)  af_indic_hints_apply
+  };
+
+#else /* !AF_CONFIG_OPTION_INDIC */
+
+  static const AF_Script_UniRangeRec  af_indic_uniranges[] =
+  {
+    { 0, 0 }
+  };
+
+
+  FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
+  af_indic_script_class =
+  {
+    AF_SCRIPT_INDIC,
+    af_indic_uniranges,
+
+    sizeof( AF_LatinMetricsRec ),
+
+    (AF_Script_InitMetricsFunc) NULL,
+    (AF_Script_ScaleMetricsFunc)NULL,
+    (AF_Script_DoneMetricsFunc) NULL,
+
+    (AF_Script_InitHintsFunc)   NULL,
+    (AF_Script_ApplyHintsFunc)  NULL
+  };
+
+#endif /* !AF_CONFIG_OPTION_INDIC */
+
+
+/* END */
diff --git a/src/autofit/afindic.h b/src/autofit/afindic.h
new file mode 100644
index 0000000..b242b26
--- /dev/null
+++ b/src/autofit/afindic.h
@@ -0,0 +1,41 @@
+/***************************************************************************/
+/*                                                                         */
+/*  afindic.h                                                              */
+/*                                                                         */
+/*    Auto-fitter hinting routines for Indic scripts (specification).      */
+/*                                                                         */
+/*  Copyright 2007 by                                                      */
+/*  Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.    */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+
+#ifndef __AFINDIC_H__
+#define __AFINDIC_H__
+
+#include "afhints.h"
+
+
+FT_BEGIN_HEADER
+
+
+  /* the Indic-specific script class */
+
+  FT_CALLBACK_TABLE const AF_ScriptClassRec
+  af_indic_script_class;
+
+
+/* */
+
+FT_END_HEADER
+
+#endif /* __AFINDIC_H__ */
+
+
+/* END */
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index c735892..bd3fa88 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -265,9 +265,11 @@ extern void*  _af_debug_hints;
     AF_SCRIPT_NONE  = 0,
     AF_SCRIPT_LATIN = 1,
     AF_SCRIPT_CJK   = 2,
+    AF_SCRIPT_INDIC = 3, 
 #ifdef FT_OPTION_AUTOFIT2
     AF_SCRIPT_LATIN2,
 #endif
+
     /* add new scripts here.  Don't forget to update the list in */
     /* `afglobal.c'.                                             */
 
diff --git a/src/autofit/autofit.c b/src/autofit/autofit.c
index 5884ab0..2fe66a9 100644
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter module (body).                                           */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005, 2006 by                                    */
+/*  Copyright 2003, 2004, 2005, 2006, 2007 by                              */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -21,12 +21,15 @@
 #include "afangles.c"
 #include "afglobal.c"
 #include "afhints.c"
+
 #include "afdummy.c"
 #include "aflatin.c"
 #ifdef FT_OPTION_AUTOFIT2
 #include "aflatin2.c"
 #endif
 #include "afcjk.c"
+#include "afindic.c"
+
 #include "afloader.c"
 #include "afmodule.c"
 
diff --git a/src/autofit/rules.mk b/src/autofit/rules.mk
index 8d6f668..017489d 100644
--- a/src/autofit/rules.mk
+++ b/src/autofit/rules.mk
@@ -3,7 +3,7 @@
 #
 
 
-# Copyright 2003, 2004, 2005, 2006 by
+# Copyright 2003, 2004, 2005, 2006, 2007 by
 # David Turner, Robert Wilhelm, and Werner Lemberg.
 #
 # This file is part of the FreeType project, and may only be used, modified,
@@ -26,11 +26,12 @@ AUTOF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(AUTOF_DIR))
 # AUTOF driver sources (i.e., C files)
 #
 AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
+                 $(AUTOF_DIR)/afcjk.c    \
                  $(AUTOF_DIR)/afdummy.c  \
                  $(AUTOF_DIR)/afglobal.c \
                  $(AUTOF_DIR)/afhints.c  \
+                 $(AUTOF_DIR)/afindic.c  \
                  $(AUTOF_DIR)/aflatin.c  \
-                 $(AUTOF_DIR)/afcjk.c    \
                  $(AUTOF_DIR)/afloader.c \
                  $(AUTOF_DIR)/afmodule.c \
                  $(AUTOF_DIR)/afwarp.c