*** empty log message ***
[m17n/m17n-pango.git] / m17n-fc.c
1 /* Pango
2  * m17n-fc.c: Generic shaper using the m17n library for FreeType-based backends
3
4    Copyright (C) 2004, 2005, 2006, 2007, 2008
5      National Institute of Advanced Industrial Science and Technology (AIST)
6      Registration Number H16PRO276
7
8    The library is free software; you can redistribute it and/or modify
9    it under the terms of the GNU Lesser General Public License as
10    published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The pango-m17n library is distributed in the hope that it will be
14    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the pango-m17n library; if not, write to the
20    Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21    MA 02111-1307, USA.  */
22
23 #include <config.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include <ctype.h>
27
28 #include <pango/pango-ot.h>
29 #include <pango/pango-engine.h>
30 #include <pango/pangofc-font.h>
31
32 #ifdef G_LOG_DOMAIN
33 #undef G_LOG_DOMAIN
34 #endif
35 #define G_LOG_DOMAIN "Pango-M17N-FC"
36
37 /**************************************/
38 /* Standard preamble for Pango module */
39 /**************************************/
40
41 /* No extra fields needed for these structures.  */
42 typedef PangoEngineShape      M17NEngineFc;
43 typedef PangoEngineShapeClass M17NEngineFcClass;
44
45 #define SCRIPT_ENGINE_NAME "M17NScriptEngineFc"
46 #define RENDER_TYPE PANGO_RENDER_TYPE_FC
47
48 static PangoEngineScriptInfo m17n_scripts[] = {
49   { PANGO_SCRIPT_ARABIC,   "*" },
50   { PANGO_SCRIPT_ARMENIAN, "*" },
51   { PANGO_SCRIPT_BENGALI,  "*" },
52   { PANGO_SCRIPT_BOPOMOFO, "*" },
53   { PANGO_SCRIPT_CHEROKEE, "*" },
54   { PANGO_SCRIPT_COPTIC,   "*" },
55   { PANGO_SCRIPT_CYRILLIC, "*" },
56   { PANGO_SCRIPT_DESERET,  "*" },
57   { PANGO_SCRIPT_DEVANAGARI, "*" },
58   { PANGO_SCRIPT_ETHIOPIC, "*" },
59   { PANGO_SCRIPT_GEORGIAN, "*" },
60   { PANGO_SCRIPT_GOTHIC,   "*" },
61   { PANGO_SCRIPT_GREEK,    "*" },
62   { PANGO_SCRIPT_GUJARATI, "*" },
63   { PANGO_SCRIPT_GURMUKHI, "*" },
64   { PANGO_SCRIPT_HAN,      "*" },
65   { PANGO_SCRIPT_HANGUL,   "*" },
66   { PANGO_SCRIPT_HEBREW,   "*" },
67   { PANGO_SCRIPT_HIRAGANA, "*" },
68   { PANGO_SCRIPT_KANNADA,  "*" },
69   { PANGO_SCRIPT_KATAKANA, "*" },
70   { PANGO_SCRIPT_KHMER,    "*" },
71   { PANGO_SCRIPT_LAO,      "*" },
72   { PANGO_SCRIPT_MALAYALAM, "*" },
73   { PANGO_SCRIPT_MYANMAR,  "*" },
74   { PANGO_SCRIPT_OGHAM,    "*" },
75   { PANGO_SCRIPT_OLD_ITALIC, "*" },
76   { PANGO_SCRIPT_ORIYA,     "*" },
77   { PANGO_SCRIPT_RUNIC,     "*" },
78   { PANGO_SCRIPT_SINHALA,   "*" },
79   { PANGO_SCRIPT_SYRIAC,    "*" },
80   { PANGO_SCRIPT_TAMIL,     "*" },
81   { PANGO_SCRIPT_TELUGU,    "*" },
82   { PANGO_SCRIPT_THAANA,    "*" },
83   { PANGO_SCRIPT_THAI,      "*" },
84   { PANGO_SCRIPT_TIBETAN,   "*" },
85   { PANGO_SCRIPT_CANADIAN_ABORIGINAL, "*" },
86   { PANGO_SCRIPT_YI,       "*" },
87
88   { PANGO_SCRIPT_BRAILLE,  "*" },
89   { PANGO_SCRIPT_CYPRIOT,  "*" },
90   { PANGO_SCRIPT_LIMBU,    "*" },
91   { PANGO_SCRIPT_OSMANYA,  "*" },
92   { PANGO_SCRIPT_SHAVIAN,  "*" },
93   { PANGO_SCRIPT_LINEAR_B, "*" },
94   { PANGO_SCRIPT_TAI_LE,   "*" },
95   { PANGO_SCRIPT_UGARITIC, "*" },
96
97   { PANGO_SCRIPT_NEW_TAI_LUE, "*" },
98   { PANGO_SCRIPT_BUGINESE, "*" },
99   { PANGO_SCRIPT_GLAGOLITIC, "*" },
100   { PANGO_SCRIPT_TIFINAGH, "*" },
101   { PANGO_SCRIPT_SYLOTI_NAGRI, "*" },
102   { PANGO_SCRIPT_OLD_PERSIAN, "*" },
103   { PANGO_SCRIPT_KHAROSHTHI, "*" },
104   { PANGO_SCRIPT_COMMON,   "" }
105 };
106
107 static PangoEngineInfo script_engines[] = {
108   {
109     SCRIPT_ENGINE_NAME,
110     PANGO_ENGINE_TYPE_SHAPE,
111     RENDER_TYPE,
112     m17n_scripts, G_N_ELEMENTS (m17n_scripts)
113   }
114 };
115
116 /***************************/
117 /* Interface with m17n-flt */
118 /***************************/
119
120 #include <m17n-flt.h>
121 #include <m17n-misc.h>
122
123 /* Return a pointer to the IDXth glyph in GSTRING.  */
124 #define GREF(GSTRING, IDX) ((GSTRING)->glyphs + (IDX))
125
126 /* Convert Pango scale to 26.6 fractional pixel.  */
127 #define PANGO_SCALE_TO_26_6(N) ((N) / (PANGO_SCALE) * (1<<6))
128
129 /* Convert 26.6 fractional pixel to Pango scale.  */
130 #define PANGO_SCALE_FROM_26_6(N) ((N) * (PANGO_SCALE) / (1<<6))
131
132 /* Control printing of debug information.  It is initialized from the
133    environment variable PANGO_M17N_FC_DEBUG.  Currently, any positive
134    value turns on all debug messages.  */
135 static int debug_level;
136
137
138 /* Structure containing information about OT features decoded from
139    MFLTOtfSpec.  */
140
141 typedef struct {
142   /* Rulesets for GSUB (1st element) and GPOS (2nd element).  */
143   PangoOTRuleset *ruleset[2];
144 } FeatureInfo;
145
146
147 /* Structure containing information about a font.  */
148
149 typedef struct {
150   MFLTFont font;
151   PangoFcFont *pango_font;
152   FT_Face face;
153   /* Cache that maps MFLTOtfSpec->sym to FeatureInfo.  */
154   MPlist *otf_spec_cache;
155 } FontInfo;
156
157
158 /* Prototypes for callback functions of FontInfo.font.  */
159
160 static int get_glyph_id (MFLTFont *, MFLTGlyphString *, int, int);
161 static int get_metrics (MFLTFont *, MFLTGlyphString *, int, int);
162 static int check_otf (MFLTFont *, MFLTOtfSpec *);
163 static int drive_otf (MFLTFont *, MFLTOtfSpec *,
164                       MFLTGlyphString *, int, int,
165                       MFLTGlyphString *, MFLTGlyphAdjustment *);
166
167
168 /* This function works in two ways.
169
170    If INFO is NULL, it checks if the features specified in SPEC match
171    with the OpenType font in OT_INFO, and return 1 (match) or 0 (no
172    match).
173
174    If INFO is non-NULL, it creates a PangoOTRuleset object from SPEC
175    and stores it in INFO.  In this case, non-existing features in SPEC
176    are just ignored.
177
178    Features in SPEC are stored in an array in this format:
179         P P ... [ 0xFFFFFFFF [ N N ... ] ]
180    where
181         Ps are positive features that should be in the font (INFO is
182         NULL), or should be applied in this order (INFO is non-NULL),
183
184         0xFFFFFFFF is a separater between Ps and Ns (INFO is NULL), or
185         is a wildcard meaning that all the other features (except for
186         Ns) must be applied (INFO is non-NULL),
187
188         Ns are negative features that should not be in the font (INFO
189         is NULL), or should not be applied (INFO is non-NULL).  */
190
191 static int
192 otf_check_features (PangoOTInfo *ot_info, PangoOTTableType type, 
193                     MFLTOtfSpec *spec, FeatureInfo *info)
194 {
195   unsigned int *features;
196   unsigned int langsys_tag;
197   guint script_idx, langsys_idx;
198   guint index;
199   guint *feature_list;
200   int i, j;
201   /* Used as an index to spec->features[] and info->ruleset[].  */
202   int for_gpos = type == PANGO_OT_TABLE_GPOS;
203
204   features = spec->features[for_gpos];
205   if (! features)
206     return 1;
207   if (! pango_ot_info_find_script (ot_info, type, spec->script, &script_idx))
208     /* No feature for the specified script exist.  If the first
209        feature in SPEC is a wildcard, the remaining features are all
210        negative, so we can return 1.  */
211     return (features[0] == 0xFFFFFFFF);
212   langsys_tag = spec->langsys;
213   if (! langsys_tag)
214     langsys_tag = PANGO_OT_DEFAULT_LANGUAGE;
215   pango_ot_info_find_language (ot_info, type, script_idx,
216                                langsys_tag, &langsys_idx, &index);
217
218   if (index != 0xFFFF)
219     {
220       info->ruleset[for_gpos] = pango_ot_ruleset_new (ot_info);
221       pango_ot_ruleset_add_feature (info->ruleset[for_gpos], type,
222                                     index, PANGO_OT_ALL_GLYPHS);
223     }
224
225   for (i = 0; features[i] && features[i] != 0xFFFFFFFF; i++)
226     {
227       if (pango_ot_info_find_feature (ot_info, type, features[i],
228                                       script_idx, langsys_idx, &index))
229         {
230           if (info)
231             {
232               if (! info->ruleset[for_gpos])
233                 info->ruleset[for_gpos] = pango_ot_ruleset_new (ot_info);
234               pango_ot_ruleset_add_feature (info->ruleset[for_gpos], type,
235                                             index, PANGO_OT_ALL_GLYPHS);
236             }
237         }
238       else
239         {
240           if (! info)
241             return 0;
242         }
243     }
244   if (! features[i])
245     /* No wildcard, no negative features.  */
246     return 1;
247
248   feature_list = pango_ot_info_list_features (ot_info, type, 0,
249                                               script_idx, langsys_idx);
250   if (! feature_list)
251     /* No feature for the specified script/language exist.  As the
252        remaining features are all negative, we can return 1.  */
253     return 1;
254
255   if (! info)
256     {
257       /* Check if the remaining features don't appear in
258          FEATURE_LIST.  */
259       for (i++; features[i]; i++)
260         for (j = 0; feature_list[j]; j++)
261           if (features[i] == feature_list[j])
262             return 0;
263       return 1;
264     }
265
266   /* Add all features in FEATURE_LIST except for those appearing in
267      FEATURES.  */
268   for (i = 0; feature_list[i]; i++)
269     {
270       guint tag = feature_list[i];
271
272       for (j = 0; features[j] && tag != features[j]; j++);
273       if (! features[j])
274         {
275           pango_ot_info_find_feature (ot_info, type, tag,
276                                       script_idx, langsys_idx, &index);
277           if (! info->ruleset[for_gpos])
278             info->ruleset[for_gpos] = pango_ot_ruleset_new (ot_info);
279           pango_ot_ruleset_add_feature (info->ruleset[for_gpos], type, index,
280                                         PANGO_OT_ALL_GLYPHS);
281         }
282     }
283   return 1;
284 }
285
286
287 /* Return a FeatureInfo object (newly created if necessary) for the
288    font in FONT_INFO and for the OpenType feature specification in
289    SPEC.  */
290
291 static FeatureInfo *
292 get_feature_info (FontInfo *font_info, MFLTOtfSpec *spec)
293 {
294   FeatureInfo *feature_info;
295   PangoOTInfo *ot_info; 
296
297   if (! spec->features[0] && ! spec->features[1])
298     return NULL;
299   if (font_info->otf_spec_cache)
300     {
301       feature_info = mplist_get (font_info->otf_spec_cache, spec->sym);
302       if (feature_info)
303         return feature_info;
304     }
305   else
306     font_info->otf_spec_cache = mplist ();
307   feature_info = g_new0 (FeatureInfo, 1);
308   mplist_push (font_info->otf_spec_cache, spec->sym, feature_info);
309   ot_info = pango_ot_info_get (font_info->face);
310   otf_check_features (ot_info, PANGO_OT_TABLE_GSUB, spec, feature_info);
311   otf_check_features (ot_info, PANGO_OT_TABLE_GPOS, spec, feature_info);
312
313   return feature_info;
314 }
315
316
317 /* Free the object pointed by FONT_INFO.  */
318
319 static void
320 free_font_info (FontInfo *font_info)
321 {
322   if (font_info->otf_spec_cache)
323     {
324       MPlist *p;
325
326       for (p = font_info->otf_spec_cache; mplist_key (p) != Mnil;
327            p = mplist_next (p))
328         {
329           FeatureInfo *feature_info = mplist_value (p);
330
331           if (feature_info->ruleset[0])
332             g_object_unref (feature_info->ruleset[0]);
333           if (feature_info->ruleset[1])
334             g_object_unref (feature_info->ruleset[1]);
335         }
336       m17n_object_unref (font_info->otf_spec_cache);
337     }
338   pango_fc_font_unlock_face (font_info->pango_font);
339   g_free (font_info);
340 }
341
342
343 /* Return a FontInfo object corresponding to FONT.  It is newly
344    created if necessary.  */
345
346 static FontInfo *
347 get_font_info  (PangoFont *font)
348 {
349   FontInfo *font_info;
350   static GQuark info_id = 0;
351   
352   if (G_UNLIKELY (! info_id))
353     info_id = g_quark_from_string ("FontInfo");
354   font_info = g_object_get_qdata (G_OBJECT (font), info_id);
355   if (G_UNLIKELY (! font_info))
356     {
357       PangoFontDescription *desc;
358       const char *family_name;
359       char *buf;
360       int len, i;
361
362       font_info = g_new0 (FontInfo, 1);
363       font_info->pango_font = PANGO_FC_FONT (font);
364       font_info->face = pango_fc_font_lock_face (font_info->pango_font);
365       desc = pango_font_describe_with_absolute_size (font);
366       family_name = pango_font_description_get_family (desc);
367       if (family_name)
368         {
369           len = strlen (family_name);
370           buf = g_alloca (len + 1);
371           for (i = 0; i < len + 1; i++)
372             buf[i] = tolower (family_name[i]);
373           font_info->font.family = msymbol (buf);
374         }
375       font_info->font.x_ppem = font_info->font.y_ppem
376         = PANGO_SCALE_TO_26_6 (pango_font_description_get_size (desc));
377       pango_font_description_free (desc);
378       font_info->font.check_otf = check_otf;
379       font_info->font.get_glyph_id = get_glyph_id;
380       font_info->font.get_metrics = get_metrics;
381       font_info->font.drive_otf = drive_otf;
382       g_object_set_qdata_full (G_OBJECT (font), info_id,
383                                font_info, (GDestroyNotify) free_font_info);
384     }
385   return font_info;
386 }
387
388 /* Four callback functions for MFLTFont.  */
389
390 static int
391 get_glyph_id (MFLTFont *font, MFLTGlyphString *gstring, int from, int to)
392 {
393   FontInfo *font_info = (FontInfo *) font;
394   MFLTGlyph *g = gstring->glyphs + from, *g_end = g + (to - from);
395   int err = 0;
396
397   for (; g < g_end; g++)
398     {
399       if (! g->encoded)
400         {
401           g->code = pango_fc_font_get_glyph (font_info->pango_font, g->code);
402           g->encoded = 1;
403           err |= (! g->code);
404         }
405     }
406   return err;
407 }
408
409 static int
410 get_metrics (MFLTFont *font, MFLTGlyphString *gstring, int from, int to)
411 {
412   FontInfo *font_info = (FontInfo *) font;
413   MFLTGlyph *g = gstring->glyphs + from, *g_end = g + (to - from);
414   int err = 0;
415
416   for (; g < g_end; g++)
417     {
418       if (! g->measured)
419         {
420           PangoRectangle inc, logical;
421
422           if (! g->encoded)
423             g->code = pango_fc_font_get_glyph (font_info->pango_font, g->code);
424           pango_font_get_glyph_extents (PANGO_FONT (font_info->pango_font),
425                                         g->code, &inc, &logical);
426           g->lbearing = PANGO_SCALE_TO_26_6 (inc.x);
427           g->rbearing = PANGO_SCALE_TO_26_6 (inc.x + inc.width);
428           g->xadv = PANGO_SCALE_TO_26_6 (logical.width);
429           g->yadv = 0;
430           g->ascent = - PANGO_SCALE_TO_26_6 (inc.y);
431           g->descent = PANGO_SCALE_TO_26_6 (inc.height + inc.y);
432           g->measured = 1;
433           err |= (! g->code);
434         }
435     }
436   return err;
437 }
438
439 static int
440 check_otf (MFLTFont *font, MFLTOtfSpec *spec)
441 {
442   FontInfo *font_info = (FontInfo *) font;
443   PangoOTInfo *ot_info = pango_ot_info_get (font_info->face);
444
445   if (! ot_info)
446     return 0;
447   if (! otf_check_features (ot_info, PANGO_OT_TABLE_GSUB, spec, NULL)
448       || ! otf_check_features (ot_info, PANGO_OT_TABLE_GPOS, spec, NULL))
449     return 0;
450   return 1;
451 }
452
453 static int
454 drive_otf (MFLTFont *font, MFLTOtfSpec *spec,
455            MFLTGlyphString *in, int from, int to,
456            MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment)
457 {
458   FontInfo *font_info = (FontInfo *) font;
459   PangoOTBuffer *buffer;
460   FeatureInfo *feature_info;
461   PangoGlyphString *glyphs;
462   int i;
463
464   buffer = pango_ot_buffer_new (font_info->pango_font);
465   for (i = from; i < to; i++)
466     pango_ot_buffer_add_glyph (buffer, in->glyphs[i].code, 0, i);
467   feature_info = get_feature_info (font_info, spec);
468   if (! feature_info)
469     goto simple_copy;
470   if (feature_info->ruleset[0])
471     pango_ot_ruleset_substitute (feature_info->ruleset[0], buffer);
472   if (feature_info->ruleset[1])
473     pango_ot_ruleset_position (feature_info->ruleset[1], buffer);
474   glyphs = pango_glyph_string_new ();
475   pango_ot_buffer_output (buffer, glyphs);
476   for (i = 0; i < glyphs->num_glyphs; i++)
477     {
478       PangoGlyphInfo *glyph_info = glyphs->glyphs + i;
479       MFLTGlyph *g;
480
481       out->glyphs[out->used] = in->glyphs[glyphs->log_clusters[i]];
482       g = out->glyphs + out->used++;
483       if (g->code != glyph_info->glyph)
484         {
485           g->c = 0;
486           g->code = glyph_info->glyph;
487           g->measured = 0;
488         }
489       g->xoff = PANGO_SCALE_TO_26_6 (glyph_info->geometry.x_offset);
490       g->yoff = PANGO_SCALE_TO_26_6 (glyph_info->geometry.y_offset);
491       g->xadv =  PANGO_SCALE_TO_26_6 (glyph_info->geometry.width);
492       g->yadv = 0;
493       adjustment[i].set = 0;
494     }
495   pango_ot_buffer_destroy (buffer);
496   pango_glyph_string_free (glyphs);
497   return to;
498
499  simple_copy:
500   pango_ot_buffer_destroy (buffer);
501   for (i = from; i < to; i++)
502     out->glyphs[out->used++] = in->glyphs[i];
503   return to;
504 }
505
506
507 /* Shaper function.  */
508
509 /* Shape TEXT of length GSTRING->used by a font in FONT_INFO, and
510    store the result in GLYPHS.  GSTRING->glyphs is not yet allocated
511    but GSTRING->allocated tells how many glyphs to allocate.  */
512
513 static int
514 shape_text (const char *text, int *offsets, MFLTGlyphString *gstring,
515             FontInfo *font_info, PangoGlyphString *glyphs)
516 {
517   int i;
518   PangoGlyphInfo *g;
519   MFLTGlyph *mg;
520
521   gstring->glyphs = g_newa (MFLTGlyph, gstring->allocated);
522   for (i = 0; i < gstring->used; i++)
523     gstring->glyphs[i].c = g_utf8_get_char (text + offsets[i]);
524   i = mflt_run (gstring, 0, gstring->used, (MFLTFont *) font_info, NULL);
525   if (i < 0)
526     return i;
527
528   pango_glyph_string_set_size (glyphs, gstring->used);
529
530   for (i = 0, g = glyphs->glyphs, mg = gstring->glyphs; i < gstring->used;
531        i++, g++, mg++)
532     {
533       g->glyph = mg->code;
534       g->geometry.x_offset = PANGO_SCALE_FROM_26_6 (mg->xoff);
535       g->geometry.y_offset = PANGO_SCALE_FROM_26_6 (mg->yoff);
536       g->geometry.width = PANGO_SCALE_FROM_26_6 (mg->xadv);
537       g->attr.is_cluster_start = (i == 0 || mg->from != mg[-1].from);
538       glyphs->log_clusters[i]
539         = (g->attr.is_cluster_start ? offsets[mg->from]
540            : glyphs->log_clusters[i - 1]);
541     }
542   return 0;
543 }
544
545 static void 
546 m17n_fc_engine_shape (PangoEngineShape *engine,
547                       PangoFont        *font,
548                       const char       *text,
549                       int              length,
550                       const PangoAnalysis    *analysis,
551                       PangoGlyphString *glyphs)
552 {
553   FontInfo *font_info;
554   MFLTGlyphString gstring;
555   int i;
556   const char *p, *pend;
557   int *offsets;
558
559   g_return_if_fail (font != NULL);
560   g_return_if_fail (text != NULL);
561   g_return_if_fail (length >= 0);
562   g_return_if_fail (analysis != NULL);
563
564   font_info = get_font_info (font);
565
566   gstring.glyph_size = sizeof (MFLTGlyph);
567   gstring.used = 0;
568   gstring.r2l = analysis->level % 2;
569
570   offsets = g_newa (int, length);
571   for (i = 0, p = text, pend = text + length; p < pend;
572        i++, p = g_utf8_next_char (p))
573     offsets[i] = p - text;
574   gstring.used = i;
575
576   /* Try at most three times, each time with larger GSTRING->glyphs.  */
577   gstring.allocated = length;
578   for (i = 0; i < 3; i++, gstring.allocated += length)
579     {
580       int result = shape_text (text, offsets, &gstring, font_info, glyphs);
581         
582       if (result != -2)
583         {
584           g_return_if_fail (result >= 0);
585           break;
586         }
587     }
588 }
589
590 #if 0
591
592 /* Check if FONT is suitable for the character WC.  For the moment,
593    this is commented out because even if it returns
594    PANGO_COVERAGE_NONE, the other engine will use the font.  In
595    addition, the caller doesn't handle PANGO_COVERAGE_APPROXIMATE and
596    PANGO_COVERAGE_FALLBACK well.  */
597
598 static PangoCoverageLevel
599 m17n_fc_engine_covers (PangoEngineShape *engine,
600                        PangoFont        *font,
601                        PangoLanguage    *language,
602                        gunichar          wc)
603 {
604   FontInfo *font_info = get_font_info (font);
605   MFLT *flt = mflt_find (wc, (MFLTFont *) font_info);
606   const char *lang = pango_language_to_string (language);
607
608   if (! flt)
609     {
610       if (debug_level)
611         g_debug (" %04X (%s/%s): no FLT\n", wc, lang,
612                  msymbol_name (font_info->font.family));
613       return PANGO_COVERAGE_NONE;
614     }
615   if (debug_level)
616     g_debug (" %04X (%s/%s): FLT %s found\n", wc, lang,
617              msymbol_name (font_info->font.family), mflt_name (flt));
618   return PANGO_COVERAGE_EXACT;
619 }
620
621 #endif
622
623 static void
624 m17n_engine_fc_class_init (PangoEngineShapeClass *class)
625 {
626   class->script_shape = m17n_fc_engine_shape;
627 #if 0
628   class->covers = m17n_fc_engine_covers;
629 #endif
630 }
631
632 PANGO_ENGINE_SHAPE_DEFINE_TYPE (M17NEngineFc, m17n_engine_fc,
633                                 m17n_engine_fc_class_init, NULL)
634
635 void 
636 PANGO_MODULE_ENTRY(init) (GTypeModule *module)
637 {
638   m17n_engine_fc_register_type (module);
639   M17N_INIT ();
640   if (getenv ("PANGO_M17N_DEBUG") != NULL)
641     debug_level = 1;
642 }
643
644 void 
645 PANGO_MODULE_ENTRY(exit) (void)
646 {
647   M17N_FINI ();
648 }
649
650 void 
651 PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
652                           int              *n_engines)
653 {
654   *engines = script_engines;
655   *n_engines = G_N_ELEMENTS (script_engines);
656 }
657
658 PangoEngine *
659 PANGO_MODULE_ENTRY(create) (const char *id)
660 {
661   return (!strcmp (id, SCRIPT_ENGINE_NAME)
662           ? g_object_new (m17n_engine_fc_type, NULL)
663           : NULL);
664 }