Java iText7是否可以使用IVS(表意变化序列)显示字体?

Java iText7是否可以使用IVS(表意变化序列)显示字体?,java,itext7,Java,Itext7,我正在使用iText7(v7.1.1)创建PDF文件。 环境:java版本“1.7.0_45” 有关IVS(表意变化序列),请参见下文 示例代码见下文 import com.itextpdf.kernel.pdf.PdfDocument; import com.itextpdf.kernel.pdf.PdfWriter; import com.itextpdf.layout.Document; import com.itextpdf.layout.element.Table; import c

我正在使用iText7(v7.1.1)创建PDF文件。
环境:java版本“1.7.0_45”

有关IVS(表意变化序列),请参见下文

示例代码见下文

import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.io.font.PdfEncodings;
import java.io.File;

public class SimpleTableIVS {
    public static final String DEST = "SimpleTableIVS.pdf";

    public static void main(String[] args) throws Exception {
        File file = new File(DEST);
        new SimpleTableIVS().manipulatePdf(DEST);
    }

    protected void manipulatePdf(String dest) throws Exception {
        PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
        Document doc = new Document(pdfDoc);

        // UTF-8 encoding table and Unicode characters
        // http://www.utf8-chartable.com/unicode-utf8-table.pl?start=131072&unicodeinhtml=hex&htmlent=1
        // http://www.utf8-chartable.com/unicode-utf8-table.pl?start=33792&number=1024
        byte[] bUtfA = {(byte)0xd8, (byte)0x40, (byte)0xdc, (byte)0x0b}; // U+2000B [IVS:2000B_E0103]
        byte[] bUtfB = {(byte)0x84, (byte)0x5b};                         // U+845B, [IVS: 845B_E0103]

        // After Add "Ideographic Variation Selector"
        byte[] bUtfC = {(byte)0xdb, (byte)0x40, (byte)0xdd, (byte)0x01}; // U+E0101
        byte[] bUtfD = {(byte)0xdb, (byte)0x40, (byte)0xdd, (byte)0x02}; // U+E0102

        //PdfFont font = PdfFontFactory.createFont("C:/Windows/Fonts/msmincho.ttc,0", PdfEncodings.IDENTITY_H);
        //PdfFont font = PdfFontFactory.createFont("C:/Windows/Fonts/meiryo.ttc,0", PdfEncodings.IDENTITY_H);
        PdfFont font = PdfFontFactory.createFont("C:/Program Files/ipamjm/ipamjm.ttf", PdfEncodings.IDENTITY_H);

        String strUtfA = new String(bUtfA, "UTF-16");
        String strUtfB = new String(bUtfB, "UTF-16");
        String strUtfC = strUtfA + (new String(bUtfC, "UTF-16"));
        String strUtfD = strUtfB + (new String(bUtfD, "UTF-16"));

        Table table = new Table(4);
        table.addCell(new Paragraph("\u200d" + strUtfA).setFont(font).setFontSize(12)); 
        table.addCell(new Paragraph("\u200d" + strUtfB).setFont(font).setFontSize(12)); 
        table.addCell(new Paragraph("\u200d" + strUtfC).setFont(font).setFontSize(12)); 
        table.addCell(new Paragraph("\u200d" + strUtfD).setFont(font).setFontSize(12)); 
        doc.add(table);
        doc.close();
    }
}

不幸的是,目前iText中不支持表意文字变化序列。支持它是可行的,但不是很容易,因此目前不是最高优先事项


已经为此创建了一个内部开发票证,在下一个版本中实现此功能将非常好。

您是否正在使用pdfCalligraph附加组件?