Path: blob/master/src/java.desktop/share/classes/sun/font/FontLineMetrics.java
41155 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425/*26*27* (C) Copyright IBM Corp. 2003, All Rights Reserved28*29*/3031package sun.font;3233import java.awt.font.FontRenderContext;34import java.awt.font.LineMetrics;3536/**37* Metrics from a font for layout of characters along a line38* and layout of set of lines.39* This and CoreMetrics replace what was previously a private internal class of Font40*/41public final class FontLineMetrics extends LineMetrics implements Cloneable {42public int numchars; // mutated by Font43public final CoreMetrics cm;44public final FontRenderContext frc;4546public FontLineMetrics(int numchars, CoreMetrics cm, FontRenderContext frc) {47this.numchars = numchars;48this.cm = cm;49this.frc = frc;50}5152public int getNumChars() {53return numchars;54}5556public float getAscent() {57return cm.ascent;58}5960public float getDescent() {61return cm.descent;62}6364public float getLeading() {65return cm.leading;66}6768public float getHeight() {69return cm.height;70}7172public int getBaselineIndex() {73return cm.baselineIndex;74}7576public float[] getBaselineOffsets() {77return cm.baselineOffsets.clone();78}7980public float getStrikethroughOffset() {81return cm.strikethroughOffset;82}8384public float getStrikethroughThickness() {85return cm.strikethroughThickness;86}8788public float getUnderlineOffset() {89return cm.underlineOffset;90}9192public float getUnderlineThickness() {93return cm.underlineThickness;94}9596public int hashCode() {97return cm.hashCode();98}99100public boolean equals(Object rhs) {101try {102return cm.equals(((FontLineMetrics)rhs).cm);103}104catch (ClassCastException e) {105return false;106}107}108109public Object clone() {110// frc, cm do not need deep clone111try {112return super.clone();113}114catch (CloneNotSupportedException e) {115throw new InternalError(e);116}117}118}119120121