1 47 package com.lowagie.text.pdf; 48 49 import java.awt.Font ; 50 51 public class AsianFontMapper extends DefaultFontMapper { 52 53 public static final String ChineseSimplifiedFont = "STSong-Light"; 54 public static final String ChineseSimplifiedEncoding_H = "UniGB-UCS2-H"; 55 public static final String ChineseSimplifiedEncoding_V = "UniGB-UCS2-V"; 56 57 public static final String ChineseTraditionalFont_MHei = "MHei-Medium"; 58 public static final String ChineseTraditionalFont_MSung = "MSung-Light"; 59 public static final String ChineseTraditionalEncoding_H = "UniCNS-UCS2-H"; 60 public static final String ChineseTraditionalEncoding_V = "UniCNS-UCS2-V"; 61 62 public static final String JapaneseFont_Go = "HeiseiKakuGo-W5"; 63 public static final String JapaneseFont_Min = "HeiseiMin-W3"; 64 public static final String JapaneseEncoding_H = "UniJIS-UCS2-H"; 65 public static final String JapaneseEncoding_V = "UniJIS-UCS2-V"; 66 public static final String JapaneseEncoding_HW_H = "UniJIS-UCS2-HW-H"; 67 public static final String JapaneseEncoding_HW_V = "UniJIS-UCS2-HW-V"; 68 69 public static final String KoreanFont_GoThic = "HYGoThic-Medium"; 70 public static final String KoreanFont_SMyeongJo = "HYSMyeongJo-Medium"; 71 public static final String KoreanEncoding_H = "UniKS-UCS2-H"; 72 public static final String KoreanEncoding_V = "UniKS-UCS2-V"; 73 74 private final String defaultFont; 75 private final String encoding; 76 77 public AsianFontMapper(String font, String encoding) { 78 super(); 79 80 this.defaultFont = font; 81 this.encoding = encoding; 82 } 83 84 public BaseFont awtToPdf(Font font) { 85 try { 86 BaseFontParameters p = getBaseFontParameters(font.getFontName()); 87 if (p != null){ 88 return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb); 89 }else{ 90 return BaseFont.createFont(defaultFont, encoding, true); 91 } 92 } 93 catch (Exception e) { 94 e.printStackTrace(); 95 } 96 return null; 97 98 } 99 100 } 101 | Popular Tags |