  	}
 @@ -235,7 +245,12 @@ pdf_load_substitute_cjk_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fon
  			fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find builtin CJK font");
- 
+
  		/* A glyph bbox cache is too big for CJK fonts. */
 +#ifndef NOBUILTINFONT
  		fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, index, 0);

+		free(data);
+#endif
 	}
 
 	if (!strcmp(clean_name, "Symbol") || !strcmp(clean_name, "ZapfDingbats"))
@@ -212,7 +217,12 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontnam
 		if (!data)
 			fz_throw(ctx, FZ_ERROR_GENERIC, "cannot find substitute font");
 
+#ifndef NOBUILTINFONT
 		fontdesc->font = fz_new_font_from_memory(ctx, fontname, data, len, 0, 1);
+#else

+{
+	*len = 0;
+	if (!strcmp("Courier", name)) {
+		return get_font_file("urw/NimbusMono-Regular.cff");
+	}
+	if (!strcmp("Courier-Bold", name)) {
+		return get_font_file("urw/NimbusMono-Bold.cff");
+	}
+	if (!strcmp("Courier-Oblique", name)) {
+		return get_font_file("urw/NimbusMono-Oblique.cff");
+	}
+	if (!strcmp("Courier-BoldOblique", name)) {
+		return get_font_file("urw/NimbusMono-BoldOblique.cff");
+	}
+	if (!strcmp("Helvetica", name)) {
+		return get_font_file("urw/NimbusSanL-Reg.cff");
+	}
+	if (!strcmp("Helvetica-Bold", name)) {
+		return get_font_file("urw/NimbusSanL-Bol.cff");
+	}
+	if (!strcmp("Helvetica-Oblique", name)) {
+		return get_font_file("urw/NimbusSanL-RegIta.cff");
+	}
+	if (!strcmp("Helvetica-BoldOblique", name)) {
+		return get_font_file("urw/NimbusSanL-BolIta.cff");
+	}
+	if (!strcmp("Times-Roman", name)) {
+		return get_font_file("urw/NimbusRomNo9L-Reg.cff");
+	}
+	if (!strcmp("Times-Bold", name)) {
+		return get_font_file("urw/NimbusRomNo9L-Med.cff");
+	}
+	if (!strcmp("Times-Italic", name)) {
+		return get_font_file("urw/NimbusRomNo9L-RegIta.cff");
+	}
+	if (!strcmp("Times-BoldItalic", name)) {
+		return get_font_file("urw/NimbusRomNo9L-MedIta.cff");
+	}
+	if (!strcmp("Symbol", name)) {
+		return get_font_file("urw/StandardSymL.cff");
