summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2005-12-24 21:37:22 (GMT)
committer John Mark Bell <jmb@netsurf-browser.org>2005-12-24 21:37:22 (GMT)
commit48ac730696ef6d89eda6fd8edcc6961004242b2a (patch)
treecb80974a5ff2197683c50e173a957b57b49812e3
parent731b0520fd4584d0dc47e77b231ee55887820b5e (diff)
downloadlibrufl-48ac730696ef6d89eda6fd8edcc6961004242b2a.tar.gz
librufl-48ac730696ef6d89eda6fd8edcc6961004242b2a.tar.bz2
[project @ 2005-12-24 21:37:22 by jmb]
Ignore fonts generated by RiScript (this may break if the user reconfigures RiScript's generated fonts location - we'll deal with that if it ever becomes an issue) Ignore TeX fonts. Ignore fonts with no Outlines data. svn path=/import/rufl/; revision=2466
-rw-r--r--rufl_init.c78
1 files changed, 66 insertions, 12 deletions
diff --git a/rufl_init.c b/rufl_init.c
index 0747100..1a6e051 100644
--- a/rufl_init.c
+++ b/rufl_init.c
@@ -15,6 +15,7 @@
#include <strings.h>
#include "oslib/font.h"
#include "oslib/hourglass.h"
+#include "oslib/osfscontrol.h"
#include "rufl_internal.h"
@@ -215,33 +216,86 @@ rufl_code rufl_init_font_list(void)
if (context2 == -1)
break;
- /* (re)allocate buffers */
- font_list = realloc(rufl_font_list, sizeof rufl_font_list[0] *
- (rufl_font_list_entries + 1));
- if (!font_list)
- return rufl_OUT_OF_MEMORY;
- rufl_font_list = font_list;
-
+ /* get next identifier */
identifier = malloc(size);
if (!identifier)
return rufl_OUT_OF_MEMORY;
- rufl_font_list[rufl_font_list_entries].identifier = identifier;
- rufl_font_list[rufl_font_list_entries].charset = 0;
- rufl_font_list[rufl_font_list_entries].umap = 0;
- rufl_font_list_entries++;
-
/* read identifier */
rufl_fm_error = xfont_list_fonts(identifier,
font_RETURN_FONT_NAME | context,
size, 0, 0, 0,
&context, 0, 0);
if (rufl_fm_error) {
+ free(identifier);
LOG("xfont_list_fonts: 0x%x: %s",
rufl_fm_error->errnum,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
+
+ /* Check that:
+ * a) it's got some Outlines data
+ * b) it's not a RiScript generated font
+ * c) it's not a TeX font
+ *
+ * If it's any of the above, we ignore it.
+ */
+ char pathname[size+6]; /* Fontname + ".Out*" + \0 */
+ snprintf(pathname, sizeof pathname, "%s.Out*", identifier);
+
+ /* Read required buffer size */
+ rufl_fm_error = xosfscontrol_canonicalise_path(pathname, 0,
+ "Font$Path", 0, 0, &size);
+ if (rufl_fm_error) {
+ free(identifier);
+ LOG("xosfscontrol_canonicalise_path: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
+ return rufl_FONT_MANAGER_ERROR;
+ }
+
+ /* size is -(space required - 1) so negate and add 1 */
+ size = -size + 1;
+
+ /* Create buffer and canonicalise path */
+ char fullpath[size];
+ rufl_fm_error = xosfscontrol_canonicalise_path(pathname,
+ fullpath, "Font$Path", 0, size, 0);
+ if (rufl_fm_error) {
+ free(identifier);
+ LOG("xosfscontrol_canonicalise_path: 0x%x: %s",
+ rufl_fm_error->errnum,
+ rufl_fm_error->errmess);
+ return rufl_FONT_MANAGER_ERROR;
+ }
+
+ /* LOG("%s (%c)", fullpath, fullpath[size - 2]); */
+
+ /* If the last character is an asterisk,
+ * there's no Outlines file. */
+ if (fullpath[size - 2] == '*' ||
+ strstr(fullpath, "!RiScript") ||
+ strstr(fullpath, "!TeXFonts")) {
+ /* Ignore this font */
+ free(identifier);
+ continue;
+ }
+
+ /* (re)allocate buffers */
+ font_list = realloc(rufl_font_list, sizeof rufl_font_list[0] *
+ (rufl_font_list_entries + 1));
+ if (!font_list) {
+ free(identifier);
+ return rufl_OUT_OF_MEMORY;
+ }
+ rufl_font_list = font_list;
+
+ rufl_font_list[rufl_font_list_entries].identifier = identifier;
+ rufl_font_list[rufl_font_list_entries].charset = 0;
+ rufl_font_list[rufl_font_list_entries].umap = 0;
+ rufl_font_list_entries++;
+
/*LOG("%u \"%s\"", rufl_font_list_entries - 1, identifier);*/
/* add family to list, if it is new */