Package com.itextpdf.io.font
Class CjkResourceLoader
- java.lang.Object
-
- com.itextpdf.io.font.CjkResourceLoader
-
public final class CjkResourceLoader extends java.lang.ObjectThis class is responsible for loading and handling CJK fonts and CMaps from font-asian package.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>allCidFontsprivate static java.lang.StringCJK_REGISTRY_FILENAMEprivate static CMapLocationResourcecmapLocationprivate static java.lang.StringFONTS_PROPprivate static java.lang.StringREGISTRY_PROPprivate static java.util.Map<java.lang.String,java.util.Set<java.lang.String>>registryNamesprivate static java.lang.StringW_PROPprivate static java.lang.StringW2_PROP
-
Constructor Summary
Constructors Modifier Constructor Description privateCjkResourceLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static IntHashtablecreateMetric(java.lang.String s)static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>getAllPredefinedCidFonts()Get all loaded predefined CID fonts.static CMapByteCidgetByte2CidCmap(java.lang.String cmap)Parses CMap with a given name producing it in a form of byte to cid mapping.static CMapCidUnigetCid2UniCmap(java.lang.String uniMap)Parses CMap with a given name producing it in a form of cid to unicode mapping.static CMapCidToCodepointgetCidToCodepointCmap(java.lang.String cmap)Parses CMap with a given name producing it in a form of cid to code point mapping.static CMapCodepointToCidgetCodepointToCidCmap(java.lang.String uniMap)Parses CMap with a given name producing it in a form of code point to cid mapping.static java.lang.StringgetCompatibleCidFont(java.lang.String cmap)Finds a CJK font family which is compatible to the given CMap.static java.util.Set<java.lang.String>getCompatibleCmaps(java.lang.String fontName)Finds all CMap names that belong to the same registry to which a given font belongs.static java.util.Map<java.lang.String,java.util.Set<java.lang.String>>getRegistryNames()Get all loaded CJK registry names mapped to a set of compatible cmaps.static CMapUniCidgetUni2CidCmap(java.lang.String uniMap)Parses CMap with a given name producing it in a form of unicode to cid mapping.static booleanisPredefinedCidFont(java.lang.String fontName)Checks if the font with the given name and encoding is one of the predefined CID fonts.private static voidloadRegistry()private static <T extends AbstractCMap>
TparseCmap(java.lang.String name, T cmap)private static java.util.Map<java.lang.String,java.lang.Object>readFontProperties(java.lang.String name)(package private) static voidsetCmapLocation(CMapLocationResource cmapLocation)
-
-
-
Field Detail
-
allCidFonts
private static final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> allCidFonts
-
registryNames
private static final java.util.Map<java.lang.String,java.util.Set<java.lang.String>> registryNames
-
CJK_REGISTRY_FILENAME
private static final java.lang.String CJK_REGISTRY_FILENAME
- See Also:
- Constant Field Values
-
FONTS_PROP
private static final java.lang.String FONTS_PROP
- See Also:
- Constant Field Values
-
REGISTRY_PROP
private static final java.lang.String REGISTRY_PROP
- See Also:
- Constant Field Values
-
W_PROP
private static final java.lang.String W_PROP
- See Also:
- Constant Field Values
-
W2_PROP
private static final java.lang.String W2_PROP
- See Also:
- Constant Field Values
-
cmapLocation
private static CMapLocationResource cmapLocation
-
-
Method Detail
-
isPredefinedCidFont
public static boolean isPredefinedCidFont(java.lang.String fontName)
Checks if the font with the given name and encoding is one of the predefined CID fonts.- Parameters:
fontName- the font name.- Returns:
trueif it is CJKFont.
-
getCompatibleCidFont
public static java.lang.String getCompatibleCidFont(java.lang.String cmap)
Finds a CJK font family which is compatible to the given CMap.- Parameters:
cmap- a name of the CMap for which compatible font is searched.- Returns:
- a CJK font name if there's known compatible font for the given cmap name, or null otherwise.
-
getCompatibleCmaps
public static java.util.Set<java.lang.String> getCompatibleCmaps(java.lang.String fontName)
Finds all CMap names that belong to the same registry to which a given font belongs.- Parameters:
fontName- a name of the font for which CMap's are searched.- Returns:
- a set of CMap names corresponding to the given font.
-
getAllPredefinedCidFonts
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> getAllPredefinedCidFonts()
Get all loaded predefined CID fonts.- Returns:
- predefined CID fonts.
-
getRegistryNames
public static java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getRegistryNames()
Get all loaded CJK registry names mapped to a set of compatible cmaps.- Returns:
- CJK registry names mapped to a set of compatible cmaps.
-
getCid2UniCmap
public static CMapCidUni getCid2UniCmap(java.lang.String uniMap)
Parses CMap with a given name producing it in a form of cid to unicode mapping.- Parameters:
uniMap- a CMap name. It is expected that CMap identified by this name defines unicode to cid mapping.- Returns:
- an object for convenient mapping from cid to unicode. If no CMap was found for provided name an exception is thrown.
-
getUni2CidCmap
public static CMapUniCid getUni2CidCmap(java.lang.String uniMap)
Parses CMap with a given name producing it in a form of unicode to cid mapping.- Parameters:
uniMap- a CMap name. It is expected that CMap identified by this name defines unicode to cid mapping.- Returns:
- an object for convenient mapping from unicode to cid. If no CMap was found for provided name an exception is thrown.
-
getByte2CidCmap
public static CMapByteCid getByte2CidCmap(java.lang.String cmap)
Parses CMap with a given name producing it in a form of byte to cid mapping.- Parameters:
cmap- a CMap name. It is expected that CMap identified by this name defines byte to cid mapping.- Returns:
- an object for convenient mapping from byte to cid. If no CMap was found for provided name an exception is thrown.
-
getCidToCodepointCmap
public static CMapCidToCodepoint getCidToCodepointCmap(java.lang.String cmap)
Parses CMap with a given name producing it in a form of cid to code point mapping.- Parameters:
cmap- a CMap name. It is expected that CMap identified by this name defines code point to cid mapping.- Returns:
- an object for convenient mapping from cid to code point. If no CMap was found for provided name an exception is thrown.
-
getCodepointToCidCmap
public static CMapCodepointToCid getCodepointToCidCmap(java.lang.String uniMap)
Parses CMap with a given name producing it in a form of code point to cid mapping.- Parameters:
uniMap- a CMap name. It is expected that CMap identified by this name defines code point to cid mapping.- Returns:
- an object for convenient mapping from code point to cid. If no CMap was found for provided name an exception is thrown.
-
setCmapLocation
static void setCmapLocation(CMapLocationResource cmapLocation)
-
loadRegistry
private static void loadRegistry() throws java.io.IOException- Throws:
java.io.IOException
-
readFontProperties
private static java.util.Map<java.lang.String,java.lang.Object> readFontProperties(java.lang.String name) throws java.io.IOException- Throws:
java.io.IOException
-
createMetric
private static IntHashtable createMetric(java.lang.String s)
-
parseCmap
private static <T extends AbstractCMap> T parseCmap(java.lang.String name, T cmap)
-
-