1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
/* * @(#)LineMetrics.java 1.21 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ /* * @(#)LineMetrics.java 1.4 98/09/21 */ package java.awt.font; /** * The <code>LineMetrics</code> class allows access to the * metrics needed to layout characters along a line * and to layout of a set of lines. A <code>LineMetrics</code> * object encapsulates the measurement information associated * with a run of text. * <p> * Fonts can have different metrics for different ranges of * characters. The <code>getLineMetrics</code> methods of * {@link java.awt.Font Font} take some text as an argument * and return a <code>LineMetrics</code> object describing the * metrics of the initial number of characters in that text, as * returned by {@link #getNumChars}. */ public abstract class LineMetrics { /** * Returns the number of characters (<code>char</code> values) in the text whose * metrics are encapsulated by this <code>LineMetrics</code> * object. * @return the number of characters (<code>char</code> values) in the text with which * this <code>LineMetrics</code> was created. */ public abstract int getNumChars(); /** * Returns the ascent of the text. The ascent * is the distance from the baseline * to the ascender line. The ascent usually represents the * the height of the capital letters of the text. Some characters * can extend above the ascender line. * @return the ascent of the text. */ public abstract float getAscent(); /** * Returns the descent of the text. The descent * is the distance from the baseline * to the descender line. The descent usually represents * the distance to the bottom of lower case letters like * 'p'. Some characters can extend below the descender * line. * @return the descent of the text. */ public abstract float getDescent(); /** * Returns the leading of the text. The * leading is the recommended * distance from the bottom of the descender line to the * top of the next line. * @return the leading of the text. */ public abstract float getLeading(); /** * Returns the height of the text. The * height is equal to the sum of the ascent, the * descent and the leading. * @return the height of the text. */ public abstract float getHeight(); /** * Returns the baseline index of the text. * The index is one of * {@link java.awt.Font#ROMAN_BASELINE ROMAN_BASELINE}, * {@link java.awt.Font#CENTER_BASELINE CENTER_BASELINE}, * {@link java.awt.Font#HANGING_BASELINE HANGING_BASELINE}. * @return the baseline of the text. */ public abstract int getBaselineIndex(); /** * Returns the baseline offsets of the text, * relative to the baseline of the text. The * offsets are indexed by baseline index. For * example, if the baseline index is * <code>CENTER_BASELINE</code> then * <code>offsets[HANGING_BASELINE]</code> is usually * negative, <code>offsets[CENTER_BASELINE]</code> * is zero, and <code>offsets[ROMAN_BASELINE]</code> * is usually positive. * @return the baseline offsets of the text. */ public abstract float[] getBaselineOffsets(); /** * Returns the position of the strike-through line * relative to the baseline. * @return the position of the strike-through line. */ public abstract float getStrikethroughOffset(); /** * Returns the thickness of the strike-through line. * @return the thickness of the strike-through line. */ public abstract float getStrikethroughThickness(); /** * Returns the position of the underline relative to * the baseline. * @return the position of the underline. */ public abstract float getUnderlineOffset(); /** * Returns the thickness of the underline. * @return the thickness of the underline. */ public abstract float getUnderlineThickness(); }