From b1ae90907e77f83b07155bebd78ced57b8554ac8 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Mon, 5 Oct 2020 21:05:09 +0000 Subject: Fix a bug that printing output file name is wrong. Simplify XeTeX font handling. (S. Hirata) git-svn-id: svn://tug.org/texlive/trunk@56558 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 8 ++ Build/source/texk/dvipdfm-x/configure | 22 +-- Build/source/texk/dvipdfm-x/configure.ac | 2 +- Build/source/texk/dvipdfm-x/dvi.c | 227 ++++++++++++++++--------------- Build/source/texk/dvipdfm-x/dvipdfmx.c | 6 +- 5 files changed, 141 insertions(+), 124 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 5e55227b88e..5107b89f967 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,11 @@ +2020-10-06 Shunsaku Hirata + + * dvipdfmx.c: Fix a bug that printing output file name is wrong. + * dvi.c: Change XeTeX font handling. Convert glyph metrics to + an internal format at load time. Don't interpret type1 + CharStrings again and again. + * configure.ac: Version 20201006. + 2020-10-05 Karl Berry * man/dvipdfmx.1: update date. diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure index 52ce64f95d2..8948d0a6d48 100755 --- a/Build/source/texk/dvipdfm-x/configure +++ b/Build/source/texk/dvipdfm-x/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201003. +# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201006. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dvipdfm-x (TeX Live)' PACKAGE_TARNAME='dvipdfm-x--tex-live-' -PACKAGE_VERSION='20201003' -PACKAGE_STRING='dvipdfm-x (TeX Live) 20201003' +PACKAGE_VERSION='20201006' +PACKAGE_STRING='dvipdfm-x (TeX Live) 20201006' PACKAGE_BUGREPORT='dvipdfmx@tug.org' PACKAGE_URL='' @@ -1350,7 +1350,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dvipdfm-x (TeX Live) 20201003 to adapt to many kinds of systems. +\`configure' configures dvipdfm-x (TeX Live) 20201006 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1421,7 +1421,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201003:";; + short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201006:";; esac cat <<\_ACEOF @@ -1551,7 +1551,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dvipdfm-x (TeX Live) configure 20201003 +dvipdfm-x (TeX Live) configure 20201006 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2390,7 +2390,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dvipdfm-x (TeX Live) $as_me 20201003, which was +It was created by dvipdfm-x (TeX Live) $as_me 20201006, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -8077,7 +8077,7 @@ fi # Define the identity of the package. PACKAGE='dvipdfm-x--tex-live-' - VERSION='20201003' + VERSION='20201006' cat >>confdefs.h <<_ACEOF @@ -14746,7 +14746,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -dvipdfm-x (TeX Live) config.lt 20201003 +dvipdfm-x (TeX Live) config.lt 20201006 configured by $0, generated by GNU Autoconf 2.69. Copyright (C) 2011 Free Software Foundation, Inc. @@ -16636,7 +16636,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dvipdfm-x (TeX Live) $as_me 20201003, which was +This file was extended by dvipdfm-x (TeX Live) $as_me 20201006, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -16706,7 +16706,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dvipdfm-x (TeX Live) config.status 20201003 +dvipdfm-x (TeX Live) config.status 20201006 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/Build/source/texk/dvipdfm-x/configure.ac b/Build/source/texk/dvipdfm-x/configure.ac index fe775d91625..477306a9492 100644 --- a/Build/source/texk/dvipdfm-x/configure.ac +++ b/Build/source/texk/dvipdfm-x/configure.ac @@ -8,7 +8,7 @@ dnl This file is free software; the copyright holder dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl -AC_INIT([dvipdfm-x (TeX Live)], [20201003], [dvipdfmx@tug.org]) +AC_INIT([dvipdfm-x (TeX Live)], [20201006], [dvipdfmx@tug.org]) AC_PREREQ([2.65]) AC_CONFIG_SRCDIR([agl.c]) AC_CONFIG_AUX_DIR([../../build-aux]) diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index 0d5f75d7ba2..2289e328070 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -136,36 +136,40 @@ static unsigned lr_width_stack_depth = 0; #define DVI 1 #define VF 2 +struct gm { + spt_t advance, ascent, descent; +}; + static struct loaded_font { - int type; /* Type is physical or virtual */ - int font_id; /* id returned by dev (for PHYSICAL fonts) - * or by vf module for (VIRTUAL fonts) - */ - int subfont_id; /* id returned by subfont_locate_font() */ - int tfm_id; - spt_t size; - int source; /* Source is either DVI or VF */ - uint32_t rgba_color; - uint8_t rgba_used; + int type; /* Type is physical or virtual */ + int font_id; /* id returned by dev (for PHYSICAL fonts) + * or by vf module for (VIRTUAL fonts) + */ + int subfont_id; /* id returned by subfont_locate_font() */ + int tfm_id; + spt_t size; + int source; /* Source is either DVI or VF */ + uint32_t rgba_color; + uint8_t rgba_used; /* Indicates that rgba_color is used or not. * It enables full range of opacity: 0-255. */ - int xgs_id; /* Transparency ExtGState */ - struct tt_longMetrics *hvmt; - int ascent; - int descent; - unsigned unitsPerEm; - cff_font *cffont; - unsigned numGlyphs; - int layout_dir; - - float extend; - float slant; - float embolden; - - int minbytes; - char padbytes[4]; + int xgs_id; /* Transparency ExtGState */ + + /* XeTeX requires glyph metrics */ + struct gm *gm; + int shift_gid; + uint16_t num_glyphs; + + int layout_dir; + + float extend; + float slant; + float embolden; + + int minbytes; + char padbytes[4]; } *loaded_fonts = NULL; static int num_loaded_fonts = 0, max_loaded_fonts = 0; @@ -184,14 +188,13 @@ static struct font_def spt_t point_size; spt_t design_size; char *font_name; - int font_id; /* index of _loaded_ font in loaded_fonts array */ + int font_id; /* index of _loaded_ font in loaded_fonts array */ int used; - int native; /* boolean */ - uint32_t rgba_color; /* only used for native fonts in XeTeX */ - uint8_t rgba_used; - /* Indicates that rgba_color is used or not. - * It enables full range of opacity: 0-255. - */ + int native; /* boolean */ + uint32_t rgba_color; /* only used for native fonts in XeTeX */ + uint8_t rgba_used; /* Indicates that rgba_color is used or not. + * It enables full range of opacity: 0-255. + */ uint32_t face_index; int layout_dir; /* 1 = vertical, 0 = horizontal */ int extend; @@ -835,8 +838,7 @@ set_string (spt_t xpos, const void *instr_ptr, int instr_len, spt_t width, - int font_id, - int ctype) + int font_id) { xpos -= compensation.x; ypos -= compensation.y; @@ -1070,10 +1072,7 @@ dvi_locate_native_font (const char *filename, uint32_t index, char *path; sfnt *sfont; ULONG offset = 0; - struct tt_head_table *head; - struct tt_maxp_table *maxp; - struct tt_hhea_table *hhea; - int is_dfont = 0, is_type1 = 0; + int is_dfont = 0, is_type1 = 0; if (dpx_conf.verbose_level > 0) MESG("<%s@%.2fpt", filename, ptsize * dvi2pts); @@ -1107,11 +1106,13 @@ dvi_locate_native_font (const char *filename, uint32_t index, loaded_fonts[cur_id].size = ptsize; loaded_fonts[cur_id].type = NATIVE; loaded_fonts[cur_id].minbytes = pdf_dev_font_minbytes(loaded_fonts[cur_id].font_id); - free(fontmap_key); + RELEASE(fontmap_key); if (is_type1) { cff_font *cffont; char *enc_vec[256]; + uint16_t num_glyphs; + int i; fp = DPXFOPEN(filename, DPX_RES_TYPE_T1FONT); if (!fp) @@ -1124,22 +1125,47 @@ dvi_locate_native_font (const char *filename, uint32_t index, cffont = t1_load_font(enc_vec, 0, fp); if (!cffont) ERROR("Failed to read Type 1 font \"%s\".", filename); - - loaded_fonts[cur_id].cffont = cffont; - - if (cff_dict_known(cffont->topdict, "FontBBox")) { - loaded_fonts[cur_id].ascent = cff_dict_get(cffont->topdict, "FontBBox", 3); - loaded_fonts[cur_id].descent = cff_dict_get(cffont->topdict, "FontBBox", 1); - } else { - loaded_fonts[cur_id].ascent = 690; - loaded_fonts[cur_id].descent = -190; + for (i = 0; i < 256; i++) { + if (enc_vec[i]) + RELEASE(enc_vec[i]); } - - loaded_fonts[cur_id].unitsPerEm = 1000; - loaded_fonts[cur_id].numGlyphs = cffont->num_glyphs; - + loaded_fonts[cur_id].shift_gid = cffont->is_notdef_notzero; + loaded_fonts[cur_id].num_glyphs = num_glyphs = cffont->num_glyphs; + loaded_fonts[cur_id].gm = NEW(num_glyphs + 1, struct gm); + for (i = 0; i < num_glyphs; i++) { + double advance, ascent, descent; + cff_index *cstrings = cffont->cstrings; + t1_ginfo gm; + uint16_t gid; + + /* If .notdef is not the 1st glyph in CharStrings, glyph_id given by + * FreeType should be increased by 1 + */ + gid = (cffont->is_notdef_notzero) ? i + 1 : i; + if (gid == num_glyphs) + break; + t1char_get_metrics(cstrings->data + cstrings->offset[gid] - 1, + cstrings->offset[gid + 1] - cstrings->offset[gid], + cffont->subrs[0], &gm); + + advance = layout_dir == 0 ? gm.wx : gm.wy; + ascent = gm.bbox.ury; + descent = gm.bbox.lly; + loaded_fonts[cur_id].gm[gid].advance = (spt_t) (ptsize * ((advance / 1000.0) * mrec->opt.extend)); + loaded_fonts[cur_id].gm[gid].ascent = (spt_t) (ptsize * ((ascent / 1000.0))); + loaded_fonts[cur_id].gm[gid].descent = (spt_t) (ptsize * ((descent / 1000.0))); + } + cff_close(cffont); DPXFCLOSE(fp); } else { + struct tt_head_table *head; + struct tt_maxp_table *maxp; + struct tt_hhea_table *hhea; + struct tt_longMetrics *gm; + spt_t ascent, descent; + uint16_t num_glyphs; + int i; + if (is_dfont) sfont = dfont_open(fp, index); else @@ -1148,36 +1174,46 @@ dvi_locate_native_font (const char *filename, uint32_t index, offset = ttc_read_offset(sfont, index); else if (sfont->type == SFNT_TYPE_DFONT) offset = sfont->offset; + sfnt_read_table_directory(sfont, offset); head = tt_read_head_table(sfont); maxp = tt_read_maxp_table(sfont); hhea = tt_read_hhea_table(sfont); - loaded_fonts[cur_id].ascent = hhea->ascent; - loaded_fonts[cur_id].descent = hhea->descent; - loaded_fonts[cur_id].unitsPerEm = head->unitsPerEm; - loaded_fonts[cur_id].numGlyphs = maxp->numGlyphs; + ascent = (spt_t) (ptsize * ((double) hhea->ascent / (double) head->unitsPerEm)); + descent = (spt_t) (ptsize * ((double) hhea->descent / (double) head->unitsPerEm)); + loaded_fonts[cur_id].num_glyphs = num_glyphs = maxp->numGlyphs; if (layout_dir == 1 && sfnt_find_table_pos(sfont, "vmtx") > 0) { struct tt_vhea_table *vhea = tt_read_vhea_table(sfont); sfnt_locate_table(sfont, "vmtx"); - loaded_fonts[cur_id].hvmt = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings); + gm = tt_read_longMetrics(sfont, maxp->numGlyphs, vhea->numOfLongVerMetrics, vhea->numOfExSideBearings); RELEASE(vhea); } else { sfnt_locate_table(sfont, "hmtx"); - loaded_fonts[cur_id].hvmt = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings); + gm = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numOfLongHorMetrics, hhea->numOfExSideBearings); } + if (!gm) + ERROR("Failed to read TrueType/OpenType glyph metrics table."); + loaded_fonts[cur_id].gm = NEW(num_glyphs, struct gm); + for (i = 0; i < num_glyphs; i++) { + loaded_fonts[cur_id].gm[i].advance = (spt_t) (ptsize * ((double) gm[i].advance / (double) head->unitsPerEm) * mrec->opt.extend); + loaded_fonts[cur_id].gm[i].ascent = ascent; + loaded_fonts[cur_id].gm[i].descent = descent; + + } + RELEASE(gm); RELEASE(hhea); RELEASE(maxp); RELEASE(head); sfnt_close(sfont); - fclose(fp); + DPXFCLOSE(fp); } - free(path); + RELEASE(path); loaded_fonts[cur_id].layout_dir = layout_dir; - loaded_fonts[cur_id].extend = mrec->opt.extend; - loaded_fonts[cur_id].slant = mrec->opt.slant; - loaded_fonts[cur_id].embolden = mrec->opt.bold; + loaded_fonts[cur_id].extend = mrec->opt.extend; + loaded_fonts[cur_id].slant = mrec->opt.slant; + loaded_fonts[cur_id].embolden = mrec->opt.bold; if (dpx_conf.verbose_level > 0) MESG(">"); @@ -1331,7 +1367,7 @@ dvi_set (int32_t ch) } else { wbuf[3] = (unsigned char) ch; } - set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id, 0); + set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id); if (dvi_is_tracking_boxes()) { pdf_rect rect; @@ -1406,7 +1442,7 @@ dvi_put (int32_t ch) } else { wbuf[3] = (unsigned char) ch; } - set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id, 0); + set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id); if (dvi_is_tracking_boxes()) { pdf_rect rect; @@ -1818,9 +1854,10 @@ static void do_glyphs (int do_actual_text) { struct loaded_font *font; - spt_t width, height, depth, *xloc, *yloc, glyph_width = 0; - unsigned char wbuf[2]; - unsigned int i, glyph_id, slen = 0; + spt_t width, height, depth, *xloc, *yloc; + unsigned char wbuf[2]; + int32_t i; + uint16_t glyph_id, slen = 0; if (current_font < 0) ERROR("No font selected!"); @@ -1889,47 +1926,24 @@ do_glyphs (int do_actual_text) } for (i = 0; i < slen; i++) { - glyph_id = get_buffered_unsigned_pair(); /* freetype glyph index */ - if (glyph_id < font->numGlyphs) { - unsigned advance; - double ascent = (double)font->ascent; - double descent = (double)font->descent; - - if (font->cffont) { - cff_index *cstrings = font->cffont->cstrings; - t1_ginfo gm; - - /* If .notdef is not the 1st glyph in CharStrings, glyph_id given by - FreeType should be increased by 1 */ - if (font->cffont->is_notdef_notzero) - glyph_id += 1; - - t1char_get_metrics(cstrings->data + cstrings->offset[glyph_id] - 1, - cstrings->offset[glyph_id + 1] - cstrings->offset[glyph_id], - font->cffont->subrs[0], &gm); - - advance = font->layout_dir == 0 ? gm.wx : gm.wy; - ascent = gm.bbox.ury; - descent = gm.bbox.lly; - } else { - advance = font->hvmt[glyph_id].advance; - } - - glyph_width = (double)font->size * (double)advance / (double)font->unitsPerEm; - glyph_width = glyph_width * font->extend; + spt_t advance = 0; + glyph_id = get_buffered_unsigned_pair(); /* freetype glyph index */ + if (glyph_id < font->num_glyphs) { + if (font->shift_gid) + glyph_id++; + advance = font->gm[glyph_id].advance; if (dvi_is_tracking_boxes()) { pdf_rect rect; - height = (double)font->size * ascent / (double)font->unitsPerEm; - depth = (double)font->size * -descent / (double)font->unitsPerEm; - calc_rect(&rect, dvi_state.h + xloc[i], -dvi_state.v - yloc[i], glyph_width, height, depth); + height = font->gm[glyph_id].ascent ; + depth = -font->gm[glyph_id].descent; + calc_rect(&rect, dvi_state.h + xloc[i], -dvi_state.v - yloc[i], advance, height, depth); pdf_doc_expand_box(&rect); } } - wbuf[0] = glyph_id >> 8; wbuf[1] = glyph_id & 0xff; - set_string(dvi_state.h + xloc[i], -dvi_state.v - yloc[i], wbuf, 2, glyph_width, font->font_id, -1); + set_string(dvi_state.h + xloc[i], -dvi_state.v - yloc[i], wbuf, 2, advance, font->font_id); } if (font->rgba_used == 1) { @@ -2260,15 +2274,10 @@ dvi_close (void) for (i = 0; i < num_loaded_fonts; i++) { - if (loaded_fonts[i].hvmt != NULL) - RELEASE(loaded_fonts[i].hvmt); - - loaded_fonts[i].hvmt = NULL; - - if (loaded_fonts[i].cffont != NULL) - cff_close(loaded_fonts[i].cffont); + if (loaded_fonts[i].gm != NULL) + RELEASE(loaded_fonts[i].gm); - loaded_fonts[i].cffont = NULL; + loaded_fonts[i].gm = NULL; } if (loaded_fonts) diff --git a/Build/source/texk/dvipdfm-x/dvipdfmx.c b/Build/source/texk/dvipdfm-x/dvipdfmx.c index 32c9acf8b14..c8c38ca45d5 100644 --- a/Build/source/texk/dvipdfm-x/dvipdfmx.c +++ b/Build/source/texk/dvipdfm-x/dvipdfmx.c @@ -1097,9 +1097,6 @@ main (int argc, char *argv[]) pdf_filename = NULL; } - MESG("%s -> %s\n", dvi_filename ? dvi_filename : "stdin", - pdf_filename ? pdf_filename : "stdout"); - if (dpx_conf.compat_mode == dpx_mode_mpost_mode) { x_offset = 0.0; y_offset = 0.0; @@ -1130,6 +1127,9 @@ main (int argc, char *argv[]) /* moved to here because image caching was not effective */ dpx_delete_old_cache(image_cache_life); + MESG("%s -> %s\n", dvi_filename ? dvi_filename : "stdin", + pdf_filename ? pdf_filename : "stdout"); + /* Setup Options */ settings.ver_major = pdf_version_major; settings.ver_minor = pdf_version_minor; -- cgit v1.2.3