diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2021-09-03 11:26:43 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2021-09-09 12:02:08 +0100 |
commit | 245ae9816d7a970347df194d1ea9ebaedb18ee12 (patch) | |
tree | c71ad5d25ec267c737d91db43d0f955104843ad1 /pdf/pdf_font.c | |
parent | 3ccbae8583ddc2e1c53b0fdfae05e1a57e36ba01 (diff) | |
download | ghostpdl-245ae9816d7a970347df194d1ea9ebaedb18ee12.tar.gz |
gpdf: Build and use resource search path list
Also use the genericrsourcedir to find fonts.
gpdf: allow setting of FONTPATH param
gpdf/gs: Populate the pdfi search paths from the PS environment
Diffstat (limited to 'pdf/pdf_font.c')
-rw-r--r-- | pdf/pdf_font.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index 790126363..7fa8a4272 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -158,22 +158,19 @@ pdfi_open_CIDFont_substitute_file(pdf_context * ctx, pdf_dict *font_dict, pdf_di if (fallback == true) { char fontfname[gp_file_name_sizeof]; - const char *romfsprefix = "%rom%Resource/CIDFSubst/"; - const int romfsprefixlen = strlen(romfsprefix); + const char *fsprefix = "CIDFSubst/"; + const int fsprefixlen = strlen(fsprefix); const char *defcidfallack = "DroidSansFallback.ttf"; const int defcidfallacklen = strlen(defcidfallack); stream *s; code = 0; - memcpy(fontfname, romfsprefix, romfsprefixlen); - memcpy(fontfname + romfsprefixlen, defcidfallack, defcidfallacklen); - fontfname[romfsprefixlen + defcidfallacklen] = '\0'; + memcpy(fontfname, fsprefix, fsprefixlen); + memcpy(fontfname + fsprefixlen, defcidfallack, defcidfallacklen); + fontfname[fsprefixlen + defcidfallacklen] = '\0'; - s = sfopen(fontfname, "r", ctx->memory); - if (s == NULL) { - code = gs_note_error(gs_error_invalidfont); - } - else { + code = pdfi_open_resource_file(ctx, fontfname, strlen(fontfname), &s); + if (code >= 0) { sfseek(s, 0, SEEK_END); *buflen = sftell(s); sfseek(s, 0, SEEK_SET); @@ -332,8 +329,6 @@ pdfi_open_font_substitute_file(pdf_context *ctx, pdf_dict *font_dict, pdf_dict * { int code; char fontfname[gp_file_name_sizeof]; - const char *romfsprefix = "%rom%Resource/Font/"; - const int romfsprefixlen = strlen(romfsprefix); pdf_obj *basefont = NULL, *mapname; pdf_obj *fontname = NULL; stream *s; @@ -381,21 +376,18 @@ pdfi_open_font_substitute_file(pdf_context *ctx, pdf_dict *font_dict, pdf_dict * } if (mapname->type == PDF_NAME) { pdf_name *mname = (pdf_name *) mapname; - if (romfsprefixlen + mname->length + 1 < gp_file_name_sizeof) { - memcpy(fontfname, romfsprefix, romfsprefixlen); - memcpy(fontfname + romfsprefixlen, mname->data, mname->length); - fontfname[romfsprefixlen + mname->length] = '\0'; + if (mname->length + 1 < gp_file_name_sizeof) { + memcpy(fontfname, mname->data, mname->length); + fontfname[mname->length] = '\0'; } else { return_error(gs_error_invalidfileaccess); } } - s = sfopen(fontfname, "r", ctx->memory); - if (s == NULL) { - code = gs_note_error(gs_error_undefinedfilename); - } - else { + code = pdfi_open_font_file(ctx, fontfname, strlen(fontfname), &s); + if (code >= 0) { + gs_const_string fname; if (basefont) { dmprintf(ctx->memory, "Loading font "); pdfi_emprint_font_name(ctx, (pdf_name *)basefont); @@ -404,6 +396,11 @@ pdfi_open_font_substitute_file(pdf_context *ctx, pdf_dict *font_dict, pdf_dict * else { dmprintf(ctx->memory, "Loading nameless font from "); } + sfilename(s, &fname); + if (fname.size < gp_file_name_sizeof) { + memcpy(fontfname, fname.data, fname.size); + fontfname[fname.size] = '\0'; + } dmprintf1(ctx->memory, "%s.\n", fontfname); sfseek(s, 0, SEEK_END); @@ -1437,7 +1434,7 @@ int pdfi_init_font_directory(pdf_context *ctx) } /* Loads a (should be!) non-embedded font by name - Only currently works for the Type 1 font set from romfs. + Only currently works for Type 1 fonts set. */ int pdfi_load_font_by_name_string(pdf_context *ctx, const byte *fontname, size_t length, pdf_obj **ppdffont) |