#elif defined (FLT_HB)
#include <m17n-flt.h>
-#include <harfbuzz.h>
+#include <hb.h>
#define PROGNAME "flt-hb"
#else /* (defined (FLT_PANGO)) */
#include <m17n-flt.h>
#define PANGO_ENABLE_ENGINE
#define PANGO_ENABLE_BACKEND
-#include <pango/pango.h>
+#include <pango/pangcairo.h>
#include <pango/pango-ot.h>
-#include <pango/pangoft2.h>
-#include <pango/pangofc-font.h>
+
#endif
+#include <m17n-misc.h>
+
static FT_Library ft_library;
int
*str = '\0';
}
+static OTF_GlyphString otf_gstring;
+
+static void
+setup_otf_gstring (int size)
+{
+ if (otf_gstring.size == 0)
+ {
+ otf_gstring.glyphs = (OTF_Glyph *) xmalloc (sizeof (OTF_Glyph) * size);
+ otf_gstring.size = size;
+ }
+ else if (otf_gstring.size < size)
+ {
+ otf_gstring.glyphs = xrealloc (otf_gstring.glyphs,
+ sizeof (OTF_Glyph) * size);
+ otf_gstring.size = size;
+ }
+ otf_gstring.used = size;
+ memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size);
+}
+
int
drive_otf (MFLTFont *font, MFLTOtfSpec *spec,
MFLTGlyphString *in, int from, int to,
MFLTGlyphString *out, MFLTGlyphAdjustment *adjustment)
{
- int len = to - from;
- int i, gidx;
OTF *otf = ((FontInfoOTF *) font)->otf;
- OTF_GlyphString otf_gstring;
+ int len = to - from;
+ int i, j, gidx;
OTF_Glyph *otfg;
- char script[4], langsys[4];
+ char script[5], *langsys = NULL;
char *gsub_features = NULL, *gpos_features = NULL;
if (len == 0)
return from;
- if (! otf)
- goto simple_copy;
- otf_gstring.glyphs = NULL;
- if (OTF_get_table (otf, "head") < 0)
- {
- OTF_close (otf);
- ((FontInfoOTF *) font)->otf = NULL;
- goto simple_copy;
- }
-
- tag_name (script, spec->script);
- tag_name (langsys, spec->langsys);
-
- if (spec->gsub_count > 0)
+ OTF_tag_name (spec->script, script);
+ if (spec->langsys)
{
- gsub_features = alloca (6 * spec->gsub_count);
- if (gsub_features)
- {
- if (OTF_check_table (otf, "GSUB") < 0)
- gsub_features = NULL;
- else
- encode_features (gsub_features, spec->gsub_count, spec->gsub);
- }
+ langsys = alloca (5);
+ OTF_tag_name (spec->langsys, langsys);
}
- if (spec->gpos_count)
+ for (i = 0; i < 2; i++)
{
- gpos_features = alloca (6 * spec->gpos_count);
- if (gpos_features)
+ char *p;
+
+ if (spec->features[i] && spec->features[i][1] != 0xFFFFFFFF)
{
- if (OTF_check_table (otf, "GPOS") < 0)
- gpos_features = NULL;
+ for (j = 0; spec->features[i][j]; j++);
+ if (i == 0)
+ p = gsub_features = alloca (6 * j);
else
- encode_features (gpos_features, spec->gpos_count, spec->gpos);
+ p = gpos_features = alloca (6 * j);
+ for (j = 0; spec->features[i][j]; j++)
+ {
+ if (spec->features[i][j] == 0xFFFFFFFF)
+ *p++ = '*', *p++ = ',';
+ else
+ {
+ OTF_tag_name (spec->features[i][j], p);
+ p[4] = ',';
+ p += 5;
+ }
+ }
+ *--p = '\0';
}
}
- otf_gstring.size = otf_gstring.used = len;
- otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len);
- memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len);
+ setup_otf_gstring (len);
for (i = 0; i < len; i++)
{
otf_gstring.glyphs[i].c = in->glyphs[from + i].c;
font_info = malloc (sizeof (FontInfoOTF));
font_info->face = face;
font_info->otf = OTF_open_ft_face (face);
+ if (OTF_get_table (font_info->otf, "head") < 0)
+ {
+ OTF_close (font_info->otf);
+ FT_Done_Face (font_info->face);
+ free (font_info);
+ return NULL;
+ }
return ((MFLTFont *) font_info);
}
MText *mt;
MFLTFont *font;
int len, i, j;
+ unsigned char *buf;
if (argc < 3)
{
font->get_metrics = get_metrics;
font->drive_otf = drive_otf;
- mt = mconv_decode_stream (msymbol ("utf-8"), stdin);
+ i = 0;
+ buf = malloc (4096);
+ while ((j = fread (buf + i, 1, 4096, stdin)) == 4096)
+ {
+ i += 4096;
+ buf = realloc (buf, i + 4096);
+ }
+ mt = mtext_from_data (buf, i, MTEXT_FORMAT_UTF_8);
len = mtext_len (mt);
for (i = 0, j = mtext_character (mt, i, len, '\n'); i < len;
i = j + 1, j = mtext_character (mt, i, len, '\n'))
i = j;
}
m17n_object_unref (mt);
+ free (buf);
close_font (font);
M17N_FINI ();
return 0;