在Pdfkit上使用零宽度联接器

时间:2019-04-08 12:43:14

标签: javascript arabic-support node-pdfkit

answer表明,当我们想在阿拉伯语单词的中间添加html标签时,可以通过某种方式重新获得连接。参见示例:

body{
  font-size: 30px;
}
Without joiner:
<p>كت<span style="color: Red;">ب</span></p>

With joiner:
<p>كت&#x200d;<span style="color: Red;">ب</span></p>

因此,我想使用continued选项(见pdfkit)在this上实现此目标,例如:

var zwj = '\u200d';

var arabic = 'كتب';
doc.fillColor('green')
   .text(arabic.slice(2), {
     width: 465,
     continued: true
    }).text(zwj, {
        continued: true
    }).fillColor('red')
    .text(arabic.slice(0, 2));

结果是:

enter image description here

那么,我该如何实现呢? (顺便说一下,我使用的是pdfkit浏览器版本)

0 个答案:

没有答案
相关问题