1 51 package org.apache.fop.render.awt; 52 53 import java.net.URL ; 55 import java.awt.Graphics2D ; 56 import java.awt.Font ; 57 58 65 66 public class FontMetricsMapper implements org.apache.fop.layout.FontMetric { 67 68 71 private static final int FIRST_CHAR = 32; 72 private static final int LAST_CHAR = 255; 73 74 78 private static AWTFontMetrics metric = null; 79 80 84 private final String family; 85 86 90 private final int style; 91 92 100 public FontMetricsMapper(String family, int style, Graphics2D graphics) { 101 this.family = family; 102 this.style = style; 103 if (metric == null) 104 metric = new AWTFontMetrics(graphics); 105 } 106 107 111 public void setEmbedFont(URL fontURL) { 112 metric.setEmbedFont(family, style, fontURL); 113 } 114 115 120 public int getAscender(int size) { 121 return metric.getAscender(family, style, size); 122 } 123 124 125 128 public int getCapHeight(int size) { 129 return metric.getCapHeight(family, style, size); 130 } 131 132 137 public int getDescender(int size) { 138 return metric.getDescender(family, style, size); 139 } 140 141 146 public int getXHeight(int size) { 147 return metric.getXHeight(family, style, size); 148 } 149 150 151 public int getFirstChar() { 152 return FIRST_CHAR; 153 } 154 155 public int getLastChar() { 156 return LAST_CHAR; 157 } 158 159 163 public int width(int i, int size) { 164 return metric.width(i, family, style, size); 165 } 166 167 168 171 public int[] getWidths(int size) { 172 return metric.getWidths(family, style, size); 173 } 174 175 180 public Font getFont(int size) { 181 return metric.getFont(family, style, size); 182 } 183 184 } 185 186 187 188 189 190 | Popular Tags |