當前位置: 首頁>>代碼示例>>Java>>正文


Java Font.COURIER屬性代碼示例

本文整理匯總了Java中com.lowagie.text.Font.COURIER屬性的典型用法代碼示例。如果您正苦於以下問題:Java Font.COURIER屬性的具體用法?Java Font.COURIER怎麽用?Java Font.COURIER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.lowagie.text.Font的用法示例。


在下文中一共展示了Font.COURIER屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setToDefaultFamily

/**
 * Sets the correct font name from the family name.
 * 
 * @param familyname The family name to set the name to.
 */
private void setToDefaultFamily(String familyname){
    switch (Font.getFamilyIndex(familyname)) {
        case Font.COURIER:
            this.fontName = "Courier";
            break;
        case Font.HELVETICA:
            this.fontName = "Arial";
            break;
        case Font.SYMBOL:
            this.fontName = "Symbol";
            this.charset = 2;
            break;
        case Font.TIMES_ROMAN:
            this.fontName = "Times New Roman";
            break;
        case Font.ZAPFDINGBATS:
            this.fontName = "Windings";
            break;
        default:
            this.fontName = familyname;
    }
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:27,代碼來源:RtfFont.java

示例2: main

/**
 * Generates a PDF file with the 14 standard Type 1 Fonts
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	// step 2:
	// we create a writer that listens to the document
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("StandardType1Fonts.pdf"));

	// step 3: we open the document
	document.open();
	// step 4:

	// the 14 standard fonts in PDF: do not use this Font constructor!
	// this is for demonstration purposes only, use FontFactory!
	Font[] fonts = new Font[14];
	fonts[0] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
	fonts[1] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC);
	fonts[2] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD);
	fonts[3] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC);
	fonts[4] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL);
	fonts[5] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC);
	fonts[6] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
	fonts[7] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC);
	fonts[8] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL);
	fonts[9] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC);
	fonts[10] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD);
	fonts[11] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC);
	fonts[12] = new Font(Font.SYMBOL);
	fonts[13] = new Font(Font.ZAPFDINGBATS);
	// add the content
	for (int i = 0; i < 14; i++) {
		document.add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
	}

	// step 5: we close the document
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:42,代碼來源:StandardType1FontsTest.java


注:本文中的com.lowagie.text.Font.COURIER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。