Package org.apache.fop.afp.fonts
Class CharacterSetBuilder
java.lang.Object
org.apache.fop.afp.fonts.CharacterSetBuilder
The CharacterSetBuilder is responsible building the a CharacterSet instance that holds
the font metric data. The data is either read from disk and passed to a CharacterSet (*)
or a FopCharacterSet is instantiated that is composed of a Typeface instance configured
with this data.
-*- For referenced fonts CharacterSetBuilder is responsible for reading the font attributes from binary code page files and the character set metric files. In IBM font structure, a code page maps each character of text to the characters in a character set. Each character is translated into a code point. When the character is printed, each code point is matched to a character ID on the code page specified. The character ID is then matched to the image (raster pattern or outline pattern) of the character in the character set specified. The image in the character set is the image that is printed in the document. To be a valid code page for a particular character set, all character IDs in the code page must be included in that character set.
This class will read the font information from the binary code page files and character set metric files in order to determine the correct metrics to use when rendering the formatted object.
-*- For referenced fonts CharacterSetBuilder is responsible for reading the font attributes from binary code page files and the character set metric files. In IBM font structure, a code page maps each character of text to the characters in a character set. Each character is translated into a code point. When the character is printed, each code point is matched to a character ID on the code page specified. The character ID is then matched to the image (raster pattern or outline pattern) of the character in the character set specified. The image in the character set is the image that is printed in the document. To be a valid code page for a particular character set, all character IDs in the code page must be included in that character set.
This class will read the font information from the binary code page files and character set metric files in order to determine the correct metrics to use when rendering the formatted object.
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.Log
Static logging instance -
Method Summary
Modifier and TypeMethodDescriptionbuild
(String characterSetName, String codePageName, String encoding, Typeface typeface, AFPEventProducer eventProducer) Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics.build
(String characterSetName, String codePageName, String encoding, Typeface typeface, AFPResourceAccessor accessor, AFPEventProducer eventProducer) buildDBCS
(String characterSetName, String codePageName, String encoding, CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer) Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics.buildSBCS
(String characterSetName, String codePageName, String encoding, AFPResourceAccessor accessor, AFPEventProducer eventProducer) Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics.static CharacterSetBuilder
Factory method for the double-byte (CID Keyed font (Type 0)) implementation of AFPFontReader.static CharacterSetBuilder
Factory method for the single-byte implementation of AFPFontReader.loadCodePage
(String codePage, String encoding, AFPResourceAccessor accessor, AFPEventProducer eventProducer) Load the code page information from the appropriate file.
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOGStatic logging instance
-
-
Method Details
-
getSingleByteInstance
Factory method for the single-byte implementation of AFPFontReader.- Returns:
- AFPFontReader
-
getDoubleByteInstance
Factory method for the double-byte (CID Keyed font (Type 0)) implementation of AFPFontReader.- Returns:
- AFPFontReader
-
buildSBCS
public CharacterSet buildSBCS(String characterSetName, String codePageName, String encoding, AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics.- Parameters:
characterSetName
- name of the charactersetcodePageName
- name of the code page fileencoding
- encoding nameaccessor
- used to load codepage and characterseteventProducer
- for handling AFP related events- Returns:
- CharacterSet object
- Throws:
IOException
- if an I/O error occurs
-
buildDBCS
public CharacterSet buildDBCS(String characterSetName, String codePageName, String encoding, CharacterSetType charsetType, AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics. This method is to be used for double byte character sets (DBCS).- Parameters:
characterSetName
- name of the charactersetcodePageName
- name of the code page fileencoding
- encoding namecharsetType
- the characterset typeaccessor
- used to load codepage and characterseteventProducer
- for handling AFP related events- Returns:
- CharacterSet object
- Throws:
IOException
- if an I/O error occurs
-
build
public CharacterSet build(String characterSetName, String codePageName, String encoding, Typeface typeface, AFPEventProducer eventProducer) throws IOException Load the font details and metrics into the CharacterSetMetric object, this will use the actual afp code page and character set files to load the object with the necessary metrics.- Parameters:
characterSetName
- the CharacterSetMetric object to populatecodePageName
- the name of the code page to useencoding
- name of the encoding in usetypeface
- base14 font nameeventProducer
- for handling AFP related events- Returns:
- CharacterSet object
- Throws:
IOException
- if an I/O error occurs
-
build
public CharacterSet build(String characterSetName, String codePageName, String encoding, Typeface typeface, AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException - Throws:
IOException
-
loadCodePage
protected Map<String,String> loadCodePage(String codePage, String encoding, AFPResourceAccessor accessor, AFPEventProducer eventProducer) throws IOException Load the code page information from the appropriate file. The file name to load is determined by the code page name and the file extension 'CDP'.- Parameters:
codePage
- the code page identifierencoding
- the encoding to use for the character decodingaccessor
- the resource accessoreventProducer
- for handling AFP related events- Returns:
- a code page mapping (key: GCGID, value: Unicode character)
- Throws:
IOException
- if an I/O exception of some sort has occurred.
-