diff options
Diffstat (limited to 'pdf/pdf_fontfile.c')
-rw-r--r-- | pdf/pdf_fontfile.c | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c index 1fedae44..79eee737 100644 --- a/pdf/pdf_fontfile.c +++ b/pdf/pdf_fontfile.c @@ -37,15 +37,15 @@ extern const unsigned int pdf_font_DroidSansFallback_ttf_len; enum { - FD_FIXED = 1 << 0, + FD_FIXED_PITCH = 1 << 0, FD_SERIF = 1 << 1, FD_SYMBOLIC = 1 << 2, FD_SCRIPT = 1 << 3, FD_NONSYMBOLIC = 1 << 5, FD_ITALIC = 1 << 6, - FD_ALLCAP = 1 << 16, - FD_SMALLCAP = 1 << 17, - FD_FORCEBOLD = 1 << 18 + FD_ALL_CAP = 1 << 16, + FD_SMALL_CAP = 1 << 17, + FD_FORCE_BOLD = 1 << 18 }; enum { CNS, GB, Japan, Korea }; @@ -55,7 +55,7 @@ static const struct { const char *name; const unsigned char *cff; const unsigned int *len; -} basefonts[] = { +} base_fonts[] = { { "Courier", pdf_font_NimbusMonL_Regu_cff_buf, &pdf_font_NimbusMonL_Regu_cff_len }, @@ -98,30 +98,30 @@ static const struct { { "ZapfDingbats", pdf_font_Dingbats_cff_buf, &pdf_font_Dingbats_cff_len }, - { nil, nil, nil } + { NULL, NULL, NULL } }; fz_error -pdf_loadbuiltinfont(pdf_fontdesc *fontdesc, char *fontname) +pdf_load_builtin_font(pdf_font_desc *fontdesc, char *fontname) { fz_error error; unsigned char *data; unsigned int len; int i; - for (i = 0; basefonts[i].name; i++) - if (!strcmp(fontname, basefonts[i].name)) + for (i = 0; base_fonts[i].name; i++) + if (!strcmp(fontname, base_fonts[i].name)) goto found; return fz_throw("cannot find font: '%s'", fontname); found: - pdf_logfont("load builtin font %s\n", fontname); + pdf_log_font("load builtin font %s\n", fontname); - data = (unsigned char *) basefonts[i].cff; - len = *basefonts[i].len; + data = (unsigned char *) base_fonts[i].cff; + len = *base_fonts[i].len; - error = fz_newfontfrombuffer(&fontdesc->font, data, len, 0); + error = fz_new_font_from_memory(&fontdesc->font, data, len, 0); if (error) return fz_rethrow(error, "cannot load freetype font from buffer"); @@ -134,7 +134,7 @@ found: } static fz_error -loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) +load_system_cid_font(pdf_font_desc *fontdesc, int ros, int kind) { #ifndef NOCJK fz_error error; @@ -142,13 +142,13 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) We only have one builtin fallback font. We'd really like to have one for each combination of ROS and Kind. */ - pdf_logfont("loading builtin CJK font\n"); - error = fz_newfontfrombuffer(&fontdesc->font, + pdf_log_font("loading builtin CJK font\n"); + error = fz_new_font_from_memory(&fontdesc->font, (unsigned char *)pdf_font_DroidSansFallback_ttf_buf, pdf_font_DroidSansFallback_ttf_len, 0); if (error) return fz_rethrow(error, "cannot load builtin CJK font"); - fontdesc->font->ftsubstitute = 1; /* substitute font */ + fontdesc->font->ft_substitute = 1; /* substitute font */ return fz_okay; #else return fz_throw("no builtin CJK font file"); @@ -156,7 +156,7 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) } fz_error -pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) +pdf_load_system_font(pdf_font_desc *fontdesc, char *fontname, char *collection) { fz_error error; char *name; @@ -174,7 +174,7 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) if (strstr(fontname, "Oblique")) isitalic = 1; - if (fontdesc->flags & FD_FIXED) + if (fontdesc->flags & FD_FIXED_PITCH) isfixed = 1; if (fontdesc->flags & FD_SERIF) isserif = 1; @@ -182,10 +182,10 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) isitalic = 1; if (fontdesc->flags & FD_SCRIPT) isscript = 1; - if (fontdesc->flags & FD_FORCEBOLD) + if (fontdesc->flags & FD_FORCE_BOLD) isbold = 1; - pdf_logfont("fixed-%d serif-%d italic-%d script-%d bold-%d\n", + pdf_log_font("fixed-%d serif-%d italic-%d script-%d bold-%d\n", isfixed, isserif, isitalic, isscript, isbold); if (collection) @@ -198,15 +198,15 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) kind = GOTHIC; if (!strcmp(collection, "Adobe-CNS1")) - return loadsystemcidfont(fontdesc, CNS, kind); + return load_system_cid_font(fontdesc, CNS, kind); else if (!strcmp(collection, "Adobe-GB1")) - return loadsystemcidfont(fontdesc, GB, kind); + return load_system_cid_font(fontdesc, GB, kind); else if (!strcmp(collection, "Adobe-Japan1")) - return loadsystemcidfont(fontdesc, Japan, kind); + return load_system_cid_font(fontdesc, Japan, kind); else if (!strcmp(collection, "Adobe-Japan2")) - return loadsystemcidfont(fontdesc, Japan, kind); + return load_system_cid_font(fontdesc, Japan, kind); else if (!strcmp(collection, "Adobe-Korea1")) - return loadsystemcidfont(fontdesc, Korea, kind); + return load_system_cid_font(fontdesc, Korea, kind); fz_warn("unknown cid collection: %s", collection); } @@ -247,38 +247,38 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) } } - error = pdf_loadbuiltinfont(fontdesc, name); + error = pdf_load_builtin_font(fontdesc, name); if (error) return fz_throw("cannot load builtin substitute font: %s", name); /* it's a substitute font: override the metrics */ - fontdesc->font->ftsubstitute = 1; + fontdesc->font->ft_substitute = 1; return fz_okay; } fz_error -pdf_loadembeddedfont(pdf_fontdesc *fontdesc, pdf_xref *xref, fz_obj *stmref) +pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref) { fz_error error; fz_buffer *buf; - pdf_logfont("load embedded font\n"); + pdf_log_font("load embedded font\n"); - error = pdf_loadstream(&buf, xref, fz_tonum(stmref), fz_togen(stmref)); + error = pdf_load_stream(&buf, xref, fz_to_num(stmref), fz_to_gen(stmref)); if (error) - return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_tonum(stmref), fz_togen(stmref)); + return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref)); - error = fz_newfontfrombuffer(&fontdesc->font, buf->data, buf->len, 0); + error = fz_new_font_from_memory(&fontdesc->font, buf->data, buf->len, 0); if (error) { - fz_dropbuffer(buf); - return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_tonum(stmref), fz_togen(stmref)); + fz_drop_buffer(buf); + return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref)); } /* save the buffer so we can free it later */ - fontdesc->font->ftdata = buf->data; - fontdesc->font->ftsize = buf->len; + fontdesc->font->ft_data = buf->data; + fontdesc->font->ft_size = buf->len; fz_free(buf); /* only free the fz_buffer struct, not the contained data */ fontdesc->isembedded = 1; |