FOray
|
FOray Modules: FOrayFontContentsIntroductionFOrayFont is an implementation of the axslFont interface, which should be consulted for details on the general API, sample code, etc. Although it is possible to use the FOrayFont package directly, there is probably no good reason to do so. If the axslFont-R interface is not sufficient for your needs, we recommend that you suggest changes to it instead of using the FOrayFont package directly. This allows your application to use any aXSL-compliant font system without making substantial changes to your code. Bootstrapping FOrayFontThe FOray-specific tasks that are needed to bootstrap the use of FOrayFont are as follows:
Once these tasks are accomplished, all downstream processing is documented in the axslFont API. In general, this consists of using the FontConsumer for font selection, which returns a FontUse instance. The FontUse is then used to obtain font metrics, encoding, embedding, etc. Here is some sample bootstrap code: // Instantiate the server Log logger = org.foray.common.Logging.makeDefaultLogger(); FOrayFontServer server = new FOrayFontServer(logger); // Set the base URL for physical font files. java.net.URL baseFontURL = someURL; server.setBaseFontURL(baseFontURL); // Set a resolver to be used when parsing the font-configuration org.xml.sax.EntityResolver resolver = someResolver; server.setEntityResolver(resolver); // Set up default fonts and read the font-configuration. java.net.URL fontConfigURL = anotherURL; server.setup(fontConfigURL, null); Troubleshooting System FontsIf your application is not getting the SystemFont returned that you think it should, check the following:
Class HierarchyThe following crude diagram shows the relationship between various components of the font system, and provides a brief overview of the data structure: ================= | FontServer | ================= | | ----------------------------------------- | | | | ================= ================= | Font | | FontConsumer | ================= ================= | | | | ----------------------------------------- | | ================= | ConsumerFont | ================= | ================= | | Encoding |-----------| ================= | | | ================= | FontUse | ================= | | ----------------------------------------- | | | | | | ================= ================= ================= | FontOutput | | FontOutput | | FontOutput | ================= ================= ================= For simplicity, the diagram above uses the aXSL interface names, with the exception of ConsumerFont, which has no counterpart in aXSL. FontServer knows about all registered fonts, and knows how to create FontConsumer instances, and helps FontConsumers select fonts. FontConsumer handles the font needs for one document that is being processed. It is responsible for font selection and for keeping track of which fonts have been used by a document. The combination of one Font used by one FontConsumer is a ConsumerFont. ConsumerFont is responsible to keep track of subsetting for that unique combination. The combination of one ConsumerFont and one Encoding is a FontUse. This concept is important in order to fully support single-byte fonts, which often have more characters than 8 bits access. FOray provides access to all characters in such fonts, by allowing the font to be encoded more than one way, and it keeps track of such various encodings through the FontUse. A given FontUse can then create one or more FontOutput instances which are helpers providing output-specific information about a given FontUse. |