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.

font-file.xsl 6.2KB

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
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
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
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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <!-- $Id$ -->
  16. <!-- This file writes the class files for the fonts (Courier.java,
  17. Helvetica.java etc.). It uses the information in the font
  18. description files (Courier.xml, Helvetica.xml) to do this. In these
  19. font description files each character is referenced by its adobe
  20. glyph name:
  21. <char name="A" width="667"/>
  22. To resolve this name and to find the code for this character it looks
  23. up the adobe name in the file encodings.xml and extracts the appropriate
  24. code. -->
  25. <xsl:stylesheet version="1.0"
  26. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  27. <xsl:output method="text"/>
  28. <xsl:param name="encoding" select="/font-metrics/encoding"/>
  29. <xsl:variable name="glyphs" select="document('encodings.xml')/encoding-set/encoding[@id=$encoding]/glyph"/>
  30. <xsl:template match="font-metrics">
  31. package org.apache.fop.fonts.base14;
  32. <xsl:if test="count(kerning) &gt; 0">
  33. import java.util.Map;
  34. </xsl:if>
  35. import java.util.Set;
  36. import org.apache.fop.fonts.FontType;
  37. import org.apache.fop.fonts.Base14Font;
  38. import org.apache.fop.fonts.CodePointMapping;
  39. public class <xsl:value-of select="class-name"/> extends Base14Font {
  40. private final static String fontName = "<xsl:value-of select="font-name"/>";
  41. private final static String fullName = "<xsl:value-of select="full-name"/>";
  42. private final static Set familyNames;
  43. private final static String encoding = "<xsl:value-of select="$encoding"/>";
  44. private final static int capHeight = <xsl:value-of select="cap-height"/>;
  45. private final static int xHeight = <xsl:value-of select="x-height"/>;
  46. private final static int ascender = <xsl:value-of select="ascender"/>;
  47. private final static int descender = <xsl:value-of select="descender"/>;
  48. private final static int firstChar = <xsl:value-of select="first-char"/>;
  49. private final static int lastChar = <xsl:value-of select="last-char"/>;
  50. private final static int[] width;
  51. private final CodePointMapping mapping =
  52. CodePointMapping.getMapping("<xsl:value-of select="$encoding"/>");
  53. <xsl:if test="count(kerning) &gt; 0">
  54. private final static Map kerning;
  55. </xsl:if>
  56. private boolean enableKerning = false;
  57. static {
  58. width = new int[256];
  59. <xsl:apply-templates select="widths"/>
  60. <xsl:if test="count(kerning) &gt; 0">
  61. kerning = new java.util.HashMap();
  62. Integer first, second;
  63. Map pairs;
  64. <xsl:apply-templates select="kerning"/>
  65. </xsl:if>
  66. familyNames = new java.util.HashSet();
  67. familyNames.add("<xsl:value-of select="family-name"/>");
  68. }
  69. public <xsl:value-of select="class-name"/>() {
  70. this(false);
  71. }
  72. public <xsl:value-of select="class-name"/>(boolean enableKerning) {
  73. this.enableKerning = enableKerning;
  74. }
  75. public String getEncodingName() {
  76. return encoding;
  77. }
  78. public String getFontName() {
  79. return fontName;
  80. }
  81. public String getEmbedFontName() {
  82. return getFontName();
  83. }
  84. public String getFullName() {
  85. return fullName;
  86. }
  87. public Set getFamilyNames() {
  88. return familyNames;
  89. }
  90. public FontType getFontType() {
  91. return FontType.TYPE1;
  92. }
  93. public int getAscender(int size) {
  94. return size * ascender;
  95. }
  96. public int getCapHeight(int size) {
  97. return size * capHeight;
  98. }
  99. public int getDescender(int size) {
  100. return size * descender;
  101. }
  102. public int getXHeight(int size) {
  103. return size * xHeight;
  104. }
  105. public int getFirstChar() {
  106. return firstChar;
  107. }
  108. public int getLastChar() {
  109. return lastChar;
  110. }
  111. public int getWidth(int i,int size) {
  112. return size * width[i];
  113. }
  114. public int[] getWidths() {
  115. int[] arr = new int[getLastChar() - getFirstChar() + 1];
  116. System.arraycopy(width, getFirstChar(), arr, 0, getLastChar() - getFirstChar() + 1);
  117. return arr;
  118. }
  119. <xsl:choose>
  120. <xsl:when test="count(kerning) &gt; 0">
  121. public boolean hasKerningInfo() {
  122. return enableKerning;
  123. }
  124. public java.util.Map getKerningInfo() {
  125. return kerning;
  126. }
  127. </xsl:when>
  128. <xsl:otherwise>
  129. public boolean hasKerningInfo() {
  130. return false;
  131. }
  132. public java.util.Map getKerningInfo() {
  133. return java.util.Collections.EMPTY_MAP;
  134. }
  135. </xsl:otherwise>
  136. </xsl:choose>
  137. public char mapChar(char c) {
  138. notifyMapOperation();
  139. char d = mapping.mapChar(c);
  140. if (d != 0) {
  141. return d;
  142. } else {
  143. return '#';
  144. }
  145. }
  146. public boolean hasChar(char c) {
  147. return (mapping.mapChar(c) > 0);
  148. }
  149. }
  150. </xsl:template>
  151. <xsl:template match="widths/char"><xsl:variable name="char-name" select="@name"/><xsl:variable name="char-num" select="$glyphs[@name = $char-name]/@codepoint"/><xsl:if test="$char-num!=''"> width[0x<xsl:value-of select="$char-num"/>] = <xsl:value-of select="@width"/>;</xsl:if></xsl:template>
  152. <xsl:template match="kerning">
  153. first = new Integer(<xsl:value-of select="@kpx1"/>);
  154. pairs = (Map)kerning.get(first);
  155. if (pairs == null) {
  156. pairs = new java.util.HashMap();
  157. kerning.put(first, pairs);
  158. }
  159. <xsl:apply-templates select="pair"/>
  160. </xsl:template>
  161. <xsl:template match="pair">
  162. second = new Integer(<xsl:value-of select="@kpx2"/>);
  163. pairs.put(second, new Integer(<xsl:value-of select="@kern"/>));
  164. </xsl:template>
  165. </xsl:stylesheet>