[numberset] Add `wrap_range_prepend'.
[ttfautohint.git] / lib / tadump.c
blobefe679be4b6b10df519f7e0c3f7ac9ff890a6efb
1 /* tadump.c */
3 /*
4 * Copyright (C) 2014-2017 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 #include "ta.h"
17 #include <stdarg.h>
20 #define DUMPVAL(str, arg) \
21 do \
22 { \
23 s = sdscatprintf(s, \
24 "%*s = %ld\n", \
25 width, (str), (FT_Long)(arg)); \
26 } while (0)
27 #define DUMPSTR(str, arg) \
28 do \
29 { \
30 s = sdscatprintf(s, \
31 "%*s = %s%s", \
32 width, (str), (arg), eol); \
33 } while (0)
34 #define DUMPSTRX(arg) \
35 do \
36 { \
37 s = sdscatprintf(s, \
38 "%s%*s %s%s", \
39 prev_eol, width, "", (arg), eol); \
40 } while (0)
44 /* if `format' is set, we present the data in a more friendly format */
46 char*
47 TA_font_dump_parameters(FONT* font,
48 FT_Bool format)
50 sds s;
51 size_t len;
52 char* res;
54 char* ns = NULL;
55 char* ds = NULL;
57 int width = 0;
58 const char* eol = "\n";
59 const char* prev_eol = "";
62 s = sdsempty();
64 if (format)
66 s = sdscat(s, "TTF_autohint parameters\n"
67 "=======================\n");
68 width = 33;
71 s = sdscat(s, "\n");
73 DUMPSTR("ttfautohint version",
74 VERSION);
76 s = sdscat(s, "\n");
78 if (font->dehint)
80 if (format)
81 DUMPVAL("dehint",
82 font->dehint);
83 goto Exit;
86 DUMPVAL("adjust-subglyphs",
87 font->adjust_subglyphs);
88 DUMPSTR("default-script",
89 script_names[font->default_script]);
90 DUMPVAL("dw-cleartype-strong-stem-width",
91 font->dw_cleartype_strong_stem_width);
92 DUMPVAL("fallback-scaling",
93 font->fallback_scaling);
94 DUMPSTR("fallback-script",
95 script_names[ta_style_classes[font->fallback_style]->script]);
96 DUMPVAL("fallback-stem-width",
97 font->fallback_stem_width);
98 DUMPVAL("gdi-cleartype-strong-stem-width",
99 font->gdi_cleartype_strong_stem_width);
100 DUMPVAL("gray-strong-stem-width",
101 font->gray_strong_stem_width);
102 DUMPVAL("hinting-limit",
103 font->hinting_limit);
104 DUMPVAL("hinting-range-max",
105 font->hinting_range_max);
106 DUMPVAL("hinting-range-min",
107 font->hinting_range_min);
108 DUMPVAL("hint-composites",
109 font->hint_composites);
110 DUMPVAL("ignore-restrictions",
111 font->ignore_restrictions);
112 DUMPVAL("increase-x-height",
113 font->increase_x_height);
114 if (font->reference_name)
115 DUMPSTR("reference",
116 font->reference_name);
117 else if (font->reference_buf)
118 DUMPSTR("reference",
119 "<yes>");
120 else
121 DUMPSTR("reference",
122 "");
123 DUMPVAL("reference-index",
124 font->reference_index);
125 DUMPVAL("symbol",
126 font->symbol);
127 DUMPVAL("TTFA-info",
128 font->TTFA_info);
129 DUMPVAL("windows-compatibility",
130 font->windows_compatibility);
132 ns = number_set_show(font->x_height_snapping_exceptions,
133 TA_PROP_INCREASE_X_HEIGHT_MIN, 0x7FFF);
134 if (!ns)
136 sdsfree(s);
137 s = NULL;
138 goto Exit;
141 DUMPSTR("x-height-snapping-exceptions", ns);
143 ds = TA_control_show(font);
144 if (!ds)
146 sdsfree(s);
147 s = NULL;
148 goto Exit;
151 if (*ds)
153 char* token;
154 char* saveptr;
157 token = strtok_r(ds, "\n", &saveptr);
158 if (format)
159 DUMPSTR("control-instructions", token);
160 else
162 DUMPSTR("control-instructions", "\\");
163 eol = "";
164 /* show control instructions line by line */
165 DUMPSTRX(token);
166 prev_eol = "; \\\n";
169 for (;;)
171 token = strtok_r(NULL, "\n", &saveptr);
172 if (!token)
173 break;
175 DUMPSTRX(token);
178 else
179 DUMPSTR("control-instructions", "");
181 if (!format)
182 s = sdscat(s, "\n");
183 s = sdscat(s, "\n");
185 Exit:
186 free(ns);
187 free(ds);
189 if (!s)
190 return NULL;
192 len = sdslen(s) + 1;
193 res = (char*)malloc(len);
194 if (res)
195 memcpy(res, s, len);
197 sdsfree(s);
199 return res;
202 /* end of tadump.c */