From faf344e834a7cad17cfc918355335d87bf80389e Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Fri, 2 Oct 2020 22:57:53 +0000 Subject: Simplify text handling. (S. Hirara) git-svn-id: svn://tug.org/texlive/trunk@56518 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/dvipdfm-x/ChangeLog | 10 ++ Build/source/texk/dvipdfm-x/cid.c | 9 +- Build/source/texk/dvipdfm-x/cid.h | 19 ++-- Build/source/texk/dvipdfm-x/cmap.c | 74 ++++++------- Build/source/texk/dvipdfm-x/configure | 22 ++-- Build/source/texk/dvipdfm-x/configure.ac | 2 +- Build/source/texk/dvipdfm-x/dvi.c | 176 ++++++++++++++++++------------- Build/source/texk/dvipdfm-x/mpost.c | 4 +- Build/source/texk/dvipdfm-x/pdfdev.c | 145 +++++-------------------- Build/source/texk/dvipdfm-x/pdfdev.h | 3 +- Build/source/texk/dvipdfm-x/pdffont.c | 38 +------ Build/source/texk/dvipdfm-x/pdffont.h | 2 +- 12 files changed, 210 insertions(+), 294 deletions(-) (limited to 'Build/source') diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index 32d6485d7aa..acaa933c820 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,13 @@ +2020-10-03 Shunsaku Hirata + + * cid.c, cid.h: Add "const" attribute to arguments fontmap_rec + and fmap_opt. + * cmap.c: Correct calculation of min-bytes and max-bytes. Fix + indentation. + * dvi.c, mpost.c, pdfdev.[ch], pdffont.[ch]: Simplify input + text handling. The "mapc" option is handled in dvi.c. + * configure.ac: Version 20201003. + 2020-09-26 Shunsaku Hirata * pdfobj.c: Fix a bug that the max number of indirect objects diff --git a/Build/source/texk/dvipdfm-x/cid.c b/Build/source/texk/dvipdfm-x/cid.c index bb3fb18604c..9935513ad3e 100644 --- a/Build/source/texk/dvipdfm-x/cid.c +++ b/Build/source/texk/dvipdfm-x/cid.c @@ -110,7 +110,7 @@ static struct { }; static void release_opt (cid_opt *opt); -static int get_cidsysinfo (CIDSysInfo *csi, const char *map_name, fontmap_opt *fmap_opt); +static int get_cidsysinfo (CIDSysInfo *csi, const char *map_name, const fontmap_opt *fmap_opt); int opt_flags_cidfont = 0; @@ -348,7 +348,8 @@ CIDFont_base_open (pdf_font *font, const char *name, cid_opt *opt) } int -pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt) +pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, + CIDSysInfo *cmap_csi, const fontmap_opt *fmap_opt) { int font_id = -1; pdf_font *font = NULL; @@ -419,7 +420,7 @@ pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, } int -pdf_font_open_cidfont (pdf_font *font, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt) +pdf_font_open_cidfont (pdf_font *font, const char *map_name, CIDSysInfo *cmap_csi, const fontmap_opt *fmap_opt) { cid_opt opt; int has_csi; @@ -513,7 +514,7 @@ release_opt (cid_opt *opt) } static int -get_cidsysinfo (CIDSysInfo *csi, const char *map_name, fontmap_opt *fmap_opt) +get_cidsysinfo (CIDSysInfo *csi, const char *map_name, const fontmap_opt *fmap_opt) { int has_csi = 0; int sup_idx; diff --git a/Build/source/texk/dvipdfm-x/cid.h b/Build/source/texk/dvipdfm-x/cid.h index 0e5457e0e54..ab33ca5b470 100644 --- a/Build/source/texk/dvipdfm-x/cid.h +++ b/Build/source/texk/dvipdfm-x/cid.h @@ -27,20 +27,21 @@ extern CIDSysInfo CSI_IDENTITY; extern CIDSysInfo CSI_UNICODE; extern int opt_flags_cidfont; -extern void CIDFont_set_flags (int flags); +extern void CIDFont_set_flags (int flags); #define CIDFONT_FORCE_FIXEDPITCH (1 << 1) -extern char *CIDFont_get_usedchars (pdf_font *font); -extern char *CIDFont_get_usedchars_v (pdf_font *font); +extern char *CIDFont_get_usedchars (pdf_font *font); +extern char *CIDFont_get_usedchars_v (pdf_font *font); -extern int CIDFont_is_ACCFont (pdf_font *font); -extern int CIDFont_is_UCSFont (pdf_font *font); +extern int CIDFont_is_ACCFont (pdf_font *font); +extern int CIDFont_is_UCSFont (pdf_font *font); #include "fontmap.h" -extern int pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt); - -extern int pdf_font_open_cidfont (pdf_font *font, const char *map_name, CIDSysInfo *cmap_csi, fontmap_opt *fmap_opt); -extern void pdf_font_load_cidfont (pdf_font *font); +extern int pdf_font_cidfont_lookup_cache (pdf_font *fonts, int count, const char *map_name, + CIDSysInfo *cmap_csi, const fontmap_opt *fmap_opt); +extern int pdf_font_open_cidfont (pdf_font *font, const char *map_name, + CIDSysInfo *cmap_csi, const fontmap_opt *fmap_opt); +extern void pdf_font_load_cidfont (pdf_font *font); #endif /* _CID_H_ */ diff --git a/Build/source/texk/dvipdfm-x/cmap.c b/Build/source/texk/dvipdfm-x/cmap.c index 477ba5ea89f..3884961e9a6 100644 --- a/Build/source/texk/dvipdfm-x/cmap.c +++ b/Build/source/texk/dvipdfm-x/cmap.c @@ -62,12 +62,12 @@ CMap_set_silent (int value) /* Private funcs. */ static int bytes_consumed (CMap *cmap, const unsigned char *instr, int inbytes); static void handle_undefined (CMap *cmap, - const unsigned char **inbuf, int *inbytesleft, - unsigned char **outbuf, int *outbytesleft); + const unsigned char **inbuf, int *inbytesleft, + unsigned char **outbuf, int *outbytesleft); static int check_range (CMap *cmap, - const unsigned char *srclo, const unsigned char *srchi, int srcdim, - const unsigned char *dst, int dstdim); + const unsigned char *srclo, const unsigned char *srchi, int srcdim, + const unsigned char *dst, int dstdim); static unsigned char *get_mem (CMap *cmap, int size); static mapDef *mapDef_new (void); @@ -86,10 +86,10 @@ CMap_new (void) cmap->useCMap = NULL; cmap->CSI = NULL; - cmap->profile.minBytesIn = 2; - cmap->profile.maxBytesIn = 2; - cmap->profile.minBytesOut = 2; - cmap->profile.maxBytesOut = 2; + cmap->profile.minBytesIn = 65535; + cmap->profile.maxBytesIn = 0; + cmap->profile.minBytesOut = 65535; + cmap->profile.maxBytesOut = 0; cmap->flags = 0; @@ -129,7 +129,7 @@ CMap_release (CMap *cmap) while (map != NULL) { mapData *prev = map->prev; if (map->data != NULL) - RELEASE(map->data); + RELEASE(map->data); RELEASE(map); map = prev; } @@ -171,9 +171,9 @@ CMap_is_valid (CMap *cmap) csi1 = CMap_get_CIDSysInfo(cmap); csi2 = CMap_get_CIDSysInfo(cmap->useCMap); if (strcmp(csi1->registry, csi2->registry) || - strcmp(csi1->ordering, csi2->ordering)) { + strcmp(csi1->ordering, csi2->ordering)) { WARN("CIDSystemInfo mismatched %s <--> %s", - CMap_get_name(cmap), CMap_get_name(cmap->useCMap)); + CMap_get_name(cmap), CMap_get_name(cmap->useCMap)); return 0; } } @@ -212,8 +212,8 @@ CMap_get_profile (CMap *cmap, int type) */ static void handle_undefined (CMap *cmap, - const unsigned char **inbuf, int *inbytesleft, - unsigned char **outbuf, int *outbytesleft) + const unsigned char **inbuf, int *inbytesleft, + unsigned char **outbuf, int *outbytesleft) { int len = 0; @@ -243,8 +243,8 @@ handle_undefined (CMap *cmap, void CMap_decode_char (CMap *cmap, - const unsigned char **inbuf, int *inbytesleft, - unsigned char **outbuf, int *outbytesleft) + const unsigned char **inbuf, int *inbytesleft, + unsigned char **outbuf, int *outbytesleft) { mapDef *t; const unsigned char *p, *save; @@ -318,9 +318,9 @@ CMap_decode_char (CMap *cmap, /* continue */ case MAP_IS_CID: case MAP_IS_CODE: if (*outbytesleft >= t[c].len) - memcpy(*outbuf, t[c].code, t[c].len); + memcpy(*outbuf, t[c].code, t[c].len); else - ERROR("%s: Buffer overflow.", CMAP_DEBUG_STR); + ERROR("%s: Buffer overflow.", CMAP_DEBUG_STR); *outbuf += t[c].len; *outbytesleft -= t[c].len; break; @@ -341,8 +341,8 @@ CMap_decode_char (CMap *cmap, */ int CMap_decode (CMap *cmap, - const unsigned char **inbuf, int *inbytesleft, - unsigned char **outbuf, int *outbytesleft) + const unsigned char **inbuf, int *inbytesleft, + unsigned char **outbuf, int *outbytesleft) { int count; @@ -445,7 +445,7 @@ CMap_set_usecmap (CMap *cmap, CMap *ucmap) if (cmap == ucmap) ERROR("%s: Identical CMap object cannot be used for usecmap CMap: 0x%p=0x%p", - CMAP_DEBUG_STR, cmap, ucmap); + CMAP_DEBUG_STR, cmap, ucmap); /* Check if ucmap have neccesary information. */ if (!CMap_is_valid(ucmap)) @@ -457,13 +457,13 @@ CMap_set_usecmap (CMap *cmap, CMap *ucmap) */ if (cmap->name && strcmp(cmap->name, ucmap->name) == 0) ERROR("%s: CMap refering itself not allowed: CMap %s --> %s", - CMAP_DEBUG_STR, cmap->name, ucmap->name); + CMAP_DEBUG_STR, cmap->name, ucmap->name); if (cmap->CSI && cmap->CSI->registry && cmap->CSI->ordering) { if (strcmp(cmap->CSI->registry, ucmap->CSI->registry) || - strcmp(cmap->CSI->ordering, ucmap->CSI->ordering)) + strcmp(cmap->CSI->ordering, ucmap->CSI->ordering)) ERROR("%s: CMap %s required by %s have different CSI.", - CMAP_DEBUG_STR, CMap_get_name(cmap), CMap_get_name(ucmap)); + CMAP_DEBUG_STR, CMap_get_name(cmap), CMap_get_name(ucmap)); } /* We must copy codespaceranges. */ @@ -488,7 +488,7 @@ CMap_match_codespace (CMap *cmap, const unsigned char *c, int dim) continue; for (pos = 0; pos < dim; pos++) { if (c[pos] > csr->codeHi[pos] || c[pos] < csr->codeLo[pos]) - break; + break; } if (pos == dim) return 0; /* Valid */ @@ -514,10 +514,10 @@ CMap_add_codespacerange (CMap *cmap, csr = cmap->codespace.ranges + i; for (j = 0; j < MIN(csr->dim, dim) && overlap; j++) { if ((codelo[j] >= csr->codeLo[j] && codelo[j] <= csr->codeHi[j]) || - (codehi[j] >= csr->codeLo[j] && codehi[j] <= csr->codeHi[j])) - overlap = 1; + (codehi[j] >= csr->codeLo[j] && codehi[j] <= csr->codeHi[j])) + overlap = 1; else - overlap = 0; + overlap = 0; } if (overlap) { WARN("Overlapping codespace found. (ingored)"); @@ -576,7 +576,7 @@ CMap_add_notdefrange (CMap *cmap, for (c = srclo[srcdim-1]; c <= srchi[srcdim-1]; c++) { if (MAP_DEFINED(cur[c].flag)) { if (!__silent) - WARN("Trying to redefine already defined code mapping. (ignored)"); + WARN("Trying to redefine already defined code mapping. (ignored)"); } else { cur[c].flag = (MAP_LOOKUP_END|MAP_IS_NOTDEF); cur[c].code = get_mem(cmap, 2); @@ -592,16 +592,16 @@ CMap_add_notdefrange (CMap *cmap, int CMap_add_bfchar (CMap *cmap, - const unsigned char *src, int srcdim, - const unsigned char *dst, int dstdim) + const unsigned char *src, int srcdim, + const unsigned char *dst, int dstdim) { return CMap_add_bfrange(cmap, src, src, srcdim, dst, dstdim); } int CMap_add_bfrange (CMap *cmap, - const unsigned char *srclo, const unsigned char *srchi, int srcdim, - const unsigned char *base, int dstdim) + const unsigned char *srclo, const unsigned char *srchi, int srcdim, + const unsigned char *base, int dstdim) { int c, last_byte, i; mapDef *cur; @@ -680,7 +680,7 @@ CMap_add_cidrange (CMap *cmap, for (c = srclo[srcdim-1]; c <= srchi[srcdim-1]; c++) { if (cur[c].flag != 0) { if (!__silent) - WARN("Trying to redefine already defined CID mapping. (ignored)"); + WARN("Trying to redefine already defined CID mapping. (ignored)"); } else { cur[c].flag = (MAP_LOOKUP_END|MAP_IS_CID); cur[c].len = 2; @@ -783,7 +783,7 @@ bytes_consumed (CMap *cmap, const unsigned char *instr, int inbytes) rangeDef *csr = cmap->codespace.ranges + i; for (pos = 0; pos < MIN(csr->dim, inbytes); pos++) { if (instr[pos] > csr->codeHi[pos] || instr[pos] < csr->codeLo[pos]) - break; + break; } if (pos == csr->dim) /* part of instr is totally valid in this codespace. */ return csr->dim; @@ -798,7 +798,7 @@ bytes_consumed (CMap *cmap, const unsigned char *instr, int inbytes) for (i = 0; i< cmap->codespace.num; i++) { rangeDef *csr = cmap->codespace.ranges + i; if (csr->dim > longest && csr->dim < bytesconsumed) - bytesconsumed = csr->dim; + bytesconsumed = csr->dim; } } @@ -807,8 +807,8 @@ bytes_consumed (CMap *cmap, const unsigned char *instr, int inbytes) static int check_range (CMap *cmap, - const unsigned char *srclo, const unsigned char *srchi, int srcdim, - const unsigned char *dst, int dstdim) + const unsigned char *srclo, const unsigned char *srchi, int srcdim, + const unsigned char *dst, int dstdim) { if ((srcdim < 1 || dstdim < 1) || (!srclo || !srchi || !dst) || diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure index 63314a88371..52ce64f95d2 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) 20200926. +# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20201003. # # 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='20200926' -PACKAGE_STRING='dvipdfm-x (TeX Live) 20200926' +PACKAGE_VERSION='20201003' +PACKAGE_STRING='dvipdfm-x (TeX Live) 20201003' 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) 20200926 to adapt to many kinds of systems. +\`configure' configures dvipdfm-x (TeX Live) 20201003 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) 20200926:";; + short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20201003:";; 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 20200926 +dvipdfm-x (TeX Live) configure 20201003 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 20200926, which was +It was created by dvipdfm-x (TeX Live) $as_me 20201003, 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='20200926' + VERSION='20201003' cat >>confdefs.h <<_ACEOF @@ -14746,7 +14746,7 @@ Usage: $0 [OPTIONS] Report bugs to ." lt_cl_version="\ -dvipdfm-x (TeX Live) config.lt 20200926 +dvipdfm-x (TeX Live) config.lt 20201003 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 20200926, which was +This file was extended by dvipdfm-x (TeX Live) $as_me 20201003, 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 20200926 +dvipdfm-x (TeX Live) config.status 20201003 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 fe6a3f0fc17..fe775d91625 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)], [20200926], [dvipdfmx@tug.org]) +AC_INIT([dvipdfm-x (TeX Live)], [20201003], [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 3dc94d440e1..0d5f75d7ba2 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -138,30 +138,34 @@ static unsigned lr_width_stack_depth = 0; 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 */ + 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 */ + /* 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; + int ascent; + int descent; unsigned unitsPerEm; cff_font *cffont; unsigned numGlyphs; - int layout_dir; - float extend; - float slant; - float embolden; + 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; @@ -176,23 +180,23 @@ need_more_fonts (unsigned n) static struct font_def { - int32_t tex_id; - spt_t point_size; - spt_t design_size; - char *font_name; - int font_id; /* index of _loaded_ font in loaded_fonts array */ - int used; - int native; /* boolean */ + int32_t tex_id; + spt_t point_size; + spt_t design_size; + char *font_name; + 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. */ uint32_t face_index; - int layout_dir; /* 1 = vertical, 0 = horizontal */ - int extend; - int slant; - int embolden; + int layout_dir; /* 1 = vertical, 0 = horizontal */ + int extend; + int slant; + int embolden; } *def_fonts = NULL; #define XDV_FLAG_VERTICAL 0x0100 @@ -836,7 +840,7 @@ set_string (spt_t xpos, { xpos -= compensation.x; ypos -= compensation.y; - pdf_dev_set_string(xpos, ypos, instr_ptr, instr_len, width, font_id, ctype); + pdf_dev_set_string(xpos, ypos, instr_ptr, instr_len, width, font_id); } static void @@ -1029,8 +1033,21 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize) } ERROR("Cannot proceed without .vf or \"physical\" font for PDF output..."); } - loaded_fonts[cur_id].type = PHYSICAL; - loaded_fonts[cur_id].font_id = font_id; + memset(loaded_fonts[cur_id].padbytes, 0, 4); + if (mrec) { + if (mrec->opt.mapc >= 0) { + loaded_fonts[cur_id].padbytes[2] = (mrec->opt.mapc >> 8) & 0xff; + } + if (mrec->enc_name && !strcmp(mrec->enc_name, "unicode")) { + if (mrec->opt.mapc >= 0) { + loaded_fonts[cur_id].padbytes[0] = (mrec->opt.mapc >> 24) & 0xff; + loaded_fonts[cur_id].padbytes[1] = (mrec->opt.mapc >> 16) & 0xff; + } + } + } + loaded_fonts[cur_id].minbytes = pdf_dev_font_minbytes(font_id); + loaded_fonts[cur_id].type = PHYSICAL; + loaded_fonts[cur_id].font_id = font_id; if (dpx_conf.verbose_level > 0) MESG(">"); @@ -1086,9 +1103,10 @@ dvi_locate_native_font (const char *filename, uint32_t index, memset(&loaded_fonts[cur_id], 0, sizeof (struct loaded_font)); - loaded_fonts[cur_id].font_id = pdf_dev_locate_font(fontmap_key, ptsize); - loaded_fonts[cur_id].size = ptsize; - loaded_fonts[cur_id].type = NATIVE; + loaded_fonts[cur_id].font_id = pdf_dev_locate_font(fontmap_key, ptsize); + 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); if (is_type1) { @@ -1260,6 +1278,7 @@ dvi_set (int32_t ch) struct loaded_font *font; spt_t width, height, depth; unsigned char wbuf[4]; + int cbytes = 1; if (current_font < 0) { ERROR("No font selected!"); @@ -1284,27 +1303,35 @@ dvi_set (int32_t ch) if (lr_mode == RTYPESETTING) dvi_right(width); /* Will actually move left */ + memcpy(wbuf, font->padbytes, 4); + cbytes = font->minbytes; switch (font->type) { case PHYSICAL: - if (ch > 65535) { /* _FIXME_ */ - wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff; - wbuf[1] = UTF32toUTF16HS(ch) & 0xff; - wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff; - wbuf[3] = UTF32toUTF16LS(ch) & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 4, width, font->font_id, 2); - } else if (ch > 255) { /* _FIXME_ */ - wbuf[0] = (ch >> 8) & 0xff; - wbuf[1] = ch & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 2, width, font->font_id, 2); + if (ch > 65535) { + /* FIXME: uptex specific undocumented */ + if (tfm_is_jfm(font->tfm_id)) { + wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff; + wbuf[1] = UTF32toUTF16HS(ch) & 0xff; + wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff; + wbuf[3] = UTF32toUTF16LS(ch) & 0xff; + } else { + wbuf[0] = (ch >> 24) & 0xff; + wbuf[1] = (ch >> 16) & 0xff; + wbuf[2] = (ch >> 8) & 0xff; + wbuf[3] = ch & 0xff; + } + cbytes = 4; + } else if (ch > 255) { + wbuf[2] = (ch >> 8) & 0xff; + wbuf[3] = ch & 0xff; } else if (font->subfont_id >= 0) { - unsigned short uch = lookup_sfd_record(font->subfont_id, (unsigned char) ch); - wbuf[0] = (uch >> 8) & 0xff; - wbuf[1] = uch & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 2, width, font->font_id, 2); + uint16_t uch = lookup_sfd_record(font->subfont_id, (unsigned char) ch); + wbuf[2] = (uch >> 8) & 0xff; + wbuf[3] = uch & 0xff; } else { - wbuf[0] = (unsigned char) ch; - set_string(dvi_state.h, -dvi_state.v, wbuf, 1, width, font->font_id, 1); + wbuf[3] = (unsigned char) ch; } + set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id, 0); if (dvi_is_tracking_boxes()) { pdf_rect rect; @@ -1338,6 +1365,7 @@ dvi_put (int32_t ch) struct loaded_font *font; spt_t width, height, depth; unsigned char wbuf[4]; + int cbytes = 1; if (current_font < 0) { ERROR("No font selected!"); @@ -1345,36 +1373,40 @@ dvi_put (int32_t ch) font = &loaded_fonts[current_font]; + memcpy(wbuf, font->padbytes, 4); + cbytes = font->minbytes; switch (font->type) { case PHYSICAL: width = tfm_get_fw_width(font->tfm_id, ch); - width = sqxfw(font->size, width); - + width = sqxfw(font->size, width); /* Treat a single character as a one byte string and use the * string routine. - */ + */ if (ch > 65535) { - /* FIXME: This is a private extension made by someone... */ - wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff; - wbuf[1] = UTF32toUTF16HS(ch) & 0xff; - wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff; - wbuf[3] = UTF32toUTF16LS(ch) & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 4, width, font->font_id, 2); - } else if (ch > 255) { /* _FIXME_ */ - wbuf[0] = (ch >> 8) & 0xff; - wbuf[1] = ch & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 2, width, font->font_id, 2); + /* FIXME: uptex specific undocumented */ + if (tfm_is_jfm(font->tfm_id)) { + wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff; + wbuf[1] = UTF32toUTF16HS(ch) & 0xff; + wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff; + wbuf[3] = UTF32toUTF16LS(ch) & 0xff; + } else { + wbuf[0] = (ch >> 24) & 0xff; + wbuf[1] = (ch >> 16) & 0xff; + wbuf[2] = (ch >> 8) & 0xff; + wbuf[3] = ch & 0xff; + } + cbytes = 4; + } else if (ch > 255) { + wbuf[2] = (ch >> 8) & 0xff; + wbuf[3] = ch & 0xff; } else if (font->subfont_id >= 0) { - unsigned int uch; - - uch = lookup_sfd_record(font->subfont_id, (unsigned char) ch); - wbuf[0] = (uch >> 8) & 0xff; - wbuf[1] = uch & 0xff; - set_string(dvi_state.h, -dvi_state.v, wbuf, 2, width, font->font_id, 2); + uint16_t uch = lookup_sfd_record(font->subfont_id, (unsigned char) ch); + wbuf[2] = (uch >> 8) & 0xff; + wbuf[3] = uch & 0xff; } else { - wbuf[0] = (unsigned char) ch; - set_string(dvi_state.h, -dvi_state.v, wbuf, 1, width, font->font_id, 1); + wbuf[3] = (unsigned char) ch; } + set_string(dvi_state.h, -dvi_state.v, wbuf + 4 - cbytes, cbytes, width, font->font_id, 0); if (dvi_is_tracking_boxes()) { pdf_rect rect; diff --git a/Build/source/texk/dvipdfm-x/mpost.c b/Build/source/texk/dvipdfm-x/mpost.c index 103273983bd..d2496176646 100644 --- a/Build/source/texk/dvipdfm-x/mpost.c +++ b/Build/source/texk/dvipdfm-x/mpost.c @@ -831,7 +831,7 @@ do_show (void) (spt_t)(cp.y * dev_unit_dviunit()), ustr, length * 2, (spt_t)(text_width*dev_unit_dviunit()), - font->font_id, 0); + font->font_id); RELEASE(ustr); } else { #define FWBASE ((double) (1<<20)) @@ -843,7 +843,7 @@ do_show (void) (spt_t)(cp.y * dev_unit_dviunit()), strptr, length, (spt_t)(text_width*dev_unit_dviunit()), - font->font_id, 0); + font->font_id); } if (pdf_dev_get_font_wmode(font->font_id)) { diff --git a/Build/source/texk/dvipdfm-x/pdfdev.c b/Build/source/texk/dvipdfm-x/pdfdev.c index dc56050c3ee..29980b5ade8 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.c +++ b/Build/source/texk/dvipdfm-x/pdfdev.c @@ -218,18 +218,6 @@ struct dev_font { double extend; double slant; double bold; /* Boldness prameter */ - - /* Compatibility */ - int mapc; /* Nasty workaround for Omega */ - - /* There are no font metric format supporting four-bytes - * charcter code. So we should provide an option to specify - * UCS group and plane. - */ - int ucs_group; - int ucs_plane; - - int is_unicode; }; /* @@ -924,77 +912,16 @@ pdf_dev_set_font (pdf_dev *p, int font_id) * used as the return value of handle_multibyte_string(): str_ptr can point these. */ static unsigned char sbuf0[FORMAT_BUF_SIZE]; -static unsigned char sbuf1[FORMAT_BUF_SIZE]; static int -handle_multibyte_string (struct dev_font *font, - const unsigned char **str_ptr, int *str_len, int ctype) +handle_multibyte_string (struct dev_font *font, const unsigned char **str_ptr, int *str_len) { const unsigned char *p; - int i, length; + int length; p = *str_ptr; length = *str_len; - /* _FIXME_ */ - if (font->is_unicode) { /* UCS-4 */ - if (ctype == 1) { - if (length * 4 >= FORMAT_BUF_SIZE) { - WARN("Too long string..."); - return -1; - } - for (i = 0; i < length; i++) { - sbuf1[i*4 ] = font->ucs_group; - sbuf1[i*4+1] = font->ucs_plane; - sbuf1[i*4+2] = '\0'; - sbuf1[i*4+3] = p[i]; - } - length *= 4; - } else if (ctype == 2) { - int len = 0; - - if (length * 2 >= FORMAT_BUF_SIZE) { - WARN("Too long string..."); - return -1; - } - for (i = 0; i < length; i += 2, len += 4) { - sbuf1[len ] = font->ucs_group; - if ((p[i] & 0xf8) == 0xd8) { - int c; - /* Check for valid surrogate pair. */ - if ((p[i] & 0xfc) != 0xd8 || i + 2 >= length || (p[i+2] & 0xfc) != 0xdc) { - WARN("Invalid surrogate p[%d]=%02X...", i, p[i]); - return -1; - } - c = (((p[i] & 0x03) << 10) | (p[i+1] << 2) | (p[i+2] & 0x03)) + 0x100; - sbuf1[len+1] = (c >> 8) & 0xff; - sbuf1[len+2] = c & 0xff; - i += 2; - } else { - sbuf1[len+1] = font->ucs_plane; - sbuf1[len+2] = p[i]; - } - sbuf1[len+3] = p[i+1]; - } - length = len; - } - p = sbuf1; - } else if (ctype == 1 && font->mapc >= 0) { - /* Omega workaround... - * Translate single-byte chars to double byte code space. - */ - if (length * 2 >= FORMAT_BUF_SIZE) { - WARN("Too long string..."); - return -1; - } - for (i = 0; i < length; i++) { - sbuf1[i*2 ] = (font->mapc & 0xff); - sbuf1[i*2+1] = p[i]; - } - length *= 2; - p = sbuf1; - } - /* * Font is double-byte font. Output is assumed to be 16-bit fixed length * encoding. @@ -1002,9 +929,9 @@ handle_multibyte_string (struct dev_font *font, */ if (font->enc_id >= 0) { const unsigned char *inbuf; - unsigned char *outbuf; - int inbytesleft, outbytesleft; - CMap *cmap; + unsigned char *outbuf; + int inbytesleft, outbytesleft; + CMap *cmap; cmap = CMap_cache_get(font->enc_id); inbuf = p; @@ -1012,8 +939,7 @@ handle_multibyte_string (struct dev_font *font, inbytesleft = length; outbytesleft = FORMAT_BUF_SIZE; - CMap_decode(cmap, - &inbuf, &inbytesleft, &outbuf, &outbytesleft); + CMap_decode(cmap, &inbuf, &inbytesleft, &outbuf, &outbytesleft); if (inbytesleft != 0) { WARN("CMap conversion failed. (%d bytes remains)", inbytesleft); return -1; @@ -1027,23 +953,9 @@ handle_multibyte_string (struct dev_font *font, return 0; } -/* - * ctype: - * -1 input string contains 2-byte Freetype glyph index values - * (XeTeX only) - * 0 byte-width of char can be variable and input string - * is properly encoded. - * n Single character cosumes n bytes in input string. - * - * _FIXME_ - * --> - * selectfont(font_name, point_size) and show_string(pos, string) - */ void pdf_dev_set_string (spt_t xpos, spt_t ypos, - const void *instr_ptr, int instr_len, - spt_t width, - int font_id, int ctype) + const void *instr_ptr, int instr_len, spt_t width, int font_id) { pdf_dev *p = current_device(); struct dev_font *font; @@ -1074,7 +986,7 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos, length = instr_len; if (font->format == PDF_FONTTYPE_COMPOSITE) { - if (handle_multibyte_string(font, &str_ptr, &length, ctype) < 0) { + if (handle_multibyte_string(font, &str_ptr, &length) < 0) { ERROR("Error in converting input string..."); return; } @@ -1451,33 +1363,10 @@ pdf_dev_locate_font (const char *font_name, spt_t ptsize) font->extend = 1.0; font->slant = 0.0; font->bold = 0.0; - font->mapc = -1; - font->is_unicode = 0; - font->ucs_group = 0; - font->ucs_plane = 0; - if (mrec) { font->extend = mrec->opt.extend; font->slant = mrec->opt.slant; font->bold = mrec->opt.bold; - if (mrec->opt.mapc >= 0) - font->mapc = (mrec->opt.mapc >> 8) & 0xff; - else { - font->mapc = -1; - } - if (mrec->enc_name && - !strcmp(mrec->enc_name, "unicode")) { - font->is_unicode = 1; - if (mrec->opt.mapc >= 0) { - font->ucs_group = (mrec->opt.mapc >> 24) & 0xff; - font->ucs_plane = (mrec->opt.mapc >> 16) & 0xff; - } else { - font->ucs_group = 0; - font->ucs_plane = 0; - } - } else { - font->is_unicode = 0; - } } return p->num_dev_fonts++; @@ -1940,3 +1829,21 @@ pdf_dev_get_font_wmode (int font_id) return 0; } + +int +pdf_dev_font_minbytes (int font_id) +{ + pdf_dev *p = current_device(); + struct dev_font *font; + int minbytes = 1; + + font = GET_FONT(p, font_id); + if (font && font->format == PDF_FONTTYPE_COMPOSITE) { + CMap *cmap; + + cmap = CMap_cache_get(font->enc_id); + minbytes = CMap_get_profile(cmap, CMAP_PROF_TYPE_INBYTES_MIN); + } + + return minbytes; +} diff --git a/Build/source/texk/dvipdfm-x/pdfdev.h b/Build/source/texk/dvipdfm-x/pdfdev.h index 86ae6ccffa7..7750e432b29 100644 --- a/Build/source/texk/dvipdfm-x/pdfdev.h +++ b/Build/source/texk/dvipdfm-x/pdfdev.h @@ -104,7 +104,7 @@ extern double dev_unit_dviunit (void); */ extern void pdf_dev_set_string (spt_t xpos, spt_t ypos, const void *instr_ptr, int instr_len, - spt_t text_width, int font_id, int ctype); + spt_t text_width, int font_id); extern void pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height); /* Place XObject: rect returned */ @@ -174,4 +174,5 @@ extern void graphics_mode (void); extern void pdf_dev_begin_actualtext (uint16_t *unicodes, int len); extern void pdf_dev_end_actualtext (void); +extern int pdf_dev_font_minbytes (int font_id); #endif /* _PDFDEV_H_ */ diff --git a/Build/source/texk/dvipdfm-x/pdffont.c b/Build/source/texk/dvipdfm-x/pdffont.c index e49763ca2f4..e282a7da58e 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.c +++ b/Build/source/texk/dvipdfm-x/pdffont.c @@ -689,37 +689,6 @@ pdf_font_findresource (const char *ident, double scale) return found ? font_id : -1; } -#if 1 -static void -compat_set_mapchar (int cmap_id, fontmap_rec *mrec) -{ - CMap *cmap; - int cmap_type, minbytes; - - cmap = CMap_cache_get(cmap_id); - cmap_type = CMap_get_type(cmap); - minbytes = CMap_get_profile(cmap, CMAP_PROF_TYPE_INBYTES_MIN); - - if (cmap_type != CMAP_TYPE_IDENTITY && - cmap_type != CMAP_TYPE_CODE_TO_CID && - cmap_type != CMAP_TYPE_TO_UNICODE) { - WARN("Only 16-bit encoding supported for output encoding."); - } - /* Turn on map option. */ - if (minbytes == 2 && mrec->opt.mapc < 0) { - if (dpx_conf.verbose_level > 0) { - MESG("\n"); - MESG("pdf_font>> Input encoding \"%s\" requires at least 2 bytes.\n", CMap_get_name(cmap)); - MESG("pdf_font>> The -m <00> option will be assumed for \"%s\".\n", mrec->font_name); - } - /* FIXME: The following code modifies mrec. */ - mrec->opt.mapc = 0; - } - - return; -} -#endif - static int create_font_alias (const char *ident, int font_id) { @@ -779,7 +748,7 @@ create_font_reencoded (const char *ident, int font_id, int cmap_id) } int -pdf_font_load_font (const char *ident, double font_scale, fontmap_rec *mrec) +pdf_font_load_font (const char *ident, double font_scale, const fontmap_rec *mrec) { int font_id = -1; pdf_font *font; @@ -831,11 +800,6 @@ pdf_font_load_font (const char *ident, double font_scale, fontmap_rec *mrec) } } else if (!strstr(mrec->enc_name, ".enc") || strstr(mrec->enc_name, ".cmap")) { cmap_id = CMap_cache_find(mrec->enc_name); -#if 1 - if (cmap_id >= 0) { - compat_set_mapchar(cmap_id, mrec); - } -#endif } if (cmap_id < 0) { encoding_id = pdf_encoding_findresource(mrec->enc_name); diff --git a/Build/source/texk/dvipdfm-x/pdffont.h b/Build/source/texk/dvipdfm-x/pdffont.h index 7d20f39eb1e..e0782e0e6e7 100644 --- a/Build/source/texk/dvipdfm-x/pdffont.h +++ b/Build/source/texk/dvipdfm-x/pdffont.h @@ -133,7 +133,7 @@ extern void pdf_close_fonts (void); * various optical sizes supported in the future. */ extern int pdf_font_findresource (const char *tex_name, double font_scale); -extern int pdf_font_load_font (const char *tex_name, double font_scale, fontmap_rec *mrec); +extern int pdf_font_load_font (const char *tex_name, double font_scale, const fontmap_rec *mrec); extern pdf_font *pdf_get_font_data (int font_id); -- cgit v1.2.3