-#define REPLACEMENT_CHARACTER 0xFFFD
-
-/* Drive FONT's OTF GSUB features according to GSUB_SPEC. See the
- comment of (sturct font_driver).otf_gsub. */
-
-int
-font_otf_gsub (font, gsub_spec, gstring_in, from, to, gstring_out, idx,
- alternate_subst)
- struct font *font;
- Lisp_Object gsub_spec;
- Lisp_Object gstring_in;
- int from, to;
- Lisp_Object gstring_out;
- int idx, alternate_subst;
-{
- int len;
- int i;
- OTF *otf;
- OTF_GlyphString otf_gstring;
- OTF_Glyph *g;
- char *script, *langsys, features[256];
- int need_cmap;
-
- parse_gsub_gpos_spec (gsub_spec, &script, &langsys, features, 256);
-
- otf = otf_open (font->entity, font->file_name);
- if (! otf)
- return 0;
- if (OTF_get_table (otf, "head") < 0)
- return 0;
- if (OTF_get_table (otf, "cmap") < 0)
- return 0;
- if (OTF_check_table (otf, "GSUB") < 0)
- return 0;
- len = to - from;
- 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);
- for (i = 0, need_cmap = 0; i < len; i++)
- {
- Lisp_Object g = LGSTRING_GLYPH (gstring_in, from + i);
-
- otf_gstring.glyphs[i].c = XINT (LGLYPH_CHAR (g));
- if (otf_gstring.glyphs[i].c == REPLACEMENT_CHARACTER)
- otf_gstring.glyphs[i].c = 0;
- if (NILP (LGLYPH_CODE (g)))
- {
- otf_gstring.glyphs[i].glyph_id = 0;
- need_cmap = 1;
- }
- else
- otf_gstring.glyphs[i].glyph_id = XINT (LGLYPH_CODE (g));
- }
-
- if (need_cmap)
- OTF_drive_cmap (otf, &otf_gstring);
- OTF_drive_gdef (otf, &otf_gstring);
- if ((alternate_subst
- ? OTF_drive_gsub_alternate (otf, &otf_gstring, script, langsys, features)
- : OTF_drive_gsub (otf, &otf_gstring, script, langsys, features)) < 0)
- {
- free (otf_gstring.glyphs);
- return 0;
- }
- if (ASIZE (gstring_out) < idx + otf_gstring.used)
- {
- free (otf_gstring.glyphs);
- return -1;
- }
-
- for (i = 0, g = otf_gstring.glyphs; i < otf_gstring.used;)
- {
- int i0 = g->f.index.from, i1 = g->f.index.to;
- Lisp_Object glyph = LGSTRING_GLYPH (gstring_in, from + i0);
- Lisp_Object min_idx = AREF (glyph, 0);
- Lisp_Object max_idx = AREF (glyph, 1);
-
- if (i0 < i1)
- {
- int min_idx_i = XINT (min_idx), max_idx_i = XINT (max_idx);
-
- for (i0++; i0 <= i1; i0++)
- {
- glyph = LGSTRING_GLYPH (gstring_in, from + i0);
- if (min_idx_i > XINT (AREF (glyph, 0)))
- min_idx_i = XINT (AREF (glyph, 0));
- if (max_idx_i < XINT (AREF (glyph, 1)))
- max_idx_i = XINT (AREF (glyph, 1));
- }
- min_idx = make_number (min_idx_i);
- max_idx = make_number (max_idx_i);
- i0 = g->f.index.from;
- }
- for (; i < otf_gstring.used && g->f.index.from == i0; i++, g++)
- {
- glyph = LGSTRING_GLYPH (gstring_out, idx + i);
- ASET (glyph, 0, min_idx);
- ASET (glyph, 1, max_idx);
- if (g->c > 0)
- LGLYPH_SET_CHAR (glyph, make_number (g->c));
- else
- LGLYPH_SET_CHAR (glyph, make_number (REPLACEMENT_CHARACTER));
- LGLYPH_SET_CODE (glyph, make_number (g->glyph_id));
- }
- }
-
- free (otf_gstring.glyphs);
- return i;
+Lisp_Object
+font_otf_ValueRecord (value_format, value_record)
+ int value_format;
+ OTF_ValueRecord *value_record;
+{
+ Lisp_Object val = Fmake_vector (make_number (8), Qnil);
+
+ if (value_format & OTF_XPlacement)
+ ASET (val, 0, value_record->XPlacement);
+ if (value_format & OTF_YPlacement)
+ ASET (val, 1, value_record->YPlacement);
+ if (value_format & OTF_XAdvance)
+ ASET (val, 2, value_record->XAdvance);
+ if (value_format & OTF_YAdvance)
+ ASET (val, 3, value_record->YAdvance);
+ if (value_format & OTF_XPlaDevice)
+ ASET (val, 4, font_otf_DeviceTable (&value_record->XPlaDevice));
+ if (value_format & OTF_YPlaDevice)
+ ASET (val, 4, font_otf_DeviceTable (&value_record->YPlaDevice));
+ if (value_format & OTF_XAdvDevice)
+ ASET (val, 4, font_otf_DeviceTable (&value_record->XAdvDevice));
+ if (value_format & OTF_YAdvDevice)
+ ASET (val, 4, font_otf_DeviceTable (&value_record->YAdvDevice));
+ return val;