From 7bb795f19ad2e3ddabf94d488f97362cff15725f Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 12 Nov 2007 12:31:19 +0000 Subject: [PATCH] (Mcombining): New variable. (Mfont_facility): Renamed from Mfont_has. Referrer changed. (enum FontLayoutCmdRuleSrcType): Delete SRC_EXIST, add SRC_HAS_GLYPH and SRC_OTF_SPEC. (FontLayoutCmdRule): Delete src.exist, add src.supported_glyph and src.otf_spec. (load_command): Adjusted for the above changes. (run_rule): Likewise. (combining_code_from_class): Delete it. (mflt_get): Check flt->name against Mcombining, not Mt. --- src/m17n-flt.c | 124 ++++++++++++++++++++++---------------------------------- 1 file changed, 49 insertions(+), 75 deletions(-) diff --git a/src/m17n-flt.c b/src/m17n-flt.c index 50372da..b72dfac 100644 --- a/src/m17n-flt.c +++ b/src/m17n-flt.c @@ -25,10 +25,7 @@ @brief FLT support for a window system. This section defines the m17n FLT API concerning character - layouting facility using FLT (Font Layout Table). FLT - - -*/ + layouting facility using FLT (Font Layout Table). */ /*=*/ @@ -240,7 +237,7 @@ MACRO-NAME ::= SYMBOL static int mdebug_flag = MDEBUG_FONT_FLT; -MSymbol Mfont, Mlayouter; +MSymbol Mfont, Mlayouter, Mcombining; static MSymbol Mgenerator, Mend; @@ -361,7 +358,7 @@ GREPLACE (MFLTGlyphString *src, int src_from, int src_to, #define CMD_ID_TO_INDEX(id) (CMD_ID_OFFSET_INDEX - (id)) #define INDEX_TO_CMD_ID(idx) (CMD_ID_OFFSET_INDEX - (idx)) -static MSymbol Mcond, Mrange, Mfont_has; +static MSymbol Mcond, Mrange, Mfont_facility; #define GLYPH_CODE_P(code) \ ((code) >= GLYPH_CODE_MIN && (code) <= GLYPH_CODE_MAX) @@ -385,7 +382,8 @@ enum FontLayoutCmdRuleSrcType SRC_INDEX, SRC_SEQ, SRC_RANGE, - SRC_EXIST + SRC_HAS_GLYPH, + SRC_OTF_SPEC }; typedef struct @@ -404,9 +402,8 @@ typedef struct struct { int from, to; } range; - struct { - int c; - } exist; + int supported_glyph; + MFLTOtfSpec otf_spec; } src; int n_cmds; @@ -814,7 +811,8 @@ load_command (FontLayoutStage *stage, MPlist *plist, /* PLIST ::= ( cond ... ) | ( STRING ... ) | ( INTEGER ... ) | ( ( INTEGER INTEGER ) ... ) | ( ( range INTEGER INTEGER ) ... ) - | ( ( exist INTEGER ) ... ) */ + | ( ( font-facilty [ INTEGER ] ) ... ) + | ( ( font-facilty OTF-SPEC ) ... ) */ MPlist *elt = MPLIST_PLIST (plist); int len = MPLIST_LENGTH (elt) - 1; FontLayoutCmd *cmd; @@ -955,17 +953,29 @@ load_command (FontLayoutStage *stage, MPlist *plist, } else if (MPLIST_SYMBOL_P (pl) && size <= 2) { - if (MPLIST_SYMBOL (pl) != Mfont_has) + if (MPLIST_SYMBOL (pl) != Mfont_facility) MERROR (MERROR_FLT, INVALID_CMD_ID); - cmd->body.rule.src_type = SRC_EXIST; - if (size == 1) - cmd->body.rule.src.exist.c = -1; + pl = MPLIST_NEXT (pl); + if (MPLIST_SYMBOL_P (pl)) + { + MSymbol sym = MPLIST_SYMBOL (pl); + char *otf_spec = MSYMBOL_NAME (sym); + + if (otf_spec[0] == ':' && otf_spec[1] == 'o' + && otf_spec[2] == 't' && otf_spec[3] == 'f') + parse_otf_command (sym, &cmd->body.rule.src.otf_spec); + else + MERROR (MERROR_FLT, INVALID_CMD_ID); + cmd->body.rule.src_type = SRC_OTF_SPEC; + } else { - pl = MPLIST_NEXT (pl); - if (! MPLIST_INTEGER_P (pl)) - MERROR (MERROR_DRAW, INVALID_CMD_ID); - cmd->body.rule.src.exist.c = MPLIST_INTEGER (pl); + cmd->body.rule.src_type = SRC_HAS_GLYPH; + if (MPLIST_INTEGER_P (pl)) + cmd->body.rule.src.supported_glyph + = MPLIST_INTEGER (pl); + else + cmd->body.rule.src.supported_glyph = -1; } } else @@ -1479,12 +1489,12 @@ run_rule (int depth, if (MDEBUG_FLAG () > 2) MDEBUG_PRINT3 ("\n [FLT] %*s(INDEX %d", depth, "", rule->src.match_idx); } - else if (rule->src_type == SRC_EXIST) + else if (rule->src_type == SRC_HAS_GLYPH) { int encoded; unsigned code; - if (rule->src.exist.c < 0) + if (rule->src.supported_glyph < 0) { if (from >= to) return 0; @@ -1494,7 +1504,7 @@ run_rule (int depth, } else { - code = rule->src.exist.c; + code = rule->src.supported_glyph; to = from; encoded = 0; } @@ -1515,6 +1525,19 @@ run_rule (int depth, return 0; } } + else if (rule->src_type == SRC_OTF_SPEC) + { + MFLTOtfSpec *spec = &rule->src.otf_spec; + + if (! ctx->font->check_otf) + { + if ((spec->features[0] && spec->features[0][0] != 0xFFFFFFFF) + || (spec->features[1] && spec->features[1][0] != 0xFFFFFFFF)) + return 0; + } + else if (! ctx->font->check_otf (ctx->font, spec)) + return 0; + } consumed = 0; depth++; @@ -2092,56 +2115,6 @@ run_stages (MFLTGlyphString *gstring, int from, int to, return to; } -static int -combining_code_from_class (int class) -{ - int code; - - if (class < 200) - code = MAKE_COMBINING_CODE (3, 1, 3, 1, 128, 128); - else if (class == 200) /* below left attached */ - code = MAKE_COMBINING_CODE (2, 0, 0, 1, 128, 128); - else if (class == 202) /* below attached*/ - code = MAKE_COMBINING_CODE (2, 1, 0, 1, 128, 128); - else if (class == 204) /* below right attached */ - code = MAKE_COMBINING_CODE (2, 2, 0, 1, 128, 128); - else if (class == 208) /* left attached */ - code = MAKE_COMBINING_CODE (3, 0, 3, 2, 128, 128); - else if (class == 210) /* right attached */ - code = MAKE_COMBINING_CODE (3, 2, 3, 0, 128, 128); - else if (class == 212) /* above left attached */ - code = MAKE_COMBINING_CODE (0, 0, 2, 1, 128, 128); - else if (class == 214) /* above attached */ - code = MAKE_COMBINING_CODE (0, 1, 2, 1, 128, 128); - else if (class == 216) /* above right attached */ - code = MAKE_COMBINING_CODE (0, 2, 2, 1, 128, 128); - else if (class == 218) /* below left */ - code = MAKE_COMBINING_CODE (2, 0, 0, 1, 122, 128); - else if (class == 220) /* below */ - code = MAKE_COMBINING_CODE (2, 1, 0, 1, 122, 128); - else if (class == 222) /* below right */ - code = MAKE_COMBINING_CODE (2, 2, 0, 1, 122, 128); - else if (class == 224) /* left */ - code = MAKE_COMBINING_CODE (3, 0, 3, 2, 128, 122); - else if (class == 226) /* right */ - code = MAKE_COMBINING_CODE (3, 2, 3, 0, 128, 133); - else if (class == 228) /* above left */ - code = MAKE_COMBINING_CODE (0, 0, 2, 1, 133, 128); - else if (class == 230) /* above */ - code = MAKE_COMBINING_CODE (0, 1, 2, 1, 133, 128); - else if (class == 232) /* above right */ - code = MAKE_COMBINING_CODE (0, 2, 2, 1, 133, 128); - else if (class == 233) /* double below */ - code = MAKE_COMBINING_CODE (2, 2, 0, 2, 122, 128); - else if (class == 234) /* double above */ - code = MAKE_COMBINING_CODE (0, 2, 2, 2, 133, 128); - else if (class == 240) /* iota subscript */ - code = MAKE_COMBINING_CODE (2, 1, 0, 1, 122, 128); - else /* unknown */ - code = MAKE_COMBINING_CODE (3, 1, 3, 1, 128, 128); - return code; -} - static void setup_combining_coverage (int from, int to, void *val, void *arg) { @@ -2216,7 +2189,8 @@ m17n_init_flt (void) Mrange = msymbol ("range"); Mfont = msymbol ("font"); Mlayouter = msymbol ("layouter"); - Mfont_has = msymbol ("font-has"); + Mcombining = msymbol ("combining"); + Mfont_facility = msymbol ("font-facility"); Mgenerator = msymbol ("generator"); Mend = msymbol ("end"); @@ -2267,7 +2241,7 @@ mflt_get (MSymbol name) flt = mplist_get (flt_list, name); if (! flt || ! CHECK_FLT_STAGES (flt)) return NULL; - if (flt->name == Mt + if (flt->name == Mcombining && ! mchartable_lookup (flt->coverage, 0)) setup_combining_flt (flt); @@ -2325,7 +2299,7 @@ mflt_find (int c, MFLTFont *font) || (spec->features[1] && spec->features[1][0] != 0xFFFFFFFF)) continue; } - else if (! font->check_otf (font, &flt->otf)) + else if (! font->check_otf (font, spec)) continue; return flt; } -- 1.7.10.4