summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-05-08 17:23:34 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2009-05-08 17:23:34 (GMT)
commit1d6597cff7cbd90c220553f168ff5eb8f8a3e648 (patch)
tree26b9698552c91cffffd798cea256d4a4ae31de28
parent5f8354856558a645fa8fddffe250ce81b8fb48d3 (diff)
downloadttf2f-1d6597cff7cbd90c220553f168ff5eb8f8a3e648.tar.gz
ttf2f-1d6597cff7cbd90c220553f168ff5eb8f8a3e648.tar.bz2
More tidying
svn path=/trunk/tools/ttf2f/; revision=7448
-rw-r--r--src/cli.c2
-rw-r--r--src/outlines.c148
-rw-r--r--src/outlines.h4
3 files changed, 86 insertions, 68 deletions
diff --git a/src/cli.c b/src/cli.c
index e61ea25..1be69c4 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
if ((err = intmetrics_write(argv[2], argv[2], glist, nglyphs,
metrics, progress)) != TTF2F_RESULT_OK) goto error_out;
- if ((err = write_outlines(argv[2], argv[2], glist, nglyphs,
+ if ((err = outlines_write(argv[2], argv[2], glist, nglyphs,
metrics, progress)) != TTF2F_RESULT_OK) goto error_out;
if ((err = encoding_write(argv[2], argv[2], glist, nglyphs,
diff --git a/src/outlines.c b/src/outlines.c
index a3a1fcd..8a0d0ec 100644
--- a/src/outlines.c
+++ b/src/outlines.c
@@ -13,7 +13,8 @@
#include "utils.h"
ttf2f_result write_chunk(FILE* file, int chunk_no,
- struct glyph *glyph_list, int list_size, unsigned int *out_chunk_size);
+ struct glyph *glyph_list, int list_size,
+ unsigned int *out_chunk_size);
/**
* Write the font outlines to file
@@ -24,9 +25,9 @@ ttf2f_result write_chunk(FILE* file, int chunk_no,
* \param list_size Size of glyph list
* \param metrics Global font metrics
*/
-ttf2f_result write_outlines(const char *savein, const char *name,
+ttf2f_result outlines_write(const char *savein, const char *name,
struct glyph *glyph_list, int list_size,
- struct font_metrics *metrics,
+ const struct font_metrics *metrics,
void (*callback)(int progress))
{
struct outlines_header header;
@@ -175,10 +176,11 @@ error_write:
* \param list_size Size of glyph list
* \return Size of this chunk, or 0 on failure
*/
-ttf2f_result write_chunk(FILE* file, int chunk_no, struct glyph *glyph_list,
- int list_size, unsigned int *out_chunk_size)
+ttf2f_result write_chunk(FILE* file, int chunk_no,
+ struct glyph *glyph_list, int list_size,
+ unsigned int *out_chunk_size)
{
- struct glyph *g;
+ const struct glyph *g;
struct chunk *chunk;
unsigned int chunk_size;
struct outline *o, *next;
@@ -247,65 +249,81 @@ ttf2f_result write_chunk(FILE* file, int chunk_no, struct glyph *glyph_list,
/* movement type */
switch (o->type) {
- case TERMINATE:
- /* end of outline */
- chunk = realloc((char*)chunk,
- chunk_size+1);
- if (chunk == NULL)
- return TTF2F_RESULT_NOMEM;
- *((char*)chunk+chunk_size-1) = 0;
- chunk_size += 1;
- break;
- case MOVE_TO:
- /* move to point */
- chunk = realloc((char*)chunk,
- chunk_size+4);
- if (chunk == NULL)
- return TTF2F_RESULT_NOMEM;
- /* id, no scaffold */
- *((char*)chunk+chunk_size-1) = 1;
- /* x, y */
- *((char*)chunk+chunk_size) = o->data.move_to.x & 0xFF;
- *((char*)chunk+chunk_size+1) = (((o->data.move_to.y << 4) & 0xF0) | ((o->data.move_to.x >> 8) & 0xF));
- *((char*)chunk+chunk_size+2) = (o->data.move_to.y >> 4) & 0xFF;
- chunk_size += 4;
- break;
- case LINE_TO:
- /* draw line to point */
- chunk = realloc((char*)chunk,
- chunk_size+4);
- if (chunk == NULL)
- return TTF2F_RESULT_NOMEM;
- /* id, no scaffold */
- *((char*)chunk+chunk_size-1) = 2;
- /* x, y */
- *((char*)chunk+chunk_size) = o->data.line_to.x & 0xFF;
- *((char*)chunk+chunk_size+1) = (((o->data.line_to.y << 4) & 0xF0) | ((o->data.line_to.x >> 8) & 0xF));
- *((char*)chunk+chunk_size+2) = (o->data.line_to.y >> 4) & 0xFF;
- chunk_size += 4;
- break;
- case CURVE:
- /* draw bezier curve to point */
- chunk = realloc((char*)chunk,
- chunk_size+10);
- if (chunk == NULL)
- return TTF2F_RESULT_NOMEM;
- /* id, no scaffold */
- *((char*)chunk+chunk_size-1) = 3;
- /* x1, y1 */
- *((char*)chunk+chunk_size) = o->data.curve.x1 & 0xFF;
- *((char*)chunk+chunk_size+1) = (((o->data.curve.y1 << 4) & 0xF0) | ((o->data.curve.x1 >> 8) & 0xF));
- *((char*)chunk+chunk_size+2) = (o->data.curve.y1 >> 4) & 0xFF;
- /* x2, y2 */
- *((char*)chunk+chunk_size+3) = o->data.curve.x2 & 0xFF;
- *((char*)chunk+chunk_size+4) = (((o->data.curve.y2 << 4) & 0xF0) | ((o->data.curve.x2 >> 8) & 0xF));
- *((char*)chunk+chunk_size+5) = (o->data.curve.y2 >> 4) & 0xFF;
- /* x3, y3 */
- *((char*)chunk+chunk_size+6) = o->data.curve.x3 & 0xFF;
- *((char*)chunk+chunk_size+7) = (((o->data.curve.y3 << 4) & 0xF0) | ((o->data.curve.x3 >> 8) & 0xF));
- *((char*)chunk+chunk_size+8) = (o->data.curve.y3 >> 4) & 0xFF;
- chunk_size += 10;
- break;
+ case TERMINATE:
+ /* end of outline */
+ chunk = realloc((char*)chunk, chunk_size + 1);
+ if (chunk == NULL)
+ return TTF2F_RESULT_NOMEM;
+ *((char*)chunk+chunk_size-1) = 0;
+ chunk_size += 1;
+ break;
+ case MOVE_TO:
+ /* move to point */
+ chunk = realloc((char*)chunk, chunk_size + 4);
+ if (chunk == NULL)
+ return TTF2F_RESULT_NOMEM;
+ /* id, no scaffold */
+ *((char*)chunk+chunk_size-1) = 1;
+ /* x, y */
+ *((char*)chunk+chunk_size) =
+ o->data.move_to.x & 0xFF;
+ *((char*)chunk+chunk_size+1) =
+ (((o->data.move_to.y << 4) & 0xF0) |
+ ((o->data.move_to.x >> 8) & 0xF));
+ *((char*)chunk+chunk_size+2) =
+ (o->data.move_to.y >> 4) & 0xFF;
+ chunk_size += 4;
+ break;
+ case LINE_TO:
+ /* draw line to point */
+ chunk = realloc((char*)chunk, chunk_size + 4);
+ if (chunk == NULL)
+ return TTF2F_RESULT_NOMEM;
+ /* id, no scaffold */
+ *((char*)chunk+chunk_size-1) = 2;
+ /* x, y */
+ *((char*)chunk+chunk_size) =
+ o->data.line_to.x & 0xFF;
+ *((char*)chunk+chunk_size+1) =
+ (((o->data.line_to.y << 4) & 0xF0) |
+ ((o->data.line_to.x >> 8) & 0xF));
+ *((char*)chunk+chunk_size+2) =
+ (o->data.line_to.y >> 4) & 0xFF;
+ chunk_size += 4;
+ break;
+ case CURVE:
+ /* draw bezier curve to point */
+ chunk = realloc((char*)chunk, chunk_size + 10);
+ if (chunk == NULL)
+ return TTF2F_RESULT_NOMEM;
+ /* id, no scaffold */
+ *((char*)chunk+chunk_size-1) = 3;
+ /* x1, y1 */
+ *((char*)chunk+chunk_size) =
+ o->data.curve.x1 & 0xFF;
+ *((char*)chunk+chunk_size+1) =
+ (((o->data.curve.y1 << 4) & 0xF0) |
+ ((o->data.curve.x1 >> 8) & 0xF));
+ *((char*)chunk+chunk_size+2) =
+ (o->data.curve.y1 >> 4) & 0xFF;
+ /* x2, y2 */
+ *((char*)chunk+chunk_size+3) =
+ o->data.curve.x2 & 0xFF;
+ *((char*)chunk+chunk_size+4) =
+ (((o->data.curve.y2 << 4) & 0xF0) |
+ ((o->data.curve.x2 >> 8) & 0xF));
+ *((char*)chunk+chunk_size+5) =
+ (o->data.curve.y2 >> 4) & 0xFF;
+ /* x3, y3 */
+ *((char*)chunk+chunk_size+6) =
+ o->data.curve.x3 & 0xFF;
+ *((char*)chunk+chunk_size+7) =
+ (((o->data.curve.y3 << 4) & 0xF0) |
+ ((o->data.curve.x3 >> 8) & 0xF));
+ *((char*)chunk+chunk_size+8) =
+ (o->data.curve.y3 >> 4) & 0xFF;
+ chunk_size += 10;
+ break;
}
next = o->next;
diff --git a/src/outlines.h b/src/outlines.h
index 51a6d1c..d849106 100644
--- a/src/outlines.h
+++ b/src/outlines.h
@@ -52,9 +52,9 @@ struct char_data {
struct glyph;
struct font_metrics;
-ttf2f_result write_outlines(const char *savein, const char *name,
+ttf2f_result outlines_write(const char *savein, const char *name,
struct glyph *glyph_list, int list_size,
- struct font_metrics *metrics,
+ const struct font_metrics *metrics,
void (*callback)(int progress));
#endif