1 17 18 19 20 package org.apache.fop.render.java2d; 21 22 import java.awt.Graphics2D ; 24 import java.util.Map ; 25 26 import org.apache.fop.fonts.FontMetrics; 28 import org.apache.fop.fonts.FontType; 29 import org.apache.fop.fonts.Typeface; 30 31 32 39 40 public class FontMetricsMapper extends Typeface implements FontMetrics { 41 42 46 private static Java2DFontMetrics metric = null; 47 48 52 private final String family; 53 54 58 private final int style; 59 60 67 public FontMetricsMapper(String family, int style, Graphics2D graphics) { 68 this.family = family; 69 this.style = style; 70 if (metric == null) { 71 metric = new Java2DFontMetrics(graphics); 72 } 73 } 74 75 78 public String getFontName() { 79 return family; 80 } 81 82 85 public FontType getFontType() { 86 return FontType.OTHER; 87 } 88 89 92 public int getMaxAscent(int size) { 93 return metric.getMaxAscent(family, style, size); 94 } 95 96 99 public int getAscender(int size) { 100 return metric.getAscender(family, style, size); 101 } 102 103 106 public int getCapHeight(int size) { 107 return metric.getCapHeight(family, style, size); 108 } 109 110 113 public int getDescender(int size) { 114 return metric.getDescender(family, style, size); 115 } 116 117 120 public int getXHeight(int size) { 121 return metric.getXHeight(family, style, size); 122 } 123 124 127 public int getWidth(int i, int size) { 128 return metric.width(i, family, style, size); 129 } 130 131 132 135 public int[] getWidths() { 136 return metric.getWidths(family, style, Java2DFontMetrics.FONT_SIZE); 137 } 138 139 145 public java.awt.Font getFont(int size) { 146 return metric.getFont(family, style, size); 147 } 148 149 152 public Map getKerningInfo() { 153 return java.util.Collections.EMPTY_MAP; 154 } 155 156 159 public boolean hasKerningInfo() { 160 return false; 161 } 162 163 164 public String getEncoding() { 165 return null; } 167 168 169 public char mapChar(char c) { 170 return c; 171 } 172 173 174 public boolean hasChar(char c) { 175 return metric.hasChar(family, style, Java2DFontMetrics.FONT_SIZE, c); 176 } 177 178 } 179 180 181 182 183 184 | Popular Tags |