+
+/* for now only intended to find what glyphs of each font are to be included in the swf file.
+ * Therefore some knowledge about the command is assumed i.e. it is font/text-related
+ * No syntax checking is done */
+static void analyseArgumentsForCommand(char*command)
+{
+ int t;
+ map_t args;
+ char* fontfile;
+ int nr = -1;
+ msg("<verbose> analyse Command: %s (line %d)", command, line);
+
+ for(t=0;t<sizeof(arguments)/sizeof(arguments[0]);t++)
+ {
+ if(!strcmp(arguments[t].command, command))
+ {
+ args = parseArguments(command, arguments[t].arguments);
+ nr = t;
+ break;
+ }
+ }
+#ifdef DEBUG
+ printf(".%s\n", command);fflush(stdout);
+ map_dump(&args, stdout, "\t");fflush(stdout);
+#endif
+ char* name = lu(&args, "name");
+ if (!strcmp(command, "font"))
+ {
+ if(dictionary_lookup(&fonts, name))
+ syntaxerror("font %s defined twice", name);
+
+ SWFFONT* font;
+ fontfile = lu(&args, "filename");
+ font = swf_LoadFont(fontfile);
+ if(font == 0) {
+ warning("Couldn't open font file \"%s\"", fontfile);
+ font = (SWFFONT*)malloc(sizeof(SWFFONT));
+ memset(font, 0, sizeof(SWFFONT));
+ }
+ swf_FontUseUTF8(font, lu(&args, "glyphs"));
+ swf_FontPrepareForEditText(font);
+ dictionary_put2(&fonts, name, font);
+ }
+ else
+ {
+ SWFFONT* font = dictionary_lookup(&fonts, lu(&args, "font"));
+ if (!font)
+ syntaxerror("font %s is not known in line %d", lu(&args, "font"), line);
+ else
+ if (!strcmp(command, "edittext"))
+ swf_FontUseAll(font);
+ else
+ swf_FontUseUTF8(font, lu(&args, "text"));
+ }
+ map_clear(&args);
+ return;
+}
+
+void skipParameters()
+{
+ do
+ readToken();
+ while (type != COMMAND);
+ pushBack();
+}
+
+void findFontUsage()
+{
+ char* fontRelated = "font;text;textshape;edittext;";
+ while(!noMoreTokens())
+ {
+ readToken();
+ if(type != COMMAND)
+ syntaxerror("command expected");
+ if (strstr(fontRelated, text))
+ analyseArgumentsForCommand(text);
+ else
+ if(strcmp(text, "end"))
+ skipParameters();
+ }
+}
+
+void firstPass()
+{
+ pos = 0;
+ id = 0;
+ dictionary_init(&fonts);
+ cleanUp = &freeFontDictionary;
+ findFontUsage();
+}
+