Generalize TA_font_dump_parameters.
[ttfautohint.git] / lib / tadump.c
blob09b20e9403ef4d59a1a516a855b5cd7e66b1f082
1 /* tadump.c */
3 /*
4 * Copyright (C) 2014 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
15 #define _POSIX_SOURCE /* to access `strtok_r' with glibc */
17 #include "ta.h"
18 #include <string.h>
21 #define DUMPVAL(str, arg) \
22 fprintf(stream, "%*s = %ld\n", \
23 width, (str), \
24 (FT_Long)(arg))
25 #define DUMPSTR(str, arg) \
26 fprintf(stream, "%*s = %s%s", \
27 width, (str), \
28 (arg), eol)
29 #define DUMPSTRX(arg) \
30 fprintf(stream, "%s%*s %s%s", \
31 prev_eol, width, "", \
32 (arg), eol)
35 /* if `format' is set, we present the data in a more friendly format */
37 TA_Error
38 TA_font_dump_parameters(FONT* font,
39 FILE* stream,
40 Deltas* deltas,
41 FT_Bool dehint,
42 FT_Bool format)
44 char* s;
45 char* token;
46 char* saveptr;
48 int width = 0;
49 const char* eol = "\n";
50 const char* prev_eol = "";
53 if (format)
55 fprintf(stream, "TTF_autohint parameters\n"
56 "=======================\n"
57 "\n");
58 width = 33;
61 if (dehint)
63 if (format)
64 DUMPVAL("dehint",
65 font->dehint);
66 return TA_Err_Ok;
69 DUMPVAL("adjust-subglyphs",
70 font->adjust_subglyphs);
71 DUMPSTR("default-script",
72 script_names[font->default_script]);
73 DUMPVAL("dw-cleartype-strong-stem-width",
74 font->dw_cleartype_strong_stem_width);
75 DUMPSTR("fallback-script",
76 script_names[ta_style_classes[font->fallback_style]->script]);
77 DUMPVAL("fallback-stem-width",
78 font->fallback_stem_width);
79 DUMPVAL("gdi-cleartype-strong-stem-width",
80 font->gdi_cleartype_strong_stem_width);
81 DUMPVAL("gray-strong-stem-width",
82 font->gray_strong_stem_width);
83 DUMPVAL("hinting-limit",
84 font->hinting_limit);
85 DUMPVAL("hinting-range-max",
86 font->hinting_range_max);
87 DUMPVAL("hinting-range-min",
88 font->hinting_range_min);
89 DUMPVAL("hint-composites",
90 font->hint_composites);
91 DUMPVAL("ignore-restrictions",
92 font->ignore_restrictions);
93 DUMPVAL("increase-x-height",
94 font->increase_x_height);
95 DUMPVAL("symbol",
96 font->symbol);
97 DUMPVAL("windows-compatibility",
98 font->windows_compatibility);
100 s = number_set_show(font->x_height_snapping_exceptions,
101 TA_PROP_INCREASE_X_HEIGHT_MIN, 0x7FFF);
102 if (!s)
103 return FT_Err_Out_Of_Memory;
105 DUMPSTR("x-height-snapping-exceptions", s);
106 free(s);
108 s = TA_deltas_show(font, deltas);
109 if (!s)
110 return FT_Err_Out_Of_Memory;
112 /* show delta exceptions data line by line */
113 if (!format)
115 eol = "";
116 prev_eol = "; \\\n";
119 token = strtok_r(s, "\n", &saveptr);
120 DUMPSTR("delta exceptions", token);
122 for (;;)
124 token = strtok_r(NULL, "\n", &saveptr);
125 if (!token)
126 break;
128 DUMPSTRX(token);
130 if (!format)
131 fprintf(stream, "\n");
133 free(s);
135 fprintf(stderr, "\n");
137 return TA_Err_Ok;
140 /* end of tadump.c */