Minor.
[ttfautohint.git] / lib / tadump.c
blobc3860fdb017b95d563d25753bbc4e1db8f6b5f38
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 #include "ta.h"
17 #include <string.h>
20 #define DUMPVAL(str, arg) \
21 fprintf(stream, "%*s = %ld\n", \
22 width, (str), \
23 (FT_Long)(arg))
24 #define DUMPSTR(str, arg) \
25 fprintf(stream, "%*s = %s%s", \
26 width, (str), \
27 (arg), eol)
28 #define DUMPSTRX(arg) \
29 fprintf(stream, "%s%*s %s%s", \
30 prev_eol, width, "", \
31 (arg), eol)
34 /* if `format' is set, we present the data in a more friendly format */
36 TA_Error
37 TA_font_dump_parameters(FONT* font,
38 FILE* stream,
39 Deltas* deltas,
40 FT_Bool dehint,
41 FT_Bool format)
43 char* s;
44 char* token;
45 char* saveptr;
47 int width = 0;
48 const char* eol = "\n";
49 const char* prev_eol = "";
52 if (format)
54 fprintf(stream, "TTF_autohint parameters\n"
55 "=======================\n"
56 "\n");
57 width = 33;
60 if (dehint)
62 if (format)
63 DUMPVAL("dehint",
64 font->dehint);
65 return TA_Err_Ok;
68 DUMPVAL("adjust-subglyphs",
69 font->adjust_subglyphs);
70 DUMPSTR("default-script",
71 script_names[font->default_script]);
72 DUMPVAL("dw-cleartype-strong-stem-width",
73 font->dw_cleartype_strong_stem_width);
74 DUMPSTR("fallback-script",
75 script_names[ta_style_classes[font->fallback_style]->script]);
76 DUMPVAL("fallback-stem-width",
77 font->fallback_stem_width);
78 DUMPVAL("gdi-cleartype-strong-stem-width",
79 font->gdi_cleartype_strong_stem_width);
80 DUMPVAL("gray-strong-stem-width",
81 font->gray_strong_stem_width);
82 DUMPVAL("hinting-limit",
83 font->hinting_limit);
84 DUMPVAL("hinting-range-max",
85 font->hinting_range_max);
86 DUMPVAL("hinting-range-min",
87 font->hinting_range_min);
88 DUMPVAL("hint-composites",
89 font->hint_composites);
90 DUMPVAL("ignore-restrictions",
91 font->ignore_restrictions);
92 DUMPVAL("increase-x-height",
93 font->increase_x_height);
94 DUMPVAL("symbol",
95 font->symbol);
96 DUMPVAL("windows-compatibility",
97 font->windows_compatibility);
99 s = number_set_show(font->x_height_snapping_exceptions,
100 TA_PROP_INCREASE_X_HEIGHT_MIN, 0x7FFF);
101 if (!s)
102 return FT_Err_Out_Of_Memory;
104 DUMPSTR("x-height-snapping-exceptions", s);
105 free(s);
107 s = TA_deltas_show(font, deltas);
108 if (!s)
109 return FT_Err_Out_Of_Memory;
111 /* show delta exceptions data line by line */
112 if (!format)
114 eol = "";
115 prev_eol = "; \\\n";
118 token = strtok_r(s, "\n", &saveptr);
119 DUMPSTR("delta exceptions", token);
121 for (;;)
123 token = strtok_r(NULL, "\n", &saveptr);
124 if (!token)
125 break;
127 DUMPSTRX(token);
129 if (!format)
130 fprintf(stream, "\n");
132 free(s);
134 fprintf(stderr, "\n");
136 return TA_Err_Ok;
139 /* end of tadump.c */