Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctex: 增加 ApTeX/upTeX 支持 #159

Closed
leo-liu opened this issue Mar 16, 2015 · 13 comments
Closed

ctex: 增加 ApTeX/upTeX 支持 #159

leo-liu opened this issue Mar 16, 2015 · 13 comments
Assignees

Comments

@leo-liu
Copy link
Member

leo-liu commented Mar 16, 2015

Original issue 160 created by LeoLiu.PKU on 2014-08-31T02:19:14.000Z:

马起园近日会发布 Y&Y TeX 的改进版本,会加入 eTeX 和 pTeX 特性支持,成为一个可以原生处理中文的 TeX 引擎。

可以考虑到时候给 ctex 增加新的引擎支持。由于 pTeX 系的引擎中,日文与汉字字体选择处理、断行、标点 kerning 等都是自动完成的,所以可能并不需要太多设置,只要引入一个简单的字体配置文件即可。

PDF 输出后端采用的是 dvipdfmx,因此 special 兼容性问题推测应该不大。

此外,upTeX 也是原生支持 Unicode 的引擎,在中文机制上很相似,可以考虑也加入支持。

@leo-liu leo-liu self-assigned this Mar 16, 2015
@leo-liu
Copy link
Member Author

leo-liu commented Mar 16, 2015

Comment #1 originally posted by sobenlee on 2014-12-05T19:14:22.000Z:

json 功能被 pTeX-ng (20141206) 移除了,所以配置字体需要重复生成 JFM 和 VF。

upTeX 提供的 upschrm-h.vf 有 1.3 MB。如果要像 zhmCJK 那样提供字体设置接口的话,需要事先生成 JFM 和 VF。这个体积不容忽视。

@leo-liu
Copy link
Member Author

leo-liu commented Feb 28, 2016

upTeX/ApTeX 能直接支持直排这点确实不错。

现在的实现使用的是 upLaTeX 带的 upstsl-h/v.tfmupstht-h/v.tfm 这两个 JFM。按文件名似乎是分别对应于华文宋体与华文黑体。

从 uptftopl 转回的结果来看这两个 tfm 没有带标点压缩信息,而 upschrm-h/v.tfmupschgt-h/v.tfm 则有。

正常使用 ctex 包应该再加上楷体和仿宋体。所以说还是需要用 uppltotf 生成一些 JFM 文件。
JVF 文件不需要了?

@qinglee

@qinglee
Copy link
Member

qinglee commented Feb 29, 2016

upschrm-h/vupschgt-h/v 都是虚拟字体,包含了标点压缩信息。upTeX 应该是在虚拟字体 JVF 文件中调整标点符号的间距来实现标点压缩功能,所以 JVF 是必要的。

我也正打算写一个 upTeX 的字体选择宏包,提供类似 xeCJK 的设置方式,需要生成一些 JFM 和 JVF 备用,相当于 zhmCJK 在 MiKTeX 下的工作方式。我看了一下,如果为 GB、CNS、JIS 和 KS 这四种字符集各生产 32 个字体(包括横排和直排两种形式)大约需要 309 MB 的空间。如果不使用 set3(makejvf-3 选项),大概能省一多半空间。set3 是用来支持 SIP 的汉字的,比如 CJK Ext-B 这些。当然这些文件数据很多冗余,用 xz 能压缩到一百多 KB。

@leo-liu
Copy link
Member Author

leo-liu commented Feb 29, 2016

感觉空间还是太大了。zhmCJK 就没被发行版安装。
如果只是预先生成少量 jfm 就比较节省,只做宋黑仿楷还能更省一点。回头再问问马起园。

leo-liu added a commit that referenced this issue Apr 17, 2016
字体使用 zhmetrics-uptex 中的 JFM、JVF。
为 Windows 设置字体映射。

#159
leo-liu added a commit that referenced this issue Apr 17, 2016
在 Windows 下测试了 windowsnew, windowsold, founder, adobe, fandol 字体集。
未测试 ubuntu, mac 字体集。
#159
@leo-liu
Copy link
Member Author

leo-liu commented Apr 17, 2016

拿宋黑仿楷专门凑出 6 个固定字体来试了试,感觉对 upTeX 来说这样做还行。至少 windowsnew, founder, fandol 都还可以。
mac 字体集可能需要测试一下,@Liam0205
马起园打算将来给 ptex-ng 加直接读字体的功能,不过现在这个也可用。

zhmetrics-uptex 做法还比较粗糙。

@Liam0205
Copy link
Contributor

Mac 我今晚试试。

@Liam0205
Copy link
Contributor

分支下的 doc 编译报错?

(./ctex.ind

! Package multicol Error: Error saving partial page.

See the multicol package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.2  \begin{theindex}

The part of the page before the multicols environment was nearly full with
the result that starting the environment will produce an overfull page. Some
text may be lost! Please increase \premulticols either generally or for this
environment by specifying a suitable value in the second optional argument to
the multicols environment.

@Liam0205
Copy link
Contributor

\documentclass[fontset = mac]{ctexart}
\begin{document}
中文测试 {\bfseries 加粗} {\itshape 意大利} {\bfseries\itshape 加粗意大利}

\sffamily
中文测试 {\bfseries 加粗} {\itshape 意大利} {\bfseries\itshape 加粗意大利}

\ttfamily
中文测试 {\bfseries 加粗} {\itshape 意大利} {\bfseries\itshape 加粗意大利}
\end{document}

编译是没问题的,不过字体加载还有问题。

rmfamily 的黑体没加进来:
6

sffamily 和 ttfamily 则是 DVIPDFMx 报错:

ctex_test.dvi -> ctex_test.pdf
[1
dvipdfmx:warning: Removed 15 null character(s) from fontname --> STKaiti-SC-Bold
]
dvipdfmx:warning: No usable TrueType cmap table found for font "华文细黑.ttf".
dvipdfmx:warning: CID character collection for this font is set to "Adobe-GB1"
dvipdfmx:fatal: Cannot continue without this...

Output file removed.

@Liam0205
Copy link
Contributor

61775f4 fix 了粗体的问题。

@Liam0205
Copy link
Contributor

华文细黑、华文黑提、华文仿宋的问题,是 DVIPDFMx 的 bug。

参见:
https://github.com/clerkma/ptex-ng/blob/master/texk/libdpx/cidtype2.c#L597

@qinglee
Copy link
Member

qinglee commented Apr 18, 2016

文档编译错误的问题,帮助提示很清楚,增大 \premulticols 就好,doc 的索引环境用的是 \IndexMin

@Liam0205 Liam0205 changed the title ctex: 增加新的 Y&Y TeX 支持,或再加入 upTeX 支持 ctex: 增加 ApTeX/upTeX 支持 Apr 18, 2016
@leo-liu
Copy link
Member Author

leo-liu commented Apr 23, 2016

zhmetrics-uptex 作为单独一个包上传 CTAN 了。

ctex 的 upTeX 支持目前我测试问题不大(用 pkuthss 测试),如果没有问题可以合并到主分支了。

两点想法:

  • zhmetrics-uptex 限制 6 个字体虽然有点少,但基本够用。目前 windowsfounder 定义的隶书和幼圆在 upTeX 中没有做支持,但似乎可以复用 upschrmupschgt 来表示,不知道这样做如何?
  • ctex 对 upLaTeX 目前是和 pdfLaTeX 一样,生成了 jy2rm.fd 等 6 个字体定义文件。但这几个文件的内容其实与 ctex 耦合少,与 zhmetrics-uptex 耦合多,似乎应该划过去。或者直接在 ctex 包里面定义字体,不生成 .fd 文件。不知道怎么处理更好。

@leo-liu
Copy link
Member Author

leo-liu commented Apr 25, 2016

简单测试文件没什么大问题:

% !TeX encoding = UTF-8
% !TeX program = uplatex+dvipdfmx
\documentclass[fontset=windows]{ctexart}

\begin{document}

正文:“\textit{意大利}\textbf{粗体}”

\textsf{无衬线\textbf{粗体}}

\texttt{打字机}

{\songti 宋体:“\textbf{粗体}”}

{\heiti 黑体\textbf{粗体}}

{\kaishu 楷书\textbf{粗体}}

{\fangsong 仿宋\textbf{粗体}}

{\yahei 雅黑体\textbf{粗体}}

{\lishu 隶书} 

{\youyuan 幼圆}

\end{document}

测试结果

leo-liu added a commit that referenced this issue Apr 25, 2016
@leo-liu leo-liu closed this as completed Apr 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants