typora / typora-issues

Bugs, suggestions or free discussions about the minimal markdown editor — Typora
https://typora.io
1.53k stars 58 forks source link

Chinese character incorrectly encoded when copied from generated PDF using 'Adobe Source Han' serif/sans font | 内置PDF导出含思源宋/黑字体时有特定字符无法正确复制 #6029

Open klizet opened 3 months ago

klizet commented 3 months ago

Describe the bug Some Chinese characters eg. '一'、'二' incorrectly encoded when copied from generated PDF using 'Adobe Source Han' serif/sans font.

To Reproduce Steps to reproduce the behavior:

  1. Modify some 3rd typora theme to specify the font to 'Adobe Source Han serif'/思源宋体 or 'Adobe Source Han sans'/思源黑体.
  2. Simply type in '一二三四五六七八九十'.
  3. Export as a pdf file.
  4. Copy the text in the pdf file, but the characters will change to '⼀⼆三四五六七⼋九⼗'. Note the characters '⼀⼆⼋⼗' are different from original inputs even they look similar.

Expected behavior Characters copied from the pdf should be exactly consistent with the original input.

Screenshots / Screencasts Omitted.

Sample Markdown File Omitted.

Desktop (please complete the following information):

Typora Version 1.8.10 in release channel.

Additional context

The issue is also discussed here but related to itext library or html2pdf program. https://www.v2ex.com/t/965813 (in Chinese) https://juejin.cn/post/6844903729439703053 (in Chinese)

This bug may be related to the upstream libraries of typora program. But, until this bug gets officially fixed, there are many ways to do a quick fix, for people who bothered.

abnerlee commented 3 months ago

Typora uses Chromium's built-in PDF generation method, so, if you export the md to html, open it in Chrome and print as PDF, does the same bug occur?

klizet commented 3 months ago

Sure, you are correct. This bug is reproduced by the edge browser. At the same time, the built-in 'Save as pdf' function of firefox, and the virtual pdf printer of windows 'Print as PDF' works well without any issue.

After checking the chromium issue tracker, I found it's related to the bug 41469265 but marked as fixed. I will re-issue this to the chromium maintainers some days later.

klizet commented 3 months ago

It can be traced into the skia library, a very low level infra of chromium here. Perhaps it WONT BE FIX in a short time. Sad.