You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LazyFont.java 9.9KB

Merged revisions 642144-647679 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r642923 | jeremias | 2008-03-31 10:39:49 +0200 (Mo, 31 Mrz 2008) | 1 line Fixed possible NullPointerException in AFM kerning table build code. ........ r642924 | jeremias | 2008-03-31 10:40:48 +0200 (Mo, 31 Mrz 2008) | 1 line Added missing code for determining the PDF Flags. The removes the need to have a PFM if you have an AFM file for a Type 1 font. ........ r642927 | jeremias | 2008-03-31 10:48:34 +0200 (Mo, 31 Mrz 2008) | 1 line Updated XG Commons for revision: http://svn.apache.org/viewvc?rev=642925&view=rev ........ r644208 | jeremias | 2008-04-03 10:05:14 +0200 (Do, 03 Apr 2008) | 11 lines Bugzilla #44737: Added support for auto-configuring TrueType Collections. XML font metrics files for *.ttc fonts are not required anymore. Submitted by: Jason Harrop <jason.at.plutext.org> Changes to patch or in addition to the patch: - Tab chars removed and Checkstyle issues fixed - Some simplifications in the cache handling (CachedFontInfo is obsolete and less cache-private information is exposed to the outside). - TTCs are fully detected and registered with FOP. - TTCs can also be registered using a "font" element. The new "sub-font" attribute selected the sub-font in the TTC. - Bug fixed in TTFFile: Font names were not decoded correctly (ex. font names in Chinese) - Minimal docs. ........ r644213 | jeremias | 2008-04-03 10:13:50 +0200 (Do, 03 Apr 2008) | 1 line Oops. Fixed a last-minute change that broke the build. ........ r644691 | jeremias | 2008-04-04 14:19:50 +0200 (Fr, 04 Apr 2008) | 3 lines Bugzilla #44743: Added a public accessor for reference to the current page to PDFGraphics2D. Submitted by: Yegor Kozlov <yegor.at.dinom.ru> ........ r644697 | jeremias | 2008-04-04 14:40:22 +0200 (Fr, 04 Apr 2008) | 2 lines Bugzilla #44744: Disable drawString(AttributedCharacterIterator, float, float) as it contains bugs and rely on the fallback implementation from AbstractGraphics2D. ........ r645104 | jeremias | 2008-04-05 16:11:50 +0200 (Sa, 05 Apr 2008) | 1 line Fixed broken links. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@647685 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 642144-647679 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r642923 | jeremias | 2008-03-31 10:39:49 +0200 (Mo, 31 Mrz 2008) | 1 line Fixed possible NullPointerException in AFM kerning table build code. ........ r642924 | jeremias | 2008-03-31 10:40:48 +0200 (Mo, 31 Mrz 2008) | 1 line Added missing code for determining the PDF Flags. The removes the need to have a PFM if you have an AFM file for a Type 1 font. ........ r642927 | jeremias | 2008-03-31 10:48:34 +0200 (Mo, 31 Mrz 2008) | 1 line Updated XG Commons for revision: http://svn.apache.org/viewvc?rev=642925&view=rev ........ r644208 | jeremias | 2008-04-03 10:05:14 +0200 (Do, 03 Apr 2008) | 11 lines Bugzilla #44737: Added support for auto-configuring TrueType Collections. XML font metrics files for *.ttc fonts are not required anymore. Submitted by: Jason Harrop <jason.at.plutext.org> Changes to patch or in addition to the patch: - Tab chars removed and Checkstyle issues fixed - Some simplifications in the cache handling (CachedFontInfo is obsolete and less cache-private information is exposed to the outside). - TTCs are fully detected and registered with FOP. - TTCs can also be registered using a "font" element. The new "sub-font" attribute selected the sub-font in the TTC. - Bug fixed in TTFFile: Font names were not decoded correctly (ex. font names in Chinese) - Minimal docs. ........ r644213 | jeremias | 2008-04-03 10:13:50 +0200 (Do, 03 Apr 2008) | 1 line Oops. Fixed a last-minute change that broke the build. ........ r644691 | jeremias | 2008-04-04 14:19:50 +0200 (Fr, 04 Apr 2008) | 3 lines Bugzilla #44743: Added a public accessor for reference to the current page to PDFGraphics2D. Submitted by: Yegor Kozlov <yegor.at.dinom.ru> ........ r644697 | jeremias | 2008-04-04 14:40:22 +0200 (Fr, 04 Apr 2008) | 2 lines Bugzilla #44744: Disable drawString(AttributedCharacterIterator, float, float) as it contains bugs and rely on the fallback implementation from AbstractGraphics2D. ........ r645104 | jeremias | 2008-04-05 16:11:50 +0200 (Sa, 05 Apr 2008) | 1 line Fixed broken links. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@647685 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 642144-647679 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r642923 | jeremias | 2008-03-31 10:39:49 +0200 (Mo, 31 Mrz 2008) | 1 line Fixed possible NullPointerException in AFM kerning table build code. ........ r642924 | jeremias | 2008-03-31 10:40:48 +0200 (Mo, 31 Mrz 2008) | 1 line Added missing code for determining the PDF Flags. The removes the need to have a PFM if you have an AFM file for a Type 1 font. ........ r642927 | jeremias | 2008-03-31 10:48:34 +0200 (Mo, 31 Mrz 2008) | 1 line Updated XG Commons for revision: http://svn.apache.org/viewvc?rev=642925&view=rev ........ r644208 | jeremias | 2008-04-03 10:05:14 +0200 (Do, 03 Apr 2008) | 11 lines Bugzilla #44737: Added support for auto-configuring TrueType Collections. XML font metrics files for *.ttc fonts are not required anymore. Submitted by: Jason Harrop <jason.at.plutext.org> Changes to patch or in addition to the patch: - Tab chars removed and Checkstyle issues fixed - Some simplifications in the cache handling (CachedFontInfo is obsolete and less cache-private information is exposed to the outside). - TTCs are fully detected and registered with FOP. - TTCs can also be registered using a "font" element. The new "sub-font" attribute selected the sub-font in the TTC. - Bug fixed in TTFFile: Font names were not decoded correctly (ex. font names in Chinese) - Minimal docs. ........ r644213 | jeremias | 2008-04-03 10:13:50 +0200 (Do, 03 Apr 2008) | 1 line Oops. Fixed a last-minute change that broke the build. ........ r644691 | jeremias | 2008-04-04 14:19:50 +0200 (Fr, 04 Apr 2008) | 3 lines Bugzilla #44743: Added a public accessor for reference to the current page to PDFGraphics2D. Submitted by: Yegor Kozlov <yegor.at.dinom.ru> ........ r644697 | jeremias | 2008-04-04 14:40:22 +0200 (Fr, 04 Apr 2008) | 2 lines Bugzilla #44744: Disable drawString(AttributedCharacterIterator, float, float) as it contains bugs and rely on the fallback implementation from AbstractGraphics2D. ........ r645104 | jeremias | 2008-04-05 16:11:50 +0200 (Sa, 05 Apr 2008) | 1 line Fixed broken links. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@647685 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
New feature: "Intermediate format" (IF). The IF is basically the XML dialect written by the area tree renderer (XMLRenderer). A new parser for this format allows reparsing a serialized and possibly modified area tree and rendering it to the final target format. More details on the Wiki at http://wiki.apache.org/xmlgraphics-fop/AreaTreeIntermediateXml. No advanced features have been implemented, yet, only the basic functionality. The whole change should be fully backwards-compatible WRT the outer FOP API except maybe for FOTreeBuilder.addElementMapping(), and the area tree XML which got small changes. The area tree has been cleaned up. The serializability has been restored. The CachedRenderPagesModel works again and can, in certain situations, decrease the maximum amount of memory held at one point in time. Some adjustments were necessary in the area tree to help the work of the AreaTreeParser. The AreaTreeParser is new and is responsible for parsing area tree XML files and adding pages to a RenderPagesModel instance. It is SAX-based and should be pretty efficient. XMLUnit (http://xmlunit.sourceforge.net, BSD license) is a new dependency for the test code. It is used to verify the correctness of the intermediate format code. It doesn't have to be installed for the build to run through, though. ElementMapping got a new method getDOMImplementation() which provides the DOMImplementation used to handle a subdocument of a particular namespace. For example, SVG uses Batik's SVG DOM. The AreaTreeParser needs that to properly recreate foreign objects because it can't use the mechanism of the FO tree. The default implementation returns null. The ElementMapping instances are no longer maintained by the FOTreeBuilder, but by the newly created ElementMappingRegistry class. It is expected that the instance of this class is moved from the FOTreeBuilder and the AreaTreeParser's Handler class to the "environment class" once it is created to cut down on the startup time for each processed document. The XMLRenderer has been slightly modified to improve the serialization/deserialization qualities of the area tree XML format. The XMLRenderer can now mimic another renderer (see mimicRenderer(Renderer)) in order to use its font setup. That way it is made certain that the reparsed area tree will render to the final target format exactly as expected. Fixed a bug in the XMLHandlerRegistry which did not always return the right XMLHandler for every situation. Added a DefaultErrorListener to the util package. I've had problems with Xalan-J swallowing exceptions with its default ErrorListener, so I added a simple one for convenience and use in AreaTreeParser. Example code for working with the AreaTreeParser can be found in examples/embedding. Documentation will follow. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@369753 13f79535-47bb-0310-9956-ffa450edef68
18 years ago
Improved font auto-detection and handling of AWT-supplied fonts in order to achieve better results when using multiple output formats. Whenever possible, the font names appearing in the operating system can also be used in XSL-FO. Better distinction between Font Family Name ("Arial"), Full Font Name ("Arial Bold") and PostScript Name ("Arial-BoldMT"). This allows a better generation of FontTriplets. The same is done for AWT fonts where I have switch from font-family detection to enumerating all java.awt.Font instances so I can extract Family Name, Full Name and PostScript Name. FontInfoFinder and AWT's FontSetup are synchronized as well as possible at this time. Register "extra-bold" (weight 800) and "light" (weight 200) in triplets when detected. Tweaked FontInfo.fontLookup() for better fallback behaviour. This approach is rapidly nearing its flexibility limits. We should rethink the FontTriplet structure. Fixed font-autodetection so fonts with uppercase extensions are detected, too. Made the way TrueType fonts are embedded in PDF compliant to the specification so viewers correctly identify subset fonts. The name prefix in MultiByteFont was incorrect. Support the detection of the special Type 1 Symbol font. Symbol used to be detected with "ExpertSubsetEncoding" instead of "SymbolEncoding". Type1FontLoader tries to construct a "full name" from the PostScript name. This is a temporary hack until we have a PFB or PFA parser. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@593189 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Improved font auto-detection and handling of AWT-supplied fonts in order to achieve better results when using multiple output formats. Whenever possible, the font names appearing in the operating system can also be used in XSL-FO. Better distinction between Font Family Name ("Arial"), Full Font Name ("Arial Bold") and PostScript Name ("Arial-BoldMT"). This allows a better generation of FontTriplets. The same is done for AWT fonts where I have switch from font-family detection to enumerating all java.awt.Font instances so I can extract Family Name, Full Name and PostScript Name. FontInfoFinder and AWT's FontSetup are synchronized as well as possible at this time. Register "extra-bold" (weight 800) and "light" (weight 200) in triplets when detected. Tweaked FontInfo.fontLookup() for better fallback behaviour. This approach is rapidly nearing its flexibility limits. We should rethink the FontTriplet structure. Fixed font-autodetection so fonts with uppercase extensions are detected, too. Made the way TrueType fonts are embedded in PDF compliant to the specification so viewers correctly identify subset fonts. The name prefix in MultiByteFont was incorrect. Support the detection of the special Type 1 Symbol font. Symbol used to be detected with "ExpertSubsetEncoding" instead of "SymbolEncoding". Type1FontLoader tries to construct a "full name" from the PostScript name. This is a temporary hack until we have a PFB or PFA parser. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@593189 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Improved font auto-detection and handling of AWT-supplied fonts in order to achieve better results when using multiple output formats. Whenever possible, the font names appearing in the operating system can also be used in XSL-FO. Better distinction between Font Family Name ("Arial"), Full Font Name ("Arial Bold") and PostScript Name ("Arial-BoldMT"). This allows a better generation of FontTriplets. The same is done for AWT fonts where I have switch from font-family detection to enumerating all java.awt.Font instances so I can extract Family Name, Full Name and PostScript Name. FontInfoFinder and AWT's FontSetup are synchronized as well as possible at this time. Register "extra-bold" (weight 800) and "light" (weight 200) in triplets when detected. Tweaked FontInfo.fontLookup() for better fallback behaviour. This approach is rapidly nearing its flexibility limits. We should rethink the FontTriplet structure. Fixed font-autodetection so fonts with uppercase extensions are detected, too. Made the way TrueType fonts are embedded in PDF compliant to the specification so viewers correctly identify subset fonts. The name prefix in MultiByteFont was incorrect. Support the detection of the special Type 1 Symbol font. Symbol used to be detected with "ExpertSubsetEncoding" instead of "SymbolEncoding". Type1FontLoader tries to construct a "full name" from the PostScript name. This is a temporary hack until we have a PFB or PFA parser. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@593189 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
Improved font auto-detection and handling of AWT-supplied fonts in order to achieve better results when using multiple output formats. Whenever possible, the font names appearing in the operating system can also be used in XSL-FO. Better distinction between Font Family Name ("Arial"), Full Font Name ("Arial Bold") and PostScript Name ("Arial-BoldMT"). This allows a better generation of FontTriplets. The same is done for AWT fonts where I have switch from font-family detection to enumerating all java.awt.Font instances so I can extract Family Name, Full Name and PostScript Name. FontInfoFinder and AWT's FontSetup are synchronized as well as possible at this time. Register "extra-bold" (weight 800) and "light" (weight 200) in triplets when detected. Tweaked FontInfo.fontLookup() for better fallback behaviour. This approach is rapidly nearing its flexibility limits. We should rethink the FontTriplet structure. Fixed font-autodetection so fonts with uppercase extensions are detected, too. Made the way TrueType fonts are embedded in PDF compliant to the specification so viewers correctly identify subset fonts. The name prefix in MultiByteFont was incorrect. Support the detection of the special Type 1 Symbol font. Symbol used to be detected with "ExpertSubsetEncoding" instead of "SymbolEncoding". Type1FontLoader tries to construct a "full name" from the PostScript name. This is a temporary hack until we have a PFB or PFA parser. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@593189 13f79535-47bb-0310-9956-ffa450edef68
16 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fonts;
  19. import java.io.IOException;
  20. import java.io.InputStream;
  21. import java.net.URL;
  22. import java.util.Map;
  23. import java.util.Set;
  24. import javax.xml.transform.Source;
  25. import javax.xml.transform.stream.StreamSource;
  26. import org.xml.sax.InputSource;
  27. import org.apache.commons.logging.Log;
  28. import org.apache.commons.logging.LogFactory;
  29. import org.apache.fop.apps.FOPException;
  30. /**
  31. * This class is used to defer the loading of a font until it is really used.
  32. */
  33. public class LazyFont extends Typeface implements FontDescriptor {
  34. private static Log log = LogFactory.getLog(LazyFont.class);
  35. private String metricsFileName = null;
  36. private String fontEmbedPath = null;
  37. private boolean useKerning = false;
  38. private String subFontName = null;
  39. private boolean isMetricsLoaded = false;
  40. private Typeface realFont = null;
  41. private FontDescriptor realFontDescriptor = null;
  42. private FontResolver resolver = null;
  43. /**
  44. * Main constructor
  45. * @param fontInfo the font info to embed
  46. * @param resolver the font resolver to handle font URIs
  47. */
  48. public LazyFont(EmbedFontInfo fontInfo, FontResolver resolver) {
  49. this.metricsFileName = fontInfo.getMetricsFile();
  50. this.fontEmbedPath = fontInfo.getEmbedFile();
  51. this.useKerning = fontInfo.getKerning();
  52. this.subFontName = fontInfo.getSubFontName();
  53. this.resolver = resolver;
  54. }
  55. /** {@inheritDoc} */
  56. public String toString() {
  57. return ( "metrics-url=" + metricsFileName + ", embed-url=" + fontEmbedPath
  58. + ", kerning=" + useKerning );
  59. }
  60. private void load(boolean fail) {
  61. if (!isMetricsLoaded) {
  62. try {
  63. if (metricsFileName != null) {
  64. /**@todo Possible thread problem here */
  65. FontReader reader = null;
  66. if (resolver != null) {
  67. Source source = resolver.resolve(metricsFileName);
  68. if (source == null) {
  69. String err
  70. = "Cannot load font: failed to create Source from metrics file "
  71. + metricsFileName;
  72. if (fail) {
  73. throw new RuntimeException(err);
  74. } else {
  75. log.error(err);
  76. }
  77. return;
  78. }
  79. InputStream in = null;
  80. if (source instanceof StreamSource) {
  81. in = ((StreamSource) source).getInputStream();
  82. }
  83. if (in == null && source.getSystemId() != null) {
  84. in = new java.net.URL(source.getSystemId()).openStream();
  85. }
  86. if (in == null) {
  87. String err = "Cannot load font: After URI resolution, the returned"
  88. + " Source object does not contain an InputStream"
  89. + " or a valid URL (system identifier) for metrics file: "
  90. + metricsFileName;
  91. if (fail) {
  92. throw new RuntimeException(err);
  93. } else {
  94. log.error(err);
  95. }
  96. return;
  97. }
  98. InputSource src = new InputSource(in);
  99. src.setSystemId(source.getSystemId());
  100. reader = new FontReader(src);
  101. } else {
  102. reader = new FontReader(new InputSource(
  103. new URL(metricsFileName).openStream()));
  104. }
  105. reader.setKerningEnabled(useKerning);
  106. reader.setFontEmbedPath(fontEmbedPath);
  107. reader.setResolver(resolver);
  108. realFont = reader.getFont();
  109. } else {
  110. if (fontEmbedPath == null) {
  111. throw new RuntimeException("Cannot load font. No font URIs available.");
  112. }
  113. realFont = FontLoader.loadFont(fontEmbedPath, this.subFontName, resolver);
  114. }
  115. if (realFont instanceof FontDescriptor) {
  116. realFontDescriptor = (FontDescriptor) realFont;
  117. }
  118. } catch (FOPException fopex) {
  119. log.error("Failed to read font metrics file " + metricsFileName, fopex);
  120. if (fail) {
  121. throw new RuntimeException(fopex.getMessage());
  122. }
  123. } catch (IOException ioex) {
  124. log.error("Failed to read font metrics file " + metricsFileName, ioex);
  125. if (fail) {
  126. throw new RuntimeException(ioex.getMessage());
  127. }
  128. }
  129. realFont.setEventListener(this.eventListener);
  130. isMetricsLoaded = true;
  131. }
  132. }
  133. /**
  134. * Gets the real font.
  135. * @return the real font
  136. */
  137. public Typeface getRealFont() {
  138. load(false);
  139. return realFont;
  140. }
  141. // ---- Font ----
  142. /** {@inheritDoc} */
  143. public String getEncodingName() {
  144. load(true);
  145. return realFont.getEncodingName();
  146. }
  147. /**
  148. * {@inheritDoc}
  149. */
  150. public char mapChar(char c) {
  151. load(true);
  152. return realFont.mapChar(c);
  153. }
  154. /**
  155. * {@inheritDoc}
  156. */
  157. public boolean hadMappingOperations() {
  158. load(true);
  159. return realFont.hadMappingOperations();
  160. }
  161. /**
  162. * {@inheritDoc}
  163. */
  164. public boolean hasChar(char c) {
  165. load(true);
  166. return realFont.hasChar(c);
  167. }
  168. /**
  169. * {@inheritDoc}
  170. */
  171. public boolean isMultiByte() {
  172. load(true);
  173. return realFont.isMultiByte();
  174. }
  175. // ---- FontMetrics interface ----
  176. /** {@inheritDoc} */
  177. public String getFontName() {
  178. load(true);
  179. return realFont.getFontName();
  180. }
  181. /** {@inheritDoc} */
  182. public String getEmbedFontName() {
  183. load(true);
  184. return realFont.getEmbedFontName();
  185. }
  186. /** {@inheritDoc} */
  187. public String getFullName() {
  188. load(true);
  189. return realFont.getFullName();
  190. }
  191. /** {@inheritDoc} */
  192. public Set getFamilyNames() {
  193. load(true);
  194. return realFont.getFamilyNames();
  195. }
  196. /**
  197. * {@inheritDoc}
  198. */
  199. public int getMaxAscent(int size) {
  200. load(true);
  201. return realFont.getMaxAscent(size);
  202. }
  203. /**
  204. * {@inheritDoc}
  205. */
  206. public int getAscender(int size) {
  207. load(true);
  208. return realFont.getAscender(size);
  209. }
  210. /**
  211. * {@inheritDoc}
  212. */
  213. public int getCapHeight(int size) {
  214. load(true);
  215. return realFont.getCapHeight(size);
  216. }
  217. /**
  218. * {@inheritDoc}
  219. */
  220. public int getDescender(int size) {
  221. load(true);
  222. return realFont.getDescender(size);
  223. }
  224. /**
  225. * {@inheritDoc}
  226. */
  227. public int getXHeight(int size) {
  228. load(true);
  229. return realFont.getXHeight(size);
  230. }
  231. /**
  232. * {@inheritDoc}
  233. */
  234. public int getWidth(int i, int size) {
  235. load(true);
  236. return realFont.getWidth(i, size);
  237. }
  238. /**
  239. * {@inheritDoc}
  240. */
  241. public int[] getWidths() {
  242. load(true);
  243. return realFont.getWidths();
  244. }
  245. /**
  246. * {@inheritDoc}
  247. */
  248. public boolean hasKerningInfo() {
  249. load(true);
  250. return realFont.hasKerningInfo();
  251. }
  252. /**
  253. * {@inheritDoc}
  254. */
  255. public Map getKerningInfo() {
  256. load(true);
  257. return realFont.getKerningInfo();
  258. }
  259. // ---- FontDescriptor interface ----
  260. /**
  261. * {@inheritDoc}
  262. */
  263. public int getCapHeight() {
  264. load(true);
  265. return realFontDescriptor.getCapHeight();
  266. }
  267. /**
  268. * {@inheritDoc}
  269. */
  270. public int getDescender() {
  271. load(true);
  272. return realFontDescriptor.getDescender();
  273. }
  274. /**
  275. * {@inheritDoc}
  276. */
  277. public int getAscender() {
  278. load(true);
  279. return realFontDescriptor.getAscender();
  280. }
  281. /**
  282. * {@inheritDoc}
  283. */
  284. public int getFlags() {
  285. load(true);
  286. return realFontDescriptor.getFlags();
  287. }
  288. /**
  289. * {@inheritDoc}
  290. */
  291. public int[] getFontBBox() {
  292. load(true);
  293. return realFontDescriptor.getFontBBox();
  294. }
  295. /**
  296. * {@inheritDoc}
  297. */
  298. public int getItalicAngle() {
  299. load(true);
  300. return realFontDescriptor.getItalicAngle();
  301. }
  302. /**
  303. * {@inheritDoc}
  304. */
  305. public int getStemV() {
  306. load(true);
  307. return realFontDescriptor.getStemV();
  308. }
  309. /**
  310. * {@inheritDoc}
  311. */
  312. public FontType getFontType() {
  313. load(true);
  314. return realFontDescriptor.getFontType();
  315. }
  316. /**
  317. * {@inheritDoc}
  318. */
  319. public boolean isEmbeddable() {
  320. load(true);
  321. return realFontDescriptor.isEmbeddable();
  322. }
  323. }