Java 类com.lowagie.text.pdf.FontSelector 实例源码

项目:itext2    文件:FontSelectionTest.java   
/**
 * Using FontSelector.
 */
@Test
public void main() throws Exception {
    // step 1
    Document document = new Document();
    // step 2
    PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fontselection.pdf"));
    // step 3
    document.open();
    // step 4
    String text = "This text is the first verse of \u275dThe Iliad\u275e. It's not polytonic as it should be "
            + "with \u2798 and \u279a entoation variants but that's all we have for now.\n\n"
            + "\u2766\u00a0\u00a0\u039c\u03b7\u03bd\u03b9\u03bd \u03b1\u03b5\u03b9\u03b4\u03b5, \u03b8\u03b5\u03b1, \u03a0\u03b7\u03bb\u03b7\u03b9\u03b1\u03b4\u03b5\u03c9 \u0391\u03c7\u03b9\u03bb\u03b7\u03bf\u03c2";
    FontSelector sel = new FontSelector();
    sel.addFont(new Font(Font.TIMES_ROMAN, 12));
    sel.addFont(new Font(Font.ZAPFDINGBATS, 12));
    sel.addFont(new Font(Font.SYMBOL, 12));
    Phrase ph = sel.process(text);
    document.add(new Paragraph(ph));
    // step 5
    document.close();

}
项目:PDFTestForAndroid    文件:FontSelection.java   
/**
 * Using FontSelector.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {
    try {
        // step 1
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "fontselection.pdf"));
        // step 3
        document.open();
        // step 4
        String text = "This text is the first verse of \u275dThe Iliad\u275e. It's not polytonic as it should be "
                + "with \u2798 and \u279a entoation variants but that's all we have for now.\n\n"
                + "\u2766\u00a0\u00a0\u039c\u03b7\u03bd\u03b9\u03bd \u03b1\u03b5\u03b9\u03b4\u03b5, \u03b8\u03b5\u03b1, \u03a0\u03b7\u03bb\u03b7\u03b9\u03b1\u03b4\u03b5\u03c9 \u0391\u03c7\u03b9\u03bb\u03b7\u03bf\u03c2";
        FontSelector sel = new FontSelector();
        sel.addFont(new Font(Font.TIMES_ROMAN, 12));
        sel.addFont(new Font(Font.ZAPFDINGBATS, 12));
        sel.addFont(new Font(Font.SYMBOL, 12));
        Phrase ph = sel.process(text);
        document.add(new Paragraph(ph));
        // step 5
        document.close();
    } catch (Exception de) {
        de.printStackTrace();
    }
}
项目:api-resolver    文件:ItextUtil.java   
public static FontSelector getFontSelector(float size, int style, Color color) {
    FontSelector selector = new FontSelector();
    selector.addFont(getCourierFont(size, style, color));
    selector.addFont(getChineseFont(size, style, color));
    return selector;
}