diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-04 23:35:45 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-04 23:35:45 +0200 |
commit | 7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 (patch) | |
tree | b329db03bae14fca178add9909b78b050345c140 /pdf/pdf_type3.c | |
parent | efc46353676c27b24f2933dce78305796951a01e (diff) | |
download | mupdf-7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2.tar.xz |
Le Roi est mort, vive le Roi!
The run-together words are dead! Long live the underscores!
The postscript inspired naming convention of using all run-together
words has served us well, but it is now time for more readable code.
In this commit I have also added the sed script, rename.sed, that I used
to convert the source. Use it on your patches and application code.
Diffstat (limited to 'pdf/pdf_type3.c')
-rw-r--r-- | pdf/pdf_type3.c | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c index 9cc15596..4c22654b 100644 --- a/pdf/pdf_type3.c +++ b/pdf/pdf_type3.c @@ -2,12 +2,12 @@ #include "mupdf.h" fz_error -pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) +pdf_load_type3_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) { fz_error error; char buf[256]; char *estrings[256]; - pdf_fontdesc *fontdesc; + pdf_font_desc *fontdesc; fz_obj *encoding; fz_obj *widths; fz_obj *charprocs; @@ -17,91 +17,91 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj fz_rect bbox; fz_matrix matrix; - obj = fz_dictgets(dict, "Name"); - if (fz_isname(obj)) - fz_strlcpy(buf, fz_toname(obj), sizeof buf); + obj = fz_dict_gets(dict, "Name"); + if (fz_is_name(obj)) + fz_strlcpy(buf, fz_to_name(obj), sizeof buf); else sprintf(buf, "Unnamed-T3"); - fontdesc = pdf_newfontdesc(); + fontdesc = pdf_new_font_desc(); - pdf_logfont("load type3 font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc); - pdf_logfont("name %s\n", buf); + pdf_log_font("load type3 font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc); + pdf_log_font("name %s\n", buf); - obj = fz_dictgets(dict, "FontMatrix"); - matrix = pdf_tomatrix(obj); + obj = fz_dict_gets(dict, "FontMatrix"); + matrix = pdf_to_matrix(obj); - pdf_logfont("matrix [%g %g %g %g %g %g]\n", + pdf_log_font("matrix [%g %g %g %g %g %g]\n", matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); - obj = fz_dictgets(dict, "FontBBox"); - bbox = pdf_torect(obj); + obj = fz_dict_gets(dict, "FontBBox"); + bbox = pdf_to_rect(obj); - pdf_logfont("bbox [%g %g %g %g]\n", + pdf_log_font("bbox [%g %g %g %g]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1); - fontdesc->font = fz_newtype3font(buf, matrix); + fontdesc->font = fz_new_type3_font(buf, matrix); - fz_setfontbbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1); + fz_set_font_bbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1); /* Encoding */ for (i = 0; i < 256; i++) - estrings[i] = nil; + estrings[i] = NULL; - encoding = fz_dictgets(dict, "Encoding"); + encoding = fz_dict_gets(dict, "Encoding"); if (!encoding) { error = fz_throw("syntaxerror: Type3 font missing Encoding"); goto cleanup; } - if (fz_isname(encoding)) - pdf_loadencoding(estrings, fz_toname(encoding)); + if (fz_is_name(encoding)) + pdf_load_encoding(estrings, fz_to_name(encoding)); - if (fz_isdict(encoding)) + if (fz_is_dict(encoding)) { fz_obj *base, *diff, *item; - base = fz_dictgets(encoding, "BaseEncoding"); - if (fz_isname(base)) - pdf_loadencoding(estrings, fz_toname(base)); + base = fz_dict_gets(encoding, "BaseEncoding"); + if (fz_is_name(base)) + pdf_load_encoding(estrings, fz_to_name(base)); - diff = fz_dictgets(encoding, "Differences"); - if (fz_isarray(diff)) + diff = fz_dict_gets(encoding, "Differences"); + if (fz_is_array(diff)) { - n = fz_arraylen(diff); + n = fz_array_len(diff); k = 0; for (i = 0; i < n; i++) { - item = fz_arrayget(diff, i); - if (fz_isint(item)) - k = fz_toint(item); - if (fz_isname(item)) - estrings[k++] = fz_toname(item); + item = fz_array_get(diff, i); + if (fz_is_int(item)) + k = fz_to_int(item); + if (fz_is_name(item)) + estrings[k++] = fz_to_name(item); if (k < 0) k = 0; if (k > 255) k = 255; } } } - fontdesc->encoding = pdf_newidentitycmap(0, 1); + fontdesc->encoding = pdf_new_identity_cmap(0, 1); - error = pdf_loadtounicode(fontdesc, xref, estrings, nil, fz_dictgets(dict, "ToUnicode")); + error = pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); if (error) goto cleanup; /* Widths */ - pdf_setdefaulthmtx(fontdesc, 0); + pdf_set_default_hmtx(fontdesc, 0); - first = fz_toint(fz_dictgets(dict, "FirstChar")); - last = fz_toint(fz_dictgets(dict, "LastChar")); + first = fz_to_int(fz_dict_gets(dict, "FirstChar")); + last = fz_to_int(fz_dict_gets(dict, "LastChar")); - widths = fz_dictgets(dict, "Widths"); + widths = fz_dict_gets(dict, "Widths"); if (!widths) { error = fz_throw("syntaxerror: Type3 font missing Widths"); @@ -110,30 +110,30 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj for (i = first; i <= last; i++) { - float w = fz_toreal(fz_arrayget(widths, i - first)); + float w = fz_to_real(fz_array_get(widths, i - first)); w = fontdesc->font->t3matrix.a * w * 1000; fontdesc->font->t3widths[i] = w * 0.001f; - pdf_addhmtx(fontdesc, i, i, w); + pdf_add_hmtx(fontdesc, i, i, w); } - pdf_endhmtx(fontdesc); + pdf_end_hmtx(fontdesc); /* Resources -- inherit page resources if the font doesn't have its own */ - fontdesc->font->t3resources = fz_dictgets(dict, "Resources"); + fontdesc->font->t3resources = fz_dict_gets(dict, "Resources"); if (!fontdesc->font->t3resources) fontdesc->font->t3resources = rdb; if (fontdesc->font->t3resources) - fz_keepobj(fontdesc->font->t3resources); + fz_keep_obj(fontdesc->font->t3resources); if (!fontdesc->font->t3resources) fz_warn("no resource dictionary for type 3 font!"); fontdesc->font->t3xref = xref; - fontdesc->font->t3run = pdf_runglyph; + fontdesc->font->t3run = pdf_run_glyph; /* CharProcs */ - charprocs = fz_dictgets(dict, "CharProcs"); + charprocs = fz_dict_gets(dict, "CharProcs"); if (!charprocs) { error = fz_throw("syntaxerror: Type3 font missing CharProcs"); @@ -144,23 +144,23 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj { if (estrings[i]) { - obj = fz_dictgets(charprocs, estrings[i]); - if (pdf_isstream(xref, fz_tonum(obj), fz_togen(obj))) + obj = fz_dict_gets(charprocs, estrings[i]); + if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj))) { - error = pdf_loadstream(&fontdesc->font->t3procs[i], xref, fz_tonum(obj), fz_togen(obj)); + error = pdf_load_stream(&fontdesc->font->t3procs[i], xref, fz_to_num(obj), fz_to_gen(obj)); if (error) goto cleanup; } } } - pdf_logfont("}\n"); + pdf_log_font("}\n"); *fontdescp = fontdesc; return fz_okay; cleanup: - fz_dropfont(fontdesc->font); + fz_drop_font(fontdesc->font); fz_free(fontdesc); - return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } |