summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-13 11:57:18 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-05-13 11:57:18 +0000
commit48d44fe3cc442f37fd155e2da99ca7cae8b3a673 (patch)
tree57e0b5b11b848389500d019fa252044ea72778b2
parent965377a4087fd77d9aa4ddcf5d6b2c9bd3ac656b (diff)
downloadttf2f-48d44fe3cc442f37fd155e2da99ca7cae8b3a673.tar.gz
ttf2f-48d44fe3cc442f37fd155e2da99ca7cae8b3a673.tar.bz2
Revert to DIR_SEP magic.
Fix toolbox frontend to initialise conversion context correctly. Append ,ff6 when not on RISC OS. svn path=/trunk/tools/ttf2f/; revision=7498
-rw-r--r--src/encoding.c2
-rw-r--r--src/intmetrics.c3
-rw-r--r--src/outlines.c2
-rw-r--r--src/toolbox.c24
-rw-r--r--src/utils.h16
5 files changed, 37 insertions, 10 deletions
diff --git a/src/encoding.c b/src/encoding.c
index 762e4c0..18220c8 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -27,7 +27,7 @@ ttf2f_result encoding_write(const char *savein, const char *name,
size_t i;
char out[1024];
- snprintf(out, 1024, "%s/Encoding", savein);
+ snprintf(out, 1024, "%s" DIR_SEP "Encoding", savein);
if ((output = fopen(out, "w+")) == NULL)
return TTF2F_RESULT_OPEN;
diff --git a/src/intmetrics.c b/src/intmetrics.c
index 87ee0bc..bc2d097 100644
--- a/src/intmetrics.c
+++ b/src/intmetrics.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -129,7 +130,7 @@ ttf2f_result intmetrics_write(const char *savein, const char *name,
/* No character map */
mapsize = 0;
- snprintf(out, 1024, "%s/IntMetrics", savein);
+ snprintf(out, 1024, "%s" DIR_SEP "IntMetrics" XXX_EXT, savein);
if ((output = fopen(out, "wb")) == NULL) {
free(xwidthtab);
return TTF2F_RESULT_OPEN;
diff --git a/src/outlines.c b/src/outlines.c
index 080a44b..962042c 100644
--- a/src/outlines.c
+++ b/src/outlines.c
@@ -66,7 +66,7 @@ ttf2f_result outlines_write(const char *savein, const char *name,
header.chunk_data.reserved[3] = 0;
header.chunk_data.reserved[4] = 0;
- snprintf(out, 1024, "%s/Outlines", savein);
+ snprintf(out, 1024, "%s" DIR_SEP "Outlines" XXX_EXT, savein);
if ((output = fopen(out, "wb") ) == NULL)
return TTF2F_RESULT_OPEN;
diff --git a/src/toolbox.c b/src/toolbox.c
index 683571d..55f46a2 100644
--- a/src/toolbox.c
+++ b/src/toolbox.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
+#include <unixlib/local.h>
#include <oslib/displayfield.h>
#include <oslib/osfile.h>
@@ -312,6 +313,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
converting = 1;
+ memset(&ctx, 0, sizeof(ttf2f_ctx));
+
/* get input file */
error = xdisplayfield_get_value(0, main_window, 0, ifilename, 256, 0);
if (error) {
@@ -385,7 +388,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
if (ctx.glyphs == NULL) {
close_font(ctx.face);
fprintf(stderr, "malloc failed\n");
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for glyphs");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -404,7 +408,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.glyphs);
close_font(ctx.face);
fprintf(stderr, "malloc failed\n");
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for metrics");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -416,7 +421,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.metrics);
free(ctx.glyphs);
close_font(ctx.face);
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for metrics data");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -448,7 +454,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.metrics);
free(ctx.glyphs);
close_font(ctx.face);
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for glyph names");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -473,7 +480,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.metrics);
free(ctx.glyphs);
close_font(ctx.face);
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for intmetrics (%d)", res);
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -492,7 +500,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.metrics);
free(ctx.glyphs);
close_font(ctx.face);
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for outlines");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
@@ -512,7 +521,8 @@ osbool convert_font(bits event_code, toolbox_action *event,
free(ctx.metrics);
free(ctx.glyphs);
close_font(ctx.face);
- snprintf(erblock.errmess, 252, "Insufficient memory");
+ snprintf(erblock.errmess, 252,
+ "Insufficient memory for encoding");
wimp_report_error(&erblock, 0x5, "TTF2f");
converting = 0;
return TRUE;
diff --git a/src/utils.h b/src/utils.h
index ec1b4db..76ffd6f 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -17,6 +17,22 @@
#define N_ELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
#endif
+#ifndef DIR_SEP
+#ifdef __riscos__
+#define DIR_SEP "."
+#else
+#define DIR_SEP "/"
+#endif
+#endif
+
+#ifndef XXX_EXT
+#ifdef __riscos__
+#define XXX_EXT ""
+#else
+#define XXX_EXT ",ff6"
+#endif
+#endif
+
typedef enum ttf2f_result {
TTF2F_RESULT_OK,
TTF2F_RESULT_NOMEM,