5 #include FT_TRUETYPE_TABLES_H
6 #include <fontconfig/fontconfig.h>
7 #include <fontconfig/fcfreetype.h>
12 #define PROGNAME "flt-gui"
14 #elif defined (FLT_OTF)
18 #define PROGNAME "flt-otf"
20 #else /* defined (FLT_HB) */
24 #define PROGNAME "flt-hb"
28 static FT_Library ft_library;
31 new_face (char *fontname, char **err)
40 pat = FcNameParse ((FcChar8 *) fontname);
43 *err = "invalid name format";
46 if (FcPatternGetString (pat, FC_FAMILY, 0, &fam) != FcResultMatch)
48 *err = "no family name";
51 if (FcPatternGetDouble (pat, FC_PIXEL_SIZE, 0, &pixelsize) != FcResultMatch)
53 FcPatternAddBool (pat, FC_SCALABLE, FcTrue);
54 FcPatternDel (pat, FC_PIXEL_SIZE);
55 os = FcObjectSetBuild (FC_FILE, NULL);
56 fs = FcFontList (NULL, pat, os);
59 *err = "no matching font";
62 FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file);
64 if (FT_New_Face (ft_library, (char *) file, 0, &face))
66 FcFontSetDestroy (fs);
67 FcObjectSetDestroy (os);
68 FcPatternDestroy (pat);
69 *err = "font open fail";
72 FcFontSetDestroy (fs);
73 FcObjectSetDestroy (os);
74 FcPatternDestroy (pat);
75 if (FT_Set_Pixel_Sizes (face, pixelsize, pixelsize))
77 *err = "set pixelsize fail";
95 open_font (char *fontname, char **err)
97 FT_Face ft_face = new_face (fontname, err);
107 fontset = mfontset ("generic");
108 mface_put_prop (face, Mfontset, fontset);
109 mplist_add (plist, Mface, face);
110 mplist_add (plist, Mdevice, Mnil);
111 frame = mframe (plist);
112 m17n_object_unref (plist);
113 m17n_object_unref (face);
114 m17n_object_unref (fontset);
116 font = calloc (1, sizeof (MFLTFont));
117 font->font = mfont_encapsulate (frame, Mfreetype, ft_face);
118 font->face = ft_face;
123 close_font (MFLTFont *font)
125 FT_Done_Face (font->face);
127 m17n_object_unref (frame);
131 flt (MText *mt, int from, int to, MFLTFont *font, char *flt_name)
133 MDrawControl control;
135 memset (&control, 0, sizeof (MDrawControl));
136 control.two_dimensional = 1;
137 control.enable_bidi = 1;
138 control.anti_alias = 1;
139 /*control.disable_caching = 1;*/
140 mtext_put_prop (mt, from, to, Mfont, font->font);
141 mdraw_text_extents (frame, mt, from, to, &control, NULL, NULL, NULL);
145 #else /* FLT_OTF or FLT_HB */
153 get_glyph_id (MFLTFont *font, MFLTGlyph *g)
155 FT_Face face = ((FontInfo *) font)->face;
157 g->code = FT_Get_Char_Index (face, g->code);
159 return (g->code ? 0 : -1);
163 get_metric (MFLTFont *font, MFLTGlyphString *gstring, int from, int to)
165 FT_Face face = ((FontInfo *) font)->face;
167 for (; from < to; from++)
169 MFLTGlyph *g = gstring->glyphs + from;
170 FT_Glyph_Metrics *metrics;
172 if (FT_Load_Glyph (face, g->code, FT_LOAD_DEFAULT))
174 metrics = &face->glyph->metrics;
175 g->lbearing = metrics->horiBearingX;
176 g->rbearing = metrics->horiBearingX + metrics->width;
177 g->xadv = metrics->horiAdvance;
178 g->yadv = metrics->vertAdvance;
179 g->ascent = metrics->horiBearingY;
180 g->descent = metrics->height - metrics->horiBearingY;
186 flt (MText *mt, int from, int to, MFLTFont *font, char *flt_name)
188 MFLTGlyphString gstring;
192 memset (&gstring, 0, sizeof (MFLTGlyphString));
193 gstring.glyph_size = sizeof (MFLTGlyph);
194 gstring.allocated = len * 2;
195 gstring.glyphs = alloca (sizeof (MFLTGlyph) * gstring.allocated);
196 for (i = 0; i < len; i++)
197 gstring.glyphs[i].c = mtext_ref_char (mt, from + i);
199 return mflt_run (&gstring, 0, len, font, msymbol (flt_name));
210 #define DEVICE_DELTA(table, size) \
211 (((size) >= (table).StartSize && (size) <= (table).EndSize) \
212 ? ((table).DeltaValue[(size) - (table).StartSize] << 6) \
216 adjust_anchor (OTF_Anchor *anchor, FT_Face face,
217 unsigned code, unsigned x_ppem, unsigned y_ppem, int *x, int *y)
219 if (anchor->AnchorFormat == 2)
222 int ap = anchor->f.f1.AnchorPoint;
224 FT_Load_Glyph (face, (FT_UInt) code, FT_LOAD_MONOCHROME);
225 outline = &face->glyph->outline;
226 if (ap < outline->n_points)
228 *x = outline->points[ap].x;
229 *y = outline->points[ap].y;
232 else if (anchor->AnchorFormat == 3)
234 if (anchor->f.f2.XDeviceTable.offset)
235 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, x_ppem);
236 if (anchor->f.f2.YDeviceTable.offset)
237 *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, y_ppem);
242 tag_name (char *str, unsigned tag)
245 *str++ = (tag >> 16) & 0xFF;
246 *str++ = (tag >> 8) & 0xFF;
252 encode_features (char *str, int count, unsigned *features)
257 for (i = 0; i < count; i++)
259 unsigned tag = features[i];
269 str = tag_name (str, tag);
282 drive_otf (MFLTFont *font, MFLTOtfSpec *spec,
283 MFLTGlyphString *in, int from, int to,
284 MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment)
288 OTF *otf = ((FontInfoOTF *) font)->otf;
289 OTF_GlyphString otf_gstring;
291 char script[4], langsys[4];
292 char *gsub_features = NULL, *gpos_features = NULL;
299 otf_gstring.glyphs = NULL;
300 if (OTF_get_table (otf, "head") < 0)
303 ((FontInfoOTF *) font)->otf = NULL;
307 tag_name (script, spec->script);
308 tag_name (langsys, spec->langsys);
310 if (spec->gsub_count > 0)
312 gsub_features = alloca (6 * spec->gsub_count);
315 if (OTF_check_table (otf, "GSUB") < 0)
316 gsub_features = NULL;
318 encode_features (gsub_features, spec->gsub_count, spec->gsub);
321 if (spec->gpos_count)
323 gpos_features = alloca (6 * spec->gpos_count);
326 if (OTF_check_table (otf, "GPOS") < 0)
327 gpos_features = NULL;
329 encode_features (gpos_features, spec->gpos_count, spec->gpos);
333 otf_gstring.size = otf_gstring.used = len;
334 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len);
335 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len);
336 for (i = 0; i < len; i++)
338 otf_gstring.glyphs[i].c = in->glyphs[from + i].c;
339 otf_gstring.glyphs[i].glyph_id = in->glyphs[from + i].code;
342 OTF_drive_gdef (otf, &otf_gstring);
347 if (OTF_drive_gsub (otf, &otf_gstring, script, langsys, gsub_features)
350 if (out->allocated < out->used + otf_gstring.used)
352 for (i = 0, otfg = otf_gstring.glyphs; i < otf_gstring.used; i++, otfg++)
354 MFLTGlyph *g = out->glyphs + out->used;
357 *g = in->glyphs[from + otfg->f.index.from];
359 for (j = from + otfg->f.index.from; j <= from + otfg->f.index.to; j++)
360 if (in->glyphs[j].code == otfg->glyph_id)
362 g->c = in->glyphs[j].c;
365 g->code = otfg->glyph_id;
371 if (out->allocated < out->used + len)
373 for (i = 0; i < len; i++)
374 out->glyphs[out->used++] = in->glyphs[from + i];
377 font->get_metric (font, out, gidx, out->used);
382 MFLTGlyph *base = NULL, *mark = NULL, *g;
383 int x_ppem, y_ppem, x_scale, y_scale;
385 if (OTF_drive_gpos (otf, &otf_gstring, script, langsys, gpos_features)
389 face = ((FontInfo *) font)->face;
390 x_ppem = face->size->metrics.x_ppem;
391 y_ppem = face->size->metrics.y_ppem;
392 x_scale = face->size->metrics.x_scale;
393 y_scale = face->size->metrics.y_scale;
395 for (i = 0, otfg = otf_gstring.glyphs, g = out->glyphs + gidx;
396 i < otf_gstring.used; i++, otfg++, g++)
400 if (! otfg->glyph_id)
402 switch (otfg->positioning_type)
408 int format = otfg->f.f1.format;
410 if (format & OTF_XPlacement)
412 = otfg->f.f1.value->XPlacement * x_scale / 0x10000;
413 if (format & OTF_XPlaDevice)
415 += DEVICE_DELTA (otfg->f.f1.value->XPlaDevice, x_ppem);
416 if (format & OTF_YPlacement)
418 = - (otfg->f.f1.value->YPlacement * y_scale / 0x10000);
419 if (format & OTF_YPlaDevice)
421 -= DEVICE_DELTA (otfg->f.f1.value->YPlaDevice, y_ppem);
422 if (format & OTF_XAdvance)
424 += otfg->f.f1.value->XAdvance * x_scale / 0x10000;
425 if (format & OTF_XAdvDevice)
427 += DEVICE_DELTA (otfg->f.f1.value->XAdvDevice, x_ppem);
428 if (format & OTF_YAdvance)
430 += otfg->f.f1.value->YAdvance * y_scale / 0x10000;
431 if (format & OTF_YAdvDevice)
433 += DEVICE_DELTA (otfg->f.f1.value->YAdvDevice, y_ppem);
434 adjustment[i].set = 1;
438 /* Not yet supported. */
444 goto label_adjust_anchor;
445 default: /* i.e. case 6 */
452 int base_x, base_y, mark_x, mark_y;
454 base_x = otfg->f.f4.base_anchor->XCoordinate * x_scale / 0x10000;
455 base_y = otfg->f.f4.base_anchor->YCoordinate * y_scale / 0x10000;
456 mark_x = otfg->f.f4.mark_anchor->XCoordinate * x_scale / 0x10000;
457 mark_y = otfg->f.f4.mark_anchor->YCoordinate * y_scale / 0x10000;;
459 if (otfg->f.f4.base_anchor->AnchorFormat != 1)
460 adjust_anchor (otfg->f.f4.base_anchor, face, prev->code,
461 x_ppem, y_ppem, &base_x, &base_y);
462 if (otfg->f.f4.mark_anchor->AnchorFormat != 1)
463 adjust_anchor (otfg->f.f4.mark_anchor, face, g->code,
464 x_ppem, y_ppem, &mark_x, &mark_y);
465 adjustment[i].xoff = (base_x - mark_x);
466 adjustment[i].yoff = - (base_y - mark_y);
467 adjustment[i].back = (g - prev);
468 adjustment[i].set = 1;
471 if (otfg->GlyphClass == OTF_GlyphClass0)
473 else if (otfg->GlyphClass == OTF_GlyphClassMark)
479 free (otf_gstring.glyphs);
483 font->get_metric (font, in, from, to);
484 for (i = 0; i < len; i++)
486 MFLTGlyph *g = in->glyphs + (from + i);
488 out->glyphs[out->used++] = *g;
490 if (otf_gstring.glyphs)
491 free (otf_gstring.glyphs);
496 open_font (char *fontname, char **err)
498 FT_Face face = new_face (fontname, err);
499 FontInfoOTF *font_info;
503 font_info = malloc (sizeof (FontInfoOTF));
504 font_info->font.get_glyph_id = get_glyph_id;
505 font_info->font.get_metric = get_metric;
506 font_info->font.drive_otf = drive_otf;
507 font_info->face = face;
508 font_info->otf = OTF_open_ft_face (face);
509 return ((MFLTFont *) font_info);
513 close_font (MFLTFont *font)
515 FontInfoOTF *font_info = (FontInfoOTF *) font;
517 OTF_close (font_info->otf);
518 FT_Done_Face (font_info->face);
538 HB_StreamRec gdef_stream;
542 MPlist *otf_spec_cache;
546 convertStringToGlyphIndices (HB_Font font, const HB_UChar16 *string,
547 hb_uint32 length, HB_Glyph *glyphs,
548 hb_uint32 *numGlyphs, HB_Bool rightToLeft)
554 getGlyphAdvances (HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs,
555 HB_Fixed *advances, int flags /*HB_ShaperFlag*/)
559 for (i = 0; i < numGlyphs; i++)
564 canRender (HB_Font font, const HB_UChar16 *string, hb_uint32 length)
570 getPointInOutline (HB_Font font, HB_Glyph glyph, int flags /*HB_ShaperFlag*/,
571 hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos,
574 FT_Face face = font->faceData;
577 if ((error = (HB_Error) FT_Load_Glyph (face, glyph, flags)))
579 if (face->glyph->format != ft_glyph_format_outline)
580 return (HB_Error) HB_Err_Invalid_GPOS_SubTable;
581 *nPoints = face->glyph->outline.n_points;
584 if (point > *nPoints)
585 return (HB_Error) HB_Err_Invalid_GPOS_SubTable;
587 *xpos = face->glyph->outline.points[point].x;
588 *ypos = face->glyph->outline.points[point].y;
594 getGlyphMetrics (HB_Font font, HB_Glyph glyph, HB_GlyphMetrics *metrics)
599 getFontMetric (HB_Font font, HB_FontMetric metric)
604 #define MAKE_TAG(name) ((((FT_ULong) (name)[0]) << 24) \
605 | (((FT_ULong) (name)[1]) << 16) \
606 | (((FT_ULong) (name)[2]) << 8) \
610 new_stream (FT_Face face, char *tagname, HB_Stream stream)
612 FT_ULong tag = MAKE_TAG (tagname);
616 if (! FT_IS_SFNT (face))
617 return HB_Err_Invalid_Argument;
619 if (FT_Load_Sfnt_Table (face, tag, 0, NULL, &len))
620 return HB_Err_Table_Missing;
623 return HB_Err_Out_Of_Memory;
624 if (FT_Load_Sfnt_Table (face, tag, 0, buf, &len))
627 return HB_Err_Table_Missing;
629 stream->base = (HB_Byte *) buf;
632 stream->cursor = NULL;
638 load_gdef (FontInfoHB *font_info)
642 if (! font_info->gdef_stream.base)
644 err = new_stream ((FT_Face) font_info->hb_font.faceData, "GDEF",
645 &font_info->gdef_stream);
646 if (err != HB_Err_Ok)
649 return HB_Load_GDEF_Table (&font_info->gdef_stream, &font_info->gdef);
653 load_gsub (FontInfoHB *font_info)
657 HB_LookupList *lookup_list;
660 if (! font_info->gdef)
662 if ((err = load_gdef (font_info)) != HB_Err_Ok)
665 err = new_stream ((FT_Face) font_info->hb_font.faceData, "GSUB", &stream);
666 if (err != HB_Err_Ok)
668 err = HB_Load_GSUB_Table (&stream, &font_info->gsub,
669 font_info->gdef, &font_info->gdef_stream);
671 lookup_list = &font_info->gsub->LookupList;
672 for (i = 0; i < lookup_list->LookupCount; i++)
673 lookup_list->Properties[i] = HB_GLYPH_PROPERTIES_UNKNOWN;
678 load_gpos (FontInfoHB *font_info)
682 HB_LookupList *lookup_list;
685 if (! font_info->gdef)
687 if ((err = load_gdef (font_info)) != HB_Err_Ok)
690 err = new_stream ((FT_Face) font_info->hb_font.faceData, "GPOS", &stream);
691 if (err != HB_Err_Ok)
693 err = HB_Load_GPOS_Table (&stream, &font_info->gpos,
694 font_info->gdef, &font_info->gdef_stream);
696 lookup_list = &font_info->gpos->LookupList;
697 for (i = 0; i < lookup_list->LookupCount; i++)
698 lookup_list->Properties[i] = HB_GLYPH_PROPERTIES_UNKNOWN;
702 const HB_FontClass hb_fontClass = {
703 convertStringToGlyphIndices, getGlyphAdvances, canRender,
704 getPointInOutline, getGlyphMetrics, getFontMetric
708 setup_features (int gsubp, FontInfoHB *font_info, MFLTOtfSpec *spec,
711 int count, preordered;
712 unsigned int *features;
713 FT_UShort script, langsys;
714 FT_UShort req_feature, index;
715 FT_UInt *feature_list;
721 if (! font_info->gsub)
723 if (load_gsub (font_info) != HB_Err_Ok)
726 if (HB_GSUB_Select_Script (font_info->gsub, spec->script, &script)
731 if (HB_GSUB_Select_Language (font_info->gsub, spec->langsys,
732 script, &langsys, &req_feature)
737 langsys = req_feature = 0xFFFF;
738 count = spec->gsub_count;
739 features = spec->gsub;
743 if (! font_info->gpos)
745 if (load_gpos (font_info) != HB_Err_Ok)
748 if (HB_GPOS_Select_Script (font_info->gpos, spec->script, &script)
753 if (HB_GPOS_Select_Language (font_info->gpos, spec->langsys,
754 script, &langsys, &req_feature)
759 langsys = req_feature = 0xFFFF;
760 count = spec->gpos_count;
761 features = spec->gpos;
764 for (preordered = 0; preordered < count; preordered++)
765 if (features[preordered] == 0)
767 if ((gsubp ? HB_GSUB_Query_Features (font_info->gsub, script, langsys,
769 : HB_GPOS_Query_Features (font_info->gpos, script, langsys,
776 for (i = 0; feature_list[i]; i++);
779 info->indices = malloc (sizeof (FT_UShort) * ((req_feature != 0xFFFF) + i));
781 if (req_feature != 0xFFFF)
782 info->indices[i++] = req_feature;
783 for (j = 0; j < preordered; j++)
784 if ((gsubp ? HB_GSUB_Select_Feature (font_info->gsub, features[j],
785 script, langsys, &index)
786 : HB_GPOS_Select_Feature (font_info->gpos, features[j],
787 script, langsys, &index))
789 info->indices[i++] = index;
791 for (j = 0; feature_list[j]; j++)
793 for (k = preordered + 1; k < count; k++)
794 if (feature_list[j] == features[k])
798 ? HB_GSUB_Select_Feature (font_info->gsub, feature_list[j],
799 script, langsys, &index)
800 : HB_GPOS_Select_Feature (font_info->gpos, feature_list[j],
801 script, langsys, &index))
803 info->indices[i++] = index;
809 setup_otf_spec (MFLTFont *font, MFLTOtfSpec *spec)
811 FontInfoHB *font_info = (FontInfoHB *) font;
814 if (spec->gsub_count + spec->gpos_count == 0)
816 ginfo = mplist_get (font_info->otf_spec_cache, spec->sym);
818 return (ginfo->gsub.count + ginfo->gpos.count > 0 ? ginfo : NULL);
819 ginfo = calloc (1, sizeof (GsubGposInfo));
820 mplist_push (font_info->otf_spec_cache, spec->sym, ginfo);
821 setup_features (1, font_info, spec, &(ginfo->gsub));
822 setup_features (0, font_info, spec, &(ginfo->gpos));
827 drive_otf (MFLTFont *font, MFLTOtfSpec *spec,
828 MFLTGlyphString *in, int from, int to,
829 MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment)
831 FontInfoHB *font_info = (FontInfoHB *) font;
836 HB_UShort *apply_order_save;
837 HB_UShort apply_count_save;
838 int gpos_applied = 0;
845 if (hb_buffer_new (&buf) != FT_Err_Ok)
847 for (i = from; i < to; i++)
849 if (hb_buffer_add_glyph (buf, in->glyphs[i].code, 0, i) != FT_Err_Ok)
852 ginfo = setup_otf_spec (font, spec);
855 if (ginfo->gsub.count > 0)
857 if (! font_info->gdef
858 && load_gdef (font_info) != HB_Err_Ok)
860 apply_order_save = font_info->gsub->FeatureList.ApplyOrder;
861 apply_count_save = font_info->gsub->FeatureList.ApplyCount;
862 font_info->gsub->FeatureList.ApplyOrder = ginfo->gsub.indices;
863 font_info->gsub->FeatureList.ApplyCount = ginfo->gsub.count;
864 err = HB_GSUB_Apply_String (font_info->gsub, buf);
865 font_info->gsub->FeatureList.ApplyOrder = apply_order_save;
866 font_info->gsub->FeatureList.ApplyCount = apply_count_save;
867 if (err != HB_Err_Ok && err != HB_Err_Not_Covered)
869 if (out->used + buf->in_length > out->allocated)
873 if (ginfo->gpos.count > 0
874 && (font_info->gpos || load_gpos (font_info) == HB_Err_Ok))
876 apply_order_save = font_info->gpos->FeatureList.ApplyOrder;
877 apply_count_save = font_info->gpos->FeatureList.ApplyCount;
878 font_info->gpos->FeatureList.ApplyOrder = ginfo->gpos.indices;
879 font_info->gpos->FeatureList.ApplyCount = ginfo->gpos.count;
880 err = HB_GPOS_Apply_String (&font_info->hb_font, font_info->gpos,
881 FT_LOAD_DEFAULT, buf, FALSE, FALSE);
882 font_info->gpos->FeatureList.ApplyOrder = apply_order_save;
883 font_info->gpos->FeatureList.ApplyCount = apply_count_save;
884 if (err == HB_Err_Ok)
890 for (i = 0; i < buf->in_length; i++)
892 HB_GlyphItem hg = buf->in_string + i;
893 HB_Position pos = buf->positions + i;
896 out->glyphs[out->used] = in->glyphs[hg->cluster];
897 g = out->glyphs + out->used++;
898 if (g->code != hg->gindex)
899 g->c = 0, g->code = hg->gindex;
900 adjustment[i].set = gpos_applied;
903 adjustment[i].xadv = pos->x_advance;
904 adjustment[i].yadv = pos->y_advance;
905 adjustment[i].xoff = pos->x_pos;
906 adjustment[i].yoff = - pos->y_pos;
907 adjustment[i].back = pos->back;
908 adjustment[i].advance_is_absolute = pos->new_advance;
915 hb_buffer_free (buf);
916 for (i = 0; i < len; i++)
917 out->glyphs[out->used++] = in->glyphs[from + i];
922 open_font (char *fontname, char **err)
924 FT_Face face = new_face (fontname, err);
925 FontInfoHB *font_info;
929 font_info = calloc (1, sizeof (FontInfoHB));
930 font_info->font.get_glyph_id = get_glyph_id;
931 font_info->font.get_metric = get_metric;
932 font_info->font.drive_otf = drive_otf;
933 font_info->face = face;
934 font_info->hb_font.klass = &hb_fontClass;
935 font_info->hb_font.faceData = face;
936 font_info->hb_font.userData = NULL;
937 font_info->hb_font.x_ppem = face->size->metrics.x_ppem;
938 font_info->hb_font.x_scale = face->size->metrics.x_scale;
939 font_info->hb_font.y_scale = face->size->metrics.y_scale;
940 font_info->hb_font.y_ppem = face->size->metrics.y_ppem;
941 font_info->otf_spec_cache = mplist ();
942 return ((MFLTFont *) font_info);
946 close_font (MFLTFont *font)
948 FontInfoHB *font_info = (FontInfoHB *) font;
953 HB_Done_GDEF_Table (font_info->gdef);
954 free (font_info->gdef_stream.base);
957 HB_Done_GSUB_Table (font_info->gsub);
959 HB_Done_GPOS_Table (font_info->gpos);
960 FT_Done_Face ((FT_Face) (font_info->hb_font.faceData));
961 for (p = font_info->otf_spec_cache; mplist_key (p) != Mnil;
964 GsubGposInfo *ginfo = mplist_value (p);
966 if (ginfo->gsub.count > 0)
967 free (ginfo->gsub.indices);
968 if (ginfo->gpos.count > 0)
969 free (ginfo->gpos.indices);
971 m17n_object_unref (font_info->otf_spec_cache);
979 main (int argc, char **argv)
981 char *font_name, *flt_name;
989 fprintf (stderr, "Usage: flt FONT-NAME FLT-NAME < TEXT-FILE\n");
996 FT_Init_FreeType (&ft_library);
998 font = open_font (font_name, &err);
1001 fprintf (stderr, "Font error: %s: %s\n", argv[1], err);
1005 mt = mconv_decode_stream (msymbol ("utf-8"), stdin);
1006 len = mtext_len (mt);
1007 for (i = 0, j = mtext_character (mt, i, len, '\n'); i < len;
1008 i = j + 1, j = mtext_character (mt, i, len, '\n'))
1012 if (flt (mt, i, j, font, flt_name) < 0)
1014 fprintf (stderr, "Error in FLT processing.\n");
1018 m17n_object_unref (mt);