X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=backend%2Fdvi%2Fmdvi-lib%2Fpk.c;h=08377e634b151b64dcb427911c6a9ce9b8d4345a;hb=74ba36be76a1d0e01cf5f7458dc1637f15c6f9c1;hp=48da0084445f5aad64c5a95274a6f4c197e8f87d;hpb=13a06349251874bd35d2f03c3fc93217cee749a2;p=evince.git diff --git a/backend/dvi/mdvi-lib/pk.c b/backend/dvi/mdvi-lib/pk.c index 48da0084..08377e63 100644 --- a/backend/dvi/mdvi-lib/pk.c +++ b/backend/dvi/mdvi-lib/pk.c @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* @@ -28,6 +28,7 @@ * - Made bitmap code much more efficient and compact. */ +#include #include #include #include @@ -306,7 +307,7 @@ static BITMAP *get_packed(FILE *p, int w, int h, int flags) paint = !paint; } if(row != h || inrow != w) { - error(_("Bad PK file: More bits than required\n")); + mdvi_error(_("Bad PK file: More bits than required\n")); bitmap_destroy(bm); return NULL; } @@ -359,8 +360,8 @@ static int pk_load_font(DviParams *unused, DviFont *font) /* get the checksum */ checksum = fuget4(p); if(checksum && font->checksum && font->checksum != checksum) { - warning(_("%s: checksum mismatch (expected %u, got %u)\n"), - font->fontname, font->checksum, checksum); + mdvi_warning(_("%s: checksum mismatch (expected %u, got %u)\n"), + font->fontname, font->checksum, checksum); } else if(!font->checksum) font->checksum = checksum; /* skip pixel per point ratios */ @@ -416,7 +417,7 @@ static int pk_load_font(DviParams *unused, DviFont *font) case PK_NOOP: break; case PK_PRE: - error(_("%s: unexpected preamble\n"), font->fontname); + mdvi_error(_("%s: unexpected preamble\n"), font->fontname); goto error; } } else { @@ -468,6 +469,15 @@ static int pk_load_font(DviParams *unused, DviFont *font) } if(feof(p)) break; + + /* Although the PK format support bigger char codes, + * XeTeX and other extended TeX engines support charcodes up to + * 65536, while normal TeX engine supports only charcode up to 255.*/ + if (cc < 0 || cc > 65536) { + mdvi_error (_("%s: unexpected charcode (%d)\n"), + font->fontname,cc); + goto error; + } if(cc < loc) loc = cc; if(cc > hic) @@ -499,19 +509,19 @@ static int pk_load_font(DviParams *unused, DviFont *font) } } if(flag_byte != PK_POST) { - error(_("%s: unexpected end of file (no postamble)\n"), - font->fontname); + mdvi_error(_("%s: unexpected end of file (no postamble)\n"), + font->fontname); goto error; } while((flag_byte = fuget1(p)) != EOF) { if(flag_byte != PK_NOOP) { - error(_("invalid PK file! (junk in postamble)\n")); + mdvi_error(_("invalid PK file! (junk in postamble)\n")); goto error; } } /* resize font char data */ - if(loc > 0 || hic < maxch-1) { + if(loc > 0 && hic < maxch-1) { memmove(font->chars, font->chars + loc, (hic - loc + 1) * sizeof(DviFontChar)); font->chars = xresize(font->chars, @@ -522,7 +532,7 @@ static int pk_load_font(DviParams *unused, DviFont *font) return 0; badpk: - error(_("%s: File corrupted, or not a PK file\n"), font->fontname); + mdvi_error(_("%s: File corrupted, or not a PK file\n"), font->fontname); error: mdvi_free(font->chars); font->chars = NULL;