summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-08 15:53:40 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-05-08 15:53:40 +0000
commitd89b9a1074ff2b8f7f9227d6e10a95808ef30129 (patch)
tree40c27c6f6b049c727961f9af478ef235240b6027 /src
parent2594050ffbc13156615d42b76baa38a0de06a322 (diff)
downloadttf2f-d89b9a1074ff2b8f7f9227d6e10a95808ef30129.tar.gz
ttf2f-d89b9a1074ff2b8f7f9227d6e10a95808ef30129.tar.bz2
API tidying
svn path=/trunk/tools/ttf2f/; revision=7445
Diffstat (limited to 'src')
-rw-r--r--src/cli.c2
-rw-r--r--src/encoding.c23
-rw-r--r--src/encoding.h9
3 files changed, 20 insertions, 14 deletions
diff --git a/src/cli.c b/src/cli.c
index 67bc3c7..1002a94 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
if ((err = write_outlines(argv[2], argv[2], glist, nglyphs,
metrics, progress)) != TTF2F_RESULT_OK) goto error_out;
- if ((err = write_encoding(argv[2], argv[2], glist, nglyphs,
+ if ((err = encoding_write(argv[2], argv[2], glist, nglyphs,
0, progress)) != TTF2F_RESULT_OK) goto error_out;
error_out:
diff --git a/src/encoding.c b/src/encoding.c
index 2cba386..2d56fee 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -7,7 +7,7 @@
#include "utils.h"
/**
- * Write font encoding file (UCS style sparse encoding)
+ * Write font encoding file
*
* \param savein Location to save in
* \param name The font name
@@ -16,8 +16,8 @@
* \param type File format to use - 0 = full; 1 = sparse
* \param callback Progress callback function
*/
-ttf2f_result write_encoding(const char *savein, const char *name,
- struct glyph *glyph_list, int list_size, int type,
+ttf2f_result encoding_write(const char *savein, const char *name,
+ struct glyph *glyph_list, int list_size, encoding_type type,
void (*callback)(int progress))
{
FILE *output;
@@ -32,7 +32,7 @@ ttf2f_result write_encoding(const char *savein, const char *name,
fprintf(output, "%% %sEncoding 1.00\n", name);
fprintf(output, "%% Encoding file for font '%s'\n\n", name);
- if (!type) {
+ if (type == ENCODING_TYPE_NORMAL) {
for (i = 0; i != 32; i++) {
fprintf(output, "/.notdef\n");
}
@@ -44,26 +44,27 @@ ttf2f_result write_encoding(const char *savein, const char *name,
callback(i * 100 / list_size);
ttf2f_poll(1);
- if (type) {
+ if (type == ENCODING_TYPE_SPARSE) {
if (g->name != 0) {
/* .notdef is implicit */
if (strcmp(g->name, ".notdef") == 0)
continue;
fprintf(output, "%4.4X;%s;COMMENT\n", i+32,
g->name);
- } else if (g->code != (unsigned int) -1)
+ } else if (g->code != (unsigned int) -1) {
fprintf(output, "%4.4X;uni%04X;COMMENT\n",
i+32, g->code);
- else
+ } else {
fprintf(output, "# Skipping %4.4X\n", i+32);
- }
- else {
+ }
+ } else {
if (g->name != 0) {
fprintf(output, "/%s\n", g->name);
- } else if (g->code != (unsigned int) -1)
+ } else if (g->code != (unsigned int) -1) {
fprintf(output, "/uni%4.4X\n", g->code);
- else
+ } else {
fprintf(output, "/.NotDef\n");
+ }
}
}
diff --git a/src/encoding.h b/src/encoding.h
index e99221e..49b4e29 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -3,10 +3,15 @@
#include "utils.h"
+typedef enum encoding_type {
+ ENCODING_TYPE_NORMAL,
+ ENCODING_TYPE_SPARSE
+} encoding_type;
+
struct glyph;
-ttf2f_result write_encoding(const char *savein, const char *name,
- struct glyph *glyph_list, int list_size, int type,
+ttf2f_result encoding_write(const char *savein, const char *name,
+ struct glyph *glyph_list, int list_size, encoding_type type,
void (*callback)(int progress));
#endif