Frames | No Frames |
1: /* Scaler.java -- Common superclass for font scalers. 2: Copyright (C) 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: package gnu.java.awt.font.opentype; 39: 40: import java.awt.geom.AffineTransform; 41: import java.awt.geom.GeneralPath; 42: import java.awt.geom.Point2D; 43: 44: 45: /** 46: * An common superclass for all font scalers. The main task of font 47: * scaler is to retrieve a scaled and hinted outline for a glyph. 48: * 49: * <p>To make text more legible, high-quality fonts contain 50: * instructions (sometimes also called “hints”) for 51: * moving the scaled control points towards the coordinate grid of the 52: * display device. 53: * 54: * <p><b>Lack of Thread Safety:</b> Font scalers are intentionally 55: * <i>not</i> safe to access from multiple concurrent 56: * threads. Synchronization needs to be performed externally. Usually, 57: * the font that uses this scaler already has obtained a lock before 58: * calling the scaler. 59: * 60: * @author Sascha Brawer (brawer@dandelis.ch) 61: */ 62: public abstract class Scaler 63: { 64: /** 65: * Retrieves the scaled outline of a glyph, adjusting control points 66: * to the raster grid if necessary. 67: * 68: * @param glyph the glyph number whose outline is retrieved. 69: * 70: * @param pointSize the point size of the font. 71: * 72: * @param transform a transform that is applied in addition to 73: * scaling to the specified point size. This is often used for 74: * scaling according to the device resolution. Those who lack any 75: * aesthetic sense may also use the transform to slant or stretch 76: * glyphs. 77: * 78: * @param antialias whether or not the rasterizer will perform 79: * anti-aliasing on the returned path. 80: * 81: * @param fractionalMetrics <code>false</code> for adjusting glyph 82: * positions to the raster grid of device space. 83: * 84: * @return the scaled and grid-fitted outline of the specified 85: * glyph, or <code>null</code> for bitmap fonts. 86: */ 87: public abstract GeneralPath getOutline(int glyph, 88: float pointSize, 89: AffineTransform transform, 90: boolean antialias, 91: boolean fractionalMetrics); 92: 93: 94: /** 95: * Determines the advance width and height for a glyph. 96: * 97: * @param glyphIndex the glyph whose advance width is to be 98: * determined. 99: * 100: * @param pointSize the point size of the font. 101: * 102: * @param transform a transform that is applied in addition to 103: * scaling to the specified point size. This is often used for 104: * scaling according to the device resolution. Those who lack any 105: * aesthetic sense may also use the transform to slant or stretch 106: * glyphs. 107: * 108: * @param antialias <code>true</code> for anti-aliased rendering, 109: * <code>false</code> for normal rendering. For hinted fonts, 110: * this parameter may indeed affect the result. 111: * 112: * @param fractionalMetrics <code>true</code> for fractional metrics, 113: * <code>false</code> for rounding the result to a pixel boundary. 114: * 115: * @param horizontal <code>true</code> for horizontal line layout, 116: * <code>false</code> for vertical line layout. 117: * 118: * @param advance a point whose <code>x</code> and <code>y</code> 119: * fields will hold the advance in each direction. It is well 120: * possible that both values are non-zero, for example for rotated 121: * text or for Urdu fonts. 122: */ 123: public abstract void getAdvance(int glyphIndex, 124: float pointSize, 125: AffineTransform transform, 126: boolean antialias, 127: boolean fractionalMetrics, 128: boolean horizontal, 129: Point2D advance); 130: 131: 132: /** 133: * Determines the distance between the base line and the highest 134: * ascender. 135: * 136: * @param pointSize the point size of the font. 137: * 138: * @param transform a transform that is applied in addition to 139: * scaling to the specified point size. This is often used for 140: * scaling according to the device resolution. Those who lack any 141: * aesthetic sense may also use the transform to slant or stretch 142: * glyphs. 143: * 144: * @param antialias <code>true</code> for anti-aliased rendering, 145: * <code>false</code> for normal rendering. For hinted fonts, 146: * this parameter may indeed affect the result. 147: * 148: * @param fractionalMetrics <code>true</code> for fractional metrics, 149: * <code>false</code> for rounding the result to a pixel boundary. 150: * 151: * @param horizontal <code>true</code> for horizontal line layout, 152: * <code>false</code> for vertical line layout. 153: * 154: * @return the ascent, which usually is a positive number. 155: */ 156: public abstract float getAscent(float pointSize, 157: AffineTransform transform, 158: boolean antialias, 159: boolean fractionalMetrics, 160: boolean horizontal); 161: 162: 163: /** 164: * Determines the distance between the base line and the lowest 165: * descender. 166: * 167: * @param pointSize the point size of the font. 168: * 169: * @param transform a transform that is applied in addition to 170: * scaling to the specified point size. This is often used for 171: * scaling according to the device resolution. Those who lack any 172: * aesthetic sense may also use the transform to slant or stretch 173: * glyphs. 174: * 175: * @param antialiased <code>true</code> for anti-aliased rendering, 176: * <code>false</code> for normal rendering. For hinted fonts, 177: * this parameter may indeed affect the result. 178: * 179: * @param fractionalMetrics <code>true</code> for fractional metrics, 180: * <code>false</code> for rounding the result to a pixel boundary. 181: * 182: * @param horizontal <code>true</code> for horizontal line layout, 183: * <code>false</code> for vertical line layout. 184: * 185: * @return the descent, which usually is a nagative number. 186: */ 187: public abstract float getDescent(float pointSize, 188: AffineTransform transform, 189: boolean antialiased, 190: boolean fractionalMetrics, 191: boolean horizontal); 192: }