#include "otf.h"
#include "otferror.h"
-/* Return nonzero if OTF_Glyph *G should be ignored according to
- LookupFlag FLAG. */
-#define IGNORED_GLYPH(g, flag) \
- ((g)->glyph_id == 0 \
- || ((flag) & (1 << (g)->GlyphClass)) \
- || (((flag) & OTF_MarkAttachmentType) \
- && (g)->GlyphClass == OTF_GlyphClassMark \
- && ((flag) >> 8) != (g)->MarkAttachClass))
+/* Return nonzero (-1 if ID is zero, 1 otherwise) if OTF_Glyph *G
+ should be ignored according to LookupFlag FLAG. */
+#define IGNORED_GLYPH(g, flag) \
+ ((g)->glyph_id == 0 ? -1 \
+ : (((flag) & (1 << (g)->GlyphClass)) \
+ || (((flag) & OTF_MarkAttachmentType) \
+ && (g)->GlyphClass == OTF_GlyphClassMark \
+ && ((flag) >> 8) != (g)->MarkAttachClass)))
#define GSTRING_DELETE(gstring, from, len) \
do { \
for (i = non_ignored_idx = to - 1; i >= from; i--)
{
OTF_Glyph *g = gstring->glyphs + i;
- if (IGNORED_GLYPH (g, flag))
+
+ if (IGNORED_GLYPH (g, flag) == 1)
{
+ /* Move this glyph to the next of the current target of
+ substitution. */
OTF_Glyph temp = *g;
memmove (g, g + 1, sizeof (OTF_Glyph) * (non_ignored_idx - i));
GSTRING_DELETE (gstring, from, (len - num));
for (i = 0; i < num; i++)
{
- gstring->glyphs[from + i].c = otf->cmap->decode_table[ids[i]];
+ if (gstring->glyphs[from + i].glyph_id != ids[i])
+ {
+ gstring->glyphs[from + i].c = 0;
+ if (otf->gdef)
+ gstring->glyphs[from + i].GlyphClass
+ = get_class_def (&otf->gdef->glyph_class_def, ids[i]);
+ else
+ gstring->glyphs[from + i].GlyphClass = 0;
+ }
gstring->glyphs[from + i].glyph_id = ids[i];
- if (otf->gdef)
- gstring->glyphs[from + i].GlyphClass
- = get_class_def (&otf->gdef->glyph_class_def, ids[i]);
- else
- gstring->glyphs[from + i].GlyphClass = 0;
gstring->glyphs[from + i].positioning_type = 0;
gstring->glyphs[from + i].f.index.from = from_idx;
gstring->glyphs[from + i].f.index.to = to_idx;
int i;
if (IGNORED_GLYPH (g, flag)
- || g->positioning_type)
+ || (0 & g->positioning_type))
return (gidx + 1);
/* Try all subtables until one of them handles the current glyph. */
OTF_Glyph *nextg;
for (next_gidx = gidx + 1, nextg = gstring->glyphs + next_gidx;
- next_gidx < gstring->used && ! IGNORED_GLYPH (nextg, flag);
+ next_gidx < gstring->used && IGNORED_GLYPH (nextg, flag);
next_gidx++, nextg++);
if (next_gidx >= gstring->used
OTF_AnchorRecord *base_record;
OTF_Glyph *baseg;
int coverage_idx_base;
+ unsigned int this_flag = flag | OTF_IgnoreMarks;
for (baseg = g - 1;
- baseg >= gstring->glyphs && IGNORED_GLYPH (baseg, flag);
+ baseg >= gstring->glyphs && IGNORED_GLYPH (baseg, this_flag);
baseg--);
if (baseg < gstring->glyphs)
continue;
OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
const char *script, const char *language, const char *features)
{
+ if (! otf->cmap)
+ OTF_get_table (otf, "cmap");
return OTF_drive_gsub_internal (otf, gstring, script, language, features, 0);
}