From: handa Date: Wed, 15 Aug 2007 11:42:58 +0000 (+0000) Subject: * font-flt.c: Include "internal-flt.h". Set mdebug_flag instead X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=f1b92af91adb28d30091441f7ab0529c66aac5a9;p=m17n%2Fm17n-lib.git * font-flt.c: Include "internal-flt.h". Set mdebug_flag instead of mdebug_mask. (run_rule): Print debug info only when MDEBUG_FLAG is greater than 2. (run_cond): Likewise. (run_otf): Likewise. (run_command): Likewise. (mfont__flt_run): Change format of debug info. * m17n-flt.c: New file created by modifying font-flt.c. --- diff --git a/src/font-flt.c b/src/font-flt.c index 4a11c0b..a0a71d0 100644 --- a/src/font-flt.c +++ b/src/font-flt.c @@ -35,6 +35,7 @@ #include "mtext.h" #include "symbol.h" #include "plist.h" +#include "internal-flt.h" #include "internal-gui.h" #include "font.h" #include "face.h" @@ -222,7 +223,7 @@ MACRO-NAME ::= SYMBOL */ -static int mdebug_mask = MDEBUG_FONT_FLT; +static int mdebug_flag = MDEBUG_FONT_FLT; MSymbol Mlayouter; @@ -993,8 +994,9 @@ run_rule (int depth, if (i < len) return 0; to = from + len; - MDEBUG_PRINT3 ("\n [FLT] %*s(SEQ 0x%X", depth, "", - rule->src.seq.codes[0]); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s(SEQ 0x%X", depth, "", + rule->src.seq.codes[0]); } else if (rule->src_type == SRC_RANGE) { @@ -1007,8 +1009,9 @@ run_rule (int depth, return 0; ctx->code_offset = head - rule->src.range.from; to = from + 1; - MDEBUG_PRINT4 ("\n [FLT] %*s(RANGE 0x%X-0x%X", depth, "", - rule->src.range.from, rule->src.range.to); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT4 ("\n [FLT] %*s(RANGE 0x%X-0x%X", depth, "", + rule->src.range.from, rule->src.range.to); } else if (rule->src_type == SRC_REGEX) { @@ -1025,10 +1028,11 @@ run_rule (int depth, NMATCH, pmatch, 0); if (result == 0 && pmatch[0].rm_so == 0) { - MDEBUG_PRINT5 ("\n [FLT] %*s(REGEX \"%s\" \"%s\" %d", depth, "", - rule->src.re.pattern, - ctx->encoded + from - ctx->encoded_offset, - pmatch[0].rm_eo); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT5 ("\n [FLT] %*s(REGEX \"%s\" \"%s\" %d", depth, "", + rule->src.re.pattern, + ctx->encoded + from - ctx->encoded_offset, + pmatch[0].rm_eo); ctx->encoded[to - ctx->encoded_offset] = saved_code; for (i = 0; i < NMATCH; i++) { @@ -1057,7 +1061,8 @@ run_rule (int depth, if (from < 0) return 0; to = ctx->match_indices[rule->src.match_idx * 2 + 1]; - MDEBUG_PRINT3 ("\n [FLT] %*s(INDEX %d", depth, "", rule->src.match_idx); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s(INDEX %d", depth, "", rule->src.match_idx); } consumed = 0; @@ -1081,7 +1086,8 @@ run_rule (int depth, } ctx->match_indices = saved_match_indices; - MDEBUG_PRINT (")"); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT (")"); return (rule->src_type == SRC_INDEX ? orig_from : to); } @@ -1092,7 +1098,8 @@ run_cond (int depth, { int i, pos = 0; - MDEBUG_PRINT2 ("\n [FLT] %*s(COND", depth, ""); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT2 ("\n [FLT] %*s(COND", depth, ""); depth++; for (i = 0; i < cond->n_cmds; i++) { @@ -1104,7 +1111,8 @@ run_cond (int depth, } if (pos < 0) MERROR (MERROR_DRAW, -1); - MDEBUG_PRINT (")"); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT (")"); return (pos); } @@ -1116,11 +1124,12 @@ run_otf (int depth, #ifdef HAVE_OTF int from_idx = gstring->used; - MDEBUG_PRINT4 ("\n [FLT] %*s(OTF %s,%s)", depth, "", - (! otf_cmd->features[MFONT_OTT_GSUB].str ? "" - : otf_cmd->features[MFONT_OTT_GSUB].str), - (! otf_cmd->features[MFONT_OTT_GPOS].str ? "" - : otf_cmd->features[MFONT_OTT_GPOS].str)); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT4 ("\n [FLT] %*s(OTF %s,%s)", depth, "", + (! otf_cmd->features[MFONT_OTT_GSUB].str ? "" + : otf_cmd->features[MFONT_OTT_GSUB].str), + (! otf_cmd->features[MFONT_OTT_GPOS].str ? "" + : otf_cmd->features[MFONT_OTT_GPOS].str)); to = mfont__ft_drive_otf (gstring, from, to, otf_cmd); if (ctx->cluster_begin_idx) for (; from_idx < gstring->used; from_idx++) @@ -1149,7 +1158,8 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, g = *(MGLYPH (from - 1)); g.type = GLYPH_CHAR; g.code = ctx->code_offset + id; - MDEBUG_PRINT3 ("\n [FLT] %*s(DIRECT 0x%X", depth, "", g.code); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s(DIRECT 0x%X", depth, "", g.code); if (ctx->combining_code) g.combining_code = ctx->combining_code; if (ctx->left_padding) @@ -1166,7 +1176,8 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, APPEND_GLYPH (gstring, g); UPDATE_CLUSTER_RANGE (ctx, g); ctx->code_offset = ctx->combining_code = ctx->left_padding = 0; - MDEBUG_PRINT (")"); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT (")"); return (from); } @@ -1193,8 +1204,9 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, if (id <= CMD_ID_OFFSET_COMBINING) { ctx->combining_code = CMD_ID_TO_COMBINING_CODE (id); - MDEBUG_PRINT3 ("\n [FLT] %*s(CMB %s)", depth, "", - dump_combining_code (ctx->combining_code)); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s(CMB %s)", depth, "", + dump_combining_code (ctx->combining_code)); return from; } @@ -1211,7 +1223,8 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, g.left_padding = ctx->left_padding; APPEND_GLYPH (gstring, g); UPDATE_CLUSTER_RANGE (ctx, g); - MDEBUG_PRINT3 ("\n [FLT] %*s(COPY 0x%X)", depth, "", g.code); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s(COPY 0x%X)", depth, "", g.code); ctx->code_offset = ctx->combining_code = ctx->left_padding = 0; return (from + 1); } @@ -1219,7 +1232,8 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, case CMD_ID_CLUSTER_BEGIN: if (! ctx->cluster_begin_idx) { - MDEBUG_PRINT3 ("\n [FLT] %*s<%d", depth, "", MGLYPH (from)->pos); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT3 ("\n [FLT] %*s<%d", depth, "", MGLYPH (from)->pos); ctx->cluster_begin_idx = gstring->used; ctx->cluster_begin_pos = MGLYPH (from)->pos; ctx->cluster_end_pos = MGLYPH (from)->to; @@ -1231,7 +1245,8 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, { int i; - MDEBUG_PRINT1 (" %d>", ctx->cluster_end_pos); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT1 (" %d>", ctx->cluster_end_pos); for (i = ctx->cluster_begin_idx; i < gstring->used; i++) { MGLYPH (i)->pos = ctx->cluster_begin_pos; @@ -1255,14 +1270,16 @@ run_command (int depth, int id, MGlyphString *gstring, int from, int to, } case CMD_ID_LEFT_PADDING: - MDEBUG_PRINT2 ("\n [FLT] %*s[", depth, ""); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT2 ("\n [FLT] %*s[", depth, ""); ctx->left_padding = 1; return from; case CMD_ID_RIGHT_PADDING: if (gstring->used > 0) { - MDEBUG_PRINT2 ("\n [FLT] %*s]", depth, ""); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT2 ("\n [FLT] %*s]", depth, ""); gstring->glyphs[gstring->used - 1].right_padding = 1; } return from; @@ -1383,28 +1400,38 @@ mfont__flt_run (MGlyphString *gstring, int from, int to, MRealizedFace *rface) from_pos = MGLYPH (from)->pos; to_pos = MGLYPH (to)->pos; + if (MDEBUG_FLAG ()) + { + MDEBUG_PRINT ("\n [FLT] (SOURCE"); + for (i = from; i < to; i++) + MDEBUG_PRINT1 (" %04X", MGLYPH (i)->c); + MDEBUG_PRINT (")"); + } + for (stage_idx = 0; 1; stage_idx++) { int len = to - from; int result; ctx.code_offset = ctx.combining_code = ctx.left_padding = 0; - MDEBUG_PRINT2 ("\n [FLT] (STAGE %d \"%s\"", stage_idx, ctx.encoded); - if (mdebug__flag & mdebug_mask - && ctx.encoded_offset < to) + if (MDEBUG_FLAG () > 2) { - if (gstring->glyphs[ctx.encoded_offset].type == GLYPH_PAD) - fprintf (stderr, " (|"); - else - fprintf (stderr, " (%X", gstring->glyphs[ctx.encoded_offset].code); - for (i = ctx.encoded_offset + 1; i < to; i++) + MDEBUG_PRINT2 ("\n [FLT] (STAGE %d \"%s\"", stage_idx, ctx.encoded); + if (ctx.encoded_offset < to) { - if (gstring->glyphs[i].type == GLYPH_PAD) - fprintf (stderr, " |"); + if (gstring->glyphs[ctx.encoded_offset].type == GLYPH_PAD) + fprintf (stderr, " (|"); else - fprintf (stderr, " %X", gstring->glyphs[i].code); + fprintf (stderr, " (%X", gstring->glyphs[ctx.encoded_offset].code); + for (i = ctx.encoded_offset + 1; i < to; i++) + { + if (gstring->glyphs[i].type == GLYPH_PAD) + fprintf (stderr, " |"); + else + fprintf (stderr, " %X", gstring->glyphs[i].code); + } + fprintf (stderr, ")"); } - fprintf (stderr, ")"); } gidx = gstring->used; @@ -1412,7 +1439,8 @@ mfont__flt_run (MGlyphString *gstring, int from, int to, MRealizedFace *rface) result = run_command (4, INDEX_TO_CMD_ID (0), gstring, ctx.encoded_offset, to, &ctx); - MDEBUG_PRINT (")"); + if (MDEBUG_FLAG () > 2) + MDEBUG_PRINT (")"); if (result < 0) return -1; to = from + (gstring->used - gidx); @@ -1521,24 +1549,25 @@ mfont__flt_run (MGlyphString *gstring, int from, int to, MRealizedFace *rface) latest = glyphs[i]; } } - MDEBUG_PRINT ("\n [FLT] (RESULT ("); - if (mdebug__flag & mdebug_mask - && ctx.encoded_offset < to) + if (MDEBUG_FLAG ()) { - if (gstring->glyphs[from].type == GLYPH_PAD) - fprintf (stderr, "|"); + MDEBUG_PRINT ("\n [FLT] (RESULT"); + if (MDEBUG_FLAG () > 1) + for (i = 0; from < to; from++, i++) + { + MGlyph *g; + + if (i > 0 && i % 4 == 0) + MDEBUG_PRINT ("\n [FLT] "); + g = MGLYPH (from); + MDEBUG_PRINT4 (" (%04X %d %d %d)", + g->code, g->width, g->xoff, g->yoff); + } else - fprintf (stderr, "%X", gstring->glyphs[from].code); - for (from++; from < to; from++) - { - if (gstring->glyphs[from].type == GLYPH_PAD) - fprintf (stderr, " |"); - else - fprintf (stderr, " %X", gstring->glyphs[from].code); - } - fprintf (stderr, "))"); + for (; from < to; from++) + MDEBUG_PRINT1 (" %04X", MGLYPH (from)->code); + MDEBUG_PRINT ("))\n"); } - MDEBUG_PRINT (")\n"); return to; }