void metafont_start_output (string output_name, bzr_preamble_type pre, tfm_global_info_type info) { unsigned this_param; string current_time = now (); mf_filename = make_output_filename (output_name, "mf"); mf_file = xfopen (mf_filename, "w"); /* Output some identification. */ OUT1 ("%% This file defines the Metafont font %s.\n", mf_filename); OUT1 ("%% {%s}\n", BZR_COMMENT (pre)); OUT1 ("%% Generated %s.\n", current_time); OUT_LINE ("% This font is in the public domain."); /* Output the size that our original data is based on. The font can be generated at sizes different than this. */ OUT_PT_ASSIGNMENT ("true_design_size#", BZR_DESIGN_SIZE (pre)); /* Output the fontwide information given in INFO. */ OUT1 ("font_coding_scheme := \"%s\";\n", TFM_CODING_SCHEME (info)); /* The real work is done in an auxiliary file. */ OUT_STATEMENT ("input bzrsetup"); for (this_param = 1; this_param <= TFM_FONT_PARAMETER_COUNT (info); this_param++) OUT2 ("fontdimen %u: %.2fpt# * u#;\n", this_param, TFM_FONT_PARAMETER (info, this_param)); }
static void out_splines (FILE * epd_file, spline_list_array_type shape) { unsigned this_list; spline_list_type list; at_color last_color = {0,0,0}; for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape); this_list++) { unsigned this_spline; spline_type first; list = SPLINE_LIST_ARRAY_ELT (shape, this_list); first = SPLINE_LIST_ELT (list, 0); if (this_list == 0 || !at_color_equal(&list.color, &last_color)) { if (this_list > 0) { OUT_LINE ((shape.centerline || list.open) ? "S" : "f"); OUT_LINE("h"); } OUT4 ("%.3f %.3f %.3f %s\n", (double) list.color.r / 255.0, (double) list.color.g / 255.0, (double) list.color.b / 255.0, (shape.centerline || list.open) ? "RG" : "rg"); last_color = list.color; } OUT_COMMAND2 (START_POINT (first).x, START_POINT (first).y, "m"); for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list); this_spline++) { spline_type s = SPLINE_LIST_ELT (list, this_spline); if (SPLINE_DEGREE (s) == LINEARTYPE) OUT_COMMAND2 (END_POINT (s).x, END_POINT (s).y, "l"); else OUT_COMMAND6 (CONTROL1 (s).x, CONTROL1 (s).y, CONTROL2 (s).x, CONTROL2 (s).y, END_POINT (s).x, END_POINT (s).y, "c"); } } if (SPLINE_LIST_ARRAY_LENGTH(shape) > 0) OUT_LINE ((shape.centerline || list.open) ? "S" : "f"); }
void metafont_finish_output (tfm_char_type *tfm_chars) { output_ligtable (tfm_chars); OUT_LINE ("\nbye."); xfclose (mf_file, mf_filename); }
static int output_epd_header(FILE* epd_file, gchar* name, int llx, int lly, int urx, int ury) { gchar* time; OUT_LINE ("%EPD-1.0"); OUT1 ("%% Created by %s\n", at_version(TRUE)); OUT1 ("%% Title: %s\n", name); OUT1 ("%% CreationDate: %s\n", time = at_time_string ()); OUT4 ("%%BBox(%d,%d,%d,%d)\n", llx, lly, urx, ury); g_free (time); return 0; }
static void output_ligtable (tfm_char_type *tfm_chars) { unsigned code; for (code = 0; code <= MAX_CHARCODE; code++) { list_type kern_list, ligature_list; unsigned this_kern, this_lig; tfm_char_type c = tfm_chars[code]; boolean output_something = false; /* If this character didn't get output, or if we don't have TFM information for it, don't do anything. */ if (NO_CHAR_P (code)) continue; /* Output the kerns. */ kern_list = c.kern; for (this_kern = 0; this_kern < LIST_SIZE (kern_list); this_kern++) { tfm_kern_type *kern = LIST_ELT (kern_list, this_kern); if (NO_CHAR_P (kern->character)) continue; LIGTABLE_ENTRY (code); OUT2 ("hex\"%x\" kern %.4fpt#", kern->character, kern->kern); } /* Output the ligatures. */ ligature_list = c.ligature; for (this_lig = 0; this_lig < LIST_SIZE (ligature_list); this_lig++) { tfm_ligature_type *lig = LIST_ELT (ligature_list, this_lig); if (NO_CHAR_P (lig->character) || NO_CHAR_P (lig->ligature)) continue; LIGTABLE_ENTRY (code); OUT2 ("hex\"%x\" =: hex\"%x\"", lig->character, lig->ligature); } if (output_something) OUT_LINE (";"); } }
void ps_output_encoding (FILE *f) { unsigned c; int range_start = -1; fprintf (f, "/Encoding %d array\n", ENCODING_VECTOR_SIZE); for (c = 0; c < ENCODING_VECTOR_SIZE; c++) { /* Write sequences of .notdef's and characters we didn't output using a loop. */ if (!ps_char_output_p[c] || STREQ (ENCODING_CHAR_NAME (encoding, c), ".notdef")) { /* Start or continue a loop. */ if (range_start == -1) range_start = c; } else { /* Finish a loop if one is started, then output the current character. */ if (range_start != -1) { /* Loop started, finish it. */ out_notdef_loop (f, range_start, c - 1); range_start = -1; } /* Output the current character. */ OUT2 (" dup %d /%s put\n", c, ENCODING_CHAR_NAME (encoding, c)); } } /* If the encoding ends with .notdef's, we'll be in the midst of a loop. */ if (range_start != -1) out_notdef_loop (f, range_start, c - 1); /* Define it. */ OUT_LINE (" readonly def"); }
void ps_start_font (FILE *f, ps_font_info_type ps_info, string comment) { OUT1 ("%%%%Creator: %s\n", version_string); OUT1 ("%%%%CreationDate: %s\n", now ()); OUT_LINE ("%%DocumentData: Clean7Bit"); OUT_LINE ("%%EndComments"); OUT1 ("%% {%s}\n", comment); OUT_LINE ("% This font is in the public domain."); OUT1 ("/%s 11 dict begin\n", ps_info.font_name); /* The FontInfo dictionary, which has additional (supposedly optional) information. */ OUT_LINE ("/FontInfo 8 dict begin"); OUT1 (" /version (%s) readonly def\n", ps_info.version); OUT1 (" /FullName (%s) readonly def\n", ps_info.font_name); OUT1 (" /FamilyName (%s) readonly def\n", ps_info.family_name); OUT1 (" /Weight (%s) readonly def\n", ps_info.weight); OUT1 (" /ItalicAngle %d def\n", ps_info.italic_angle); OUT1 (" /isFixedPitch %s def\n", ps_info.monospace_p ? "true" : "false"); OUT1 (" /underlinePosition %d def\n", ps_info.underline_position); OUT1 (" /underlineThickness %d def\n", ps_info.underline_thickness); OUT_LINE ("currentdict end readonly def"); /* Other constant top-level elements of the font dictionary. Assume that the font name is the only thing on the stack at this point (which is true). This saves us from having to write the name twice. */ OUT_LINE ("/FontName 1 index def"); OUT_LINE ("/PaintType 0 def"); /* All our fonts are filled. */ if (ps_info.unique_id) OUT1 ("/UniqueID %d\n", ps_info.unique_id); }
void metafont_output_char (bzr_char_type c) { unsigned this_list; spline_list_array_type shape = BZR_SHAPE (c); int offset = CHAR_LSB (c); fprintf (mf_file, "\nbeginchar (%d, %.2fu#, %.2fu#, %.2fu#);\n", CHARCODE (c), CHAR_SET_WIDTH (c), CHAR_HEIGHT (c), CHAR_DEPTH (c)); /* Go through the list of splines once, assigning the control points to Metafont variables. This allows us to produce more information on proofsheets. */ for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape); this_list++) { unsigned this_spline; spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list); OUT_ZASSIGNMENT (INDENT "z%u\\%us", this_list, 0, START_POINT (SPLINE_LIST_ELT (list, 0))); for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list); this_spline++) { spline_type s = SPLINE_LIST_ELT (list, this_spline); if (SPLINE_DEGREE (s) == CUBIC) { OUT_ZASSIGNMENT (INDENT "z%u\\%uc1", this_list, this_spline, CONTROL1 (s)); OUT_ZASSIGNMENT (INDENT "z%u\\%uc2", this_list, this_spline, CONTROL2 (s)); } /* The last point in the list is also the first point, and we don't want to output two variables for the same point. */ if (this_spline < SPLINE_LIST_LENGTH (list) - 1) OUT_ZASSIGNMENT (INDENT "z%u\\%u", this_list, this_spline, END_POINT (s)); } } /* Go through the list of splines again, outputting the path-construction commands. */ for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape); this_list++) { unsigned this_spline; spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list); OUT2 (INDENT "fill_or_unfill z%u\\%us\n", this_list, 0); for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list); this_spline++) { spline_type s = SPLINE_LIST_ELT (list, this_spline); if (SPLINE_DEGREE (s) == LINEAR) OUT_STRING (INDENT INDENT "--"); else { OUT_STRING (INDENT INDENT "..controls "); OUT2 ("z%u\\%uc1 and ", this_list, this_spline); OUT2 ("z%u\\%uc2..", this_list, this_spline); } if (this_spline < SPLINE_LIST_LENGTH (list) - 1) OUT2 ("z%u\\%u\n", this_list, this_spline); } OUT_STRING ("cycle;\n"); } /* The plain Metafont `labels' command makes it possible to produce proofsheets with all the points labeled. We always want labels for the starting and ending points, and possibly labels for the control points on each spline, so we have our own command `proof_labels', defined in `bzrsetup.mf'. */ OUT_LINE (INDENT "proof_labels ("); for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape); this_list++) { unsigned this_spline; spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list); for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (list); this_spline++) OUT2 (INDENT INDENT "%u\\%u,\n", this_list, this_spline); } OUT_STRING (");\n"); OUT_STATEMENT ("endchar"); mf_char_output_p[CHARCODE (c)] = true; }
/****************************************************************************** * DXF output function. */ int output_dxf12_writer(FILE* dxf_file, gchar* name, int llx, int lly, int urx, int ury, at_output_opts_type * opts, spline_list_array_type shape, at_msg_func msg_func, gpointer msg_data, gpointer user_data) { OUT_LINE (" 0"); OUT_LINE ("SECTION"); OUT_LINE (" 2"); OUT_LINE ("HEADER"); OUT_LINE (" 9"); OUT_LINE ("$ACADVER"); OUT_LINE (" 1"); OUT_LINE ("AC1009"); OUT_LINE (" 9"); OUT_LINE ("$EXTMIN"); OUT_LINE (" 10"); OUT1 (" %f\n", (double)llx); OUT_LINE (" 20"); OUT1 (" %f\n", (double)lly); OUT_LINE (" 30"); OUT_LINE (" 0.000000"); OUT_LINE (" 9"); OUT_LINE ("$EXTMAX"); OUT_LINE (" 10"); OUT1 (" %f\n", (double)urx); OUT_LINE (" 20"); OUT1 (" %f\n", (double)ury); OUT_LINE (" 30"); OUT_LINE (" 0.000000"); OUT_LINE (" 0"); OUT_LINE ("ENDSEC"); output_layer(dxf_file, shape); OUT_LINE (" 0"); OUT_LINE ("SECTION"); OUT_LINE (" 2"); OUT_LINE ("ENTITIES"); out_splines(dxf_file, shape); OUT_LINE (" 0"); OUT_LINE ("ENDSEC"); OUT_LINE (" 0"); OUT_LINE ("EOF"); return 0; }
/****************************************************************************** * This function outputs a complete layer table for all 255 colors. */ void output_layer(FILE *dxf_file, spline_list_array_type shape) { int i, idx; char layerlist[256]; unsigned this_list; at_color last_color = {0,0,0}; memset(layerlist, 0, sizeof(layerlist)); for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (shape); this_list++) { spline_list_type list = SPLINE_LIST_ARRAY_ELT (shape, this_list); at_color curr_color = (list.clockwise && shape.background_color != NULL) ? *(shape.background_color) : list.color; if (&this_list == 0 || !at_color_equal(&curr_color, &last_color)) { if (!(curr_color.r==0 && curr_color.g==0 && curr_color.b==0) || !color_check) { idx = GetIndexByRGBValue(curr_color.r, curr_color.g, curr_color.b); layerlist[idx-1] = 1; last_color = curr_color; } } } OUT_LINE(" 0"); OUT_LINE("SECTION"); OUT_LINE(" 2"); OUT_LINE("TABLES"); OUT_LINE(" 0"); OUT_LINE("TABLE"); OUT_LINE(" 2"); OUT_LINE("LAYER"); OUT_LINE(" 70"); OUT_LINE(" 2048"); OUT_LINE(" 0"); OUT_LINE("LAYER"); OUT_LINE(" 2"); OUT_LINE("0"); OUT_LINE(" 70"); OUT_LINE(" 0"); OUT_LINE(" 62"); OUT_LINE(" 7"); OUT_LINE(" 6"); OUT_LINE("CONTINUOUS"); for (i=1; i<256; i++) { if (layerlist[i-1]) { OUT_LINE(" 0"); OUT_LINE("LAYER"); OUT_LINE(" 2"); OUT1 ("C%d\n", i); OUT_LINE(" 70"); OUT_LINE(" 64"); OUT_LINE(" 62"); OUT1 ("%d\n", i); OUT_LINE(" 6"); OUT_LINE("CONTINUOUS"); } } OUT_LINE(" 0"); OUT_LINE("ENDTAB"); OUT_LINE (" 0"); OUT_LINE ("ENDSEC"); }