r7445 jmb - in /trunk/tools/ttf2f/src: cli.c encoding.c encoding.h

netsurf at semichrome.net netsurf at semichrome.net
Fri May 8 16:53:40 BST 2009


Author: jmb
Date: Fri May  8 10:53:40 2009
New Revision: 7445

URL: http://source.netsurf-browser.org?rev=7445&view=rev
Log:
API tidying

Modified:
    trunk/tools/ttf2f/src/cli.c
    trunk/tools/ttf2f/src/encoding.c
    trunk/tools/ttf2f/src/encoding.h

Modified: trunk/tools/ttf2f/src/cli.c
URL: http://source.netsurf-browser.org/trunk/tools/ttf2f/src/cli.c?rev=7445&r1=7444&r2=7445&view=diff
==============================================================================
--- trunk/tools/ttf2f/src/cli.c (original)
+++ trunk/tools/ttf2f/src/cli.c Fri May  8 10:53:40 2009
@@ -92,7 +92,7 @@
 	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:

Modified: trunk/tools/ttf2f/src/encoding.c
URL: http://source.netsurf-browser.org/trunk/tools/ttf2f/src/encoding.c?rev=7445&r1=7444&r2=7445&view=diff
==============================================================================
--- trunk/tools/ttf2f/src/encoding.c (original)
+++ trunk/tools/ttf2f/src/encoding.c Fri May  8 10:53:40 2009
@@ -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 @@
 	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 @@
 		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");
+			}
 		}
 	}
 

Modified: trunk/tools/ttf2f/src/encoding.h
URL: http://source.netsurf-browser.org/trunk/tools/ttf2f/src/encoding.h?rev=7445&r1=7444&r2=7445&view=diff
==============================================================================
--- trunk/tools/ttf2f/src/encoding.h (original)
+++ trunk/tools/ttf2f/src/encoding.h Fri May  8 10:53:40 2009
@@ -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




More information about the netsurf-commits mailing list