745
/* SYMBOL's name features[0] for checking for applying
746
features[1] GSUB GPOS GSUB GPOS
747
------------- ------------------ ------------- ------------
748
SCRIPT [-1,0] [-1,0] any | any all all
749
SCRIPT= NULL [-1,0] none & 1 none all
750
SCRIPT+ [-1,0] NULL 1 & none all none
751
SCRIPT=+ NULL NULL none & none none none
752
SCRIPT=F1 [F1,0] [-1,0] F1 & 1 F1 all
753
SCRIPT+F1 [-1][0] [F1,0] 1 & F1 none F1
754
SCRIPT=F1+ [F1,0] NULL F1 & none F1 none
755
SCRIPT=~F2 [-1,F2,0] [-1,0] ~F2 & 1 all~F2 all
756
SCRIPT=F1,~F2 [F1,-1,F2,0][-1,0] F1&~F2 & 1 F1 (*1) all
758
(*1) Invalid specification
746
762
parse_otf_command (MSymbol symbol, MFLTOtfSpec *spec)
748
764
char *str = MSYMBOL_NAME (symbol);
749
765
char *end = str + MSYMBOL_NAMELEN (symbol);
750
766
unsigned int script, langsys;
752
int gsub_count = 0, gpos_count = 0;
768
int feature_count[2]; /* [0]:GSUB, [1]:GPOS */
755
772
memset (spec, 0, sizeof (MFLTOtfSpec));
765
782
/* This is a spec to reset category codes. */
768
script = gen_otf_tag (str, 8);
785
spec->script = gen_otf_tag (str, 8);
772
langsys = gen_otf_tag (str, 8);
789
spec->langsys = gen_otf_tag (str, 8);
779
796
/* Apply all GSUB features. */
797
feature_count[0] = -1;
784
str = otf_count_features (p, end, '+', &gsub_count);
801
str = otf_count_features (p, end, '+', feature_count);
786
803
MERROR (MERROR_FLT, -1);
790
807
/* Apply all GPOS features. */
808
feature_count[1] = -1;
795
str = otf_count_features (p, end, '\0', &gpos_count);
812
str = otf_count_features (p, end, '\0', feature_count + 1);
797
814
MERROR (MERROR_FLT, -1);
800
spec->script = script;
801
spec->langsys = langsys;
804
spec->features[0] = malloc (sizeof (int) * (gsub_count + 1));
805
if (! spec->features[0])
808
otf_store_features (gsub + 1, gpos, spec->features[0]);
810
spec->features[0][0] = 0xFFFFFFFF, spec->features[0][1] = 0;
814
spec->features[1] = malloc (sizeof (int) * (gpos_count + 1));
815
if (! spec->features[1])
817
if (spec->features[0])
818
free (spec->features[0]);
817
for (i = 0; i < 2; i++)
818
if (feature_count[i])
820
spec->features[i] = malloc (sizeof (int)
821
* (feature_count[i] < 0 ? 2
822
: feature_count[i] + 1));
823
if (! spec->features[i])
822
otf_store_features (gpos + 1, str, spec->features[1]);
824
spec->features[1][0] = 0xFFFFFFFF, spec->features[1][1] = 0;
825
if (feature_count[i] > 0)
826
otf_store_features (features[i] + 1, features[i + 1],
829
spec->features[i][0] = 0xFFFFFFFF, spec->features[i][1] = 0;
3058
3062
MDEBUG_PRINT ("\n [FLT] (RESULT");
3059
3063
if (MDEBUG_FLAG () > 1)
3060
for (i = 0; this_from < this_to; this_from++, i++)
3062
if (i > 0 && i % 4 == 0)
3063
MDEBUG_PRINT ("\n [FLT] ");
3064
g = GREF (gstring, this_from);
3065
MDEBUG_PRINT4 (" (%04X %d %d %d)",
3066
g->code, g->xadv, g->xoff, g->yoff);
3066
for (i = 0; this_from < this_to; i++, this_from++)
3068
g = GREF (gstring, this_from);
3072
MDEBUG_PRINT2 ("\n [FLT] %02d-%02d",
3075
MDEBUG_PRINT2 (" %02d-%02d", g->from, g->to);
3078
MDEBUG_PRINT4 (" (%04X %d %d %d)",
3079
g->code, g->xadv, g->xoff, g->yoff);
3069
3083
for (; this_from < this_to; this_from++)
3070
3084
MDEBUG_PRINT1 (" %04X", GREF (gstring, this_from)->code);
3128
3142
FontLayoutCmdRule *rule = &cmd->body.rule;
3131
fprintf (stderr, "(rule ");
3145
fprintf (mdebug__output, "(rule ");
3132
3146
if (rule->src_type == SRC_REGEX)
3133
fprintf (stderr, "\"%s\"", rule->src.re.pattern);
3147
fprintf (mdebug__output, "\"%s\"", rule->src.re.pattern);
3134
3148
else if (rule->src_type == SRC_INDEX)
3135
fprintf (stderr, "%d", rule->src.match_idx);
3149
fprintf (mdebug__output, "%d", rule->src.match_idx);
3136
3150
else if (rule->src_type == SRC_SEQ)
3137
fprintf (stderr, "(seq)");
3151
fprintf (mdebug__output, "(seq)");
3138
3152
else if (rule->src_type == SRC_RANGE)
3139
fprintf (stderr, "(range)");
3153
fprintf (mdebug__output, "(range)");
3141
fprintf (stderr, "(invalid src)");
3155
fprintf (mdebug__output, "(invalid src)");
3143
3157
for (i = 0; i < rule->n_cmds; i++)
3145
fprintf (stderr, "\n%s ", prefix);
3159
fprintf (mdebug__output, "\n%s ", prefix);
3146
3160
dump_flt_cmd (stage, rule->cmd_ids[i], indent + 2);
3148
fprintf (stderr, ")");
3162
fprintf (mdebug__output, ")");
3150
3164
else if (cmd->type == FontLayoutCmdTypeCond)
3152
3166
FontLayoutCmdCond *cond = &cmd->body.cond;
3155
fprintf (stderr, "(cond");
3169
fprintf (mdebug__output, "(cond");
3156
3170
for (i = 0; i < cond->n_cmds; i++)
3158
fprintf (stderr, "\n%s ", prefix);
3172
fprintf (mdebug__output, "\n%s ", prefix);
3159
3173
dump_flt_cmd (stage, cond->cmd_ids[i], indent + 2);
3161
fprintf (stderr, ")");
3175
fprintf (mdebug__output, ")");
3163
3177
else if (cmd->type == FontLayoutCmdTypeOTF)
3165
fprintf (stderr, "(otf)");
3179
fprintf (mdebug__output, "(otf)");
3168
fprintf (stderr, "(error-command)");
3182
fprintf (mdebug__output, "(error-command)");
3170
3184
else if (id <= CMD_ID_OFFSET_COMBINING)
3171
fprintf (stderr, "cominging-code");
3185
fprintf (mdebug__output, "cominging-code");
3173
fprintf (stderr, "(predefiend %d)", id);
3187
fprintf (mdebug__output, "(predefiend %d)", id);
3177
3191
@brief Dump a Font Layout Table.
3179
3193
The mdebug_dump_flt () function prints the Font Layout Table $FLT
3180
in a human readable way to the stderr. $INDENT specifies how many
3181
columns to indent the lines but the first one.
3194
in a human readable way to the stderr or to what specified by the
3195
environment variable MDEBUG_OUTPUT_FILE. $INDENT specifies how
3196
many columns to indent the lines but the first one.
3184
3199
This function returns $FLT. */
3193
3208
memset (prefix, 32, indent);
3194
3209
prefix[indent] = 0;
3195
fprintf (stderr, "(flt");
3210
fprintf (mdebug__output, "(flt");
3196
3211
MPLIST_DO (plist, flt->stages)
3198
3213
FontLayoutStage *stage = (FontLayoutStage *) MPLIST_VAL (plist);
3201
fprintf (stderr, "\n%s (stage %d", prefix, stage_idx);
3216
fprintf (mdebug__output, "\n%s (stage %d", prefix, stage_idx);
3202
3217
for (i = 0; i < stage->used; i++)
3204
fprintf (stderr, "\n%s ", prefix);
3219
fprintf (mdebug__output, "\n%s ", prefix);
3205
3220
dump_flt_cmd (stage, INDEX_TO_CMD_ID (i), indent + 4);
3207
fprintf (stderr, ")");
3222
fprintf (mdebug__output, ")");
3210
fprintf (stderr, ")");
3225
fprintf (mdebug__output, ")");
3219
fprintf (stderr, "(flt-gstring");
3234
fprintf (mdebug__output, "(flt-gstring");
3220
3235
for (i = 0; i < gstring->used; i++)
3222
3237
MFLTGlyph *g = GREF (gstring, i);
3223
fprintf (stderr, "\n (%02d pos:%d-%d c:%04X code:%04X cat:%c)",
3238
fprintf (mdebug__output, "\n (%02d pos:%d-%d c:%04X code:%04X cat:%c)",
3224
3239
i, g->from, g->to, g->c, g->code, GET_CATEGORY_CODE (g));
3226
fprintf (stderr, ")\n");
3241
fprintf (mdebug__output, ")\n");