Skip to content

Commit

Permalink
dvipdfm-x/dvi.c: ensure UTF16 prior to convert encoding to UTF16 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-tk committed May 11, 2024
1 parent 0c5a562 commit 2883bae
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/texk/dvipdfm-x/dvi.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ static unsigned lr_width_stack_depth = 0;
#define DVI 1
#define VF 2

#define ENC_UNICODE 1
#define ENC_UTF16 2

struct gm {
spt_t advance, ascent, descent;
};
Expand Down Expand Up @@ -1142,14 +1145,16 @@ dvi_locate_font (const char *tfm_name, spt_t ptsize)
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;
loaded_fonts[cur_id].padbytes[2] = (mrec->opt.mapc >> 8) & 0xff;
}
if (mrec->enc_name && !strcmp(mrec->enc_name, "unicode")) {
loaded_fonts[cur_id].is_unicode = 1;
loaded_fonts[cur_id].is_unicode = ENC_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;
}
} else if (mrec->enc_name && strstr(mrec->enc_name, "UTF16") != NULL) {
loaded_fonts[cur_id].is_unicode = ENC_UTF16;
}
}
loaded_fonts[cur_id].minbytes = pdf_dev_font_minbytes(font_id);
Expand Down Expand Up @@ -1473,7 +1478,7 @@ dvi_set (int32_t ch)
case PHYSICAL:
if (ch > 65535) {
/* FIXME: uptex specific undocumented */
if (!font->is_unicode && tfm_is_jfm(font->tfm_id)) {
if (font->is_unicode == ENC_UTF16 && tfm_is_jfm(font->tfm_id)) {
wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff;
wbuf[1] = UTF32toUTF16HS(ch) & 0xff;
wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff;
Expand Down Expand Up @@ -1564,7 +1569,7 @@ dvi_put (int32_t ch)
*/
if (ch > 65535) {
/* FIXME: uptex specific undocumented */
if (!font->is_unicode && tfm_is_jfm(font->tfm_id)) {
if (font->is_unicode == ENC_UTF16 && tfm_is_jfm(font->tfm_id)) {
wbuf[0] = (UTF32toUTF16HS(ch) >> 8) & 0xff;
wbuf[1] = UTF32toUTF16HS(ch) & 0xff;
wbuf[2] = (UTF32toUTF16LS(ch) >> 8) & 0xff;
Expand Down

0 comments on commit 2883bae

Please sign in to comment.