org.docx4j.fonts.CJKToEnglish Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docx4j-core Show documentation
Show all versions of docx4j-core Show documentation
docx4j is a library which helps you to work with the Office Open
XML file format as used in docx
documents, pptx presentations, and xlsx spreadsheets.
package org.docx4j.fonts;
/**
* Certain fonts have CJK names in a docx.
* However, in Win 7 (English locale at least), the font names are in English.
* So this class translates the docx CJK font name to a physical font name.
*
* @author jharrop
*
*/
public class CJKToEnglish {
/**
* Convert a CJK font name (as used in docx) to an English font name
* (as used on Win 7, English locale at least).
*
* @param fontName
* @return
*/
public static String toEnglish(String fontName) {
// Special cases; there are more; see http://en.wikipedia.org/wiki/List_of_CJK_fonts
if (fontName.equals("MS ゴシック")) {
//
return "MS Gothic";
} else if (fontName.equals("MS 明朝")) {
return "MS Mincho";
} else if (fontName.equals("맑은 고딕")) {
//
return "Malgun Gothic";
} else if (fontName.equals("宋体")) {
//
return "SimSun";
} else if (fontName.equals("新細明體")) {
return "PMingLiU"; // according to http://zh.wikipedia.org/wiki/%E5%AE%8B%E4%BD%93
} else {
return null;
}
}
}