Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/font/PhysicalFont.java
38829 views
/*1* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.font;2627import java.awt.FontFormatException;28import java.awt.geom.GeneralPath;29import java.awt.geom.Point2D;30import java.awt.geom.Rectangle2D;31import java.io.FileInputStream;32import java.lang.ref.WeakReference;33import java.nio.ByteBuffer;34import java.nio.channels.FileChannel;3536public abstract class PhysicalFont extends Font2D {3738protected String platName;39// nativeNames is a String or a (possibly null) String[].40protected Object nativeNames;4142public boolean equals(Object o) {43return (o != null && o.getClass() == this.getClass() &&44((Font2D)o).fullName.equals(this.fullName));45}4647public int hashCode() {48return fullName.hashCode();49}5051/**52* Opens the file (temporarily) and does basic verification.53* Initializes the CMAP54* @throws FontFormatException - if the font can't be opened55* or fails verification, or there's no usable cmap56*/57PhysicalFont(String platname, Object nativeNames)58throws FontFormatException {5960handle = new Font2DHandle(this);61this.platName = platname;62this.nativeNames = nativeNames;63}6465protected PhysicalFont() {66handle = new Font2DHandle(this);67}6869/* The following methods are delegated to the font by the strike70* for physical fonts as the PhysicalFont holds a shared reference71* to the native resource, so all invocations need to be directed72* through a synchronization point. Implementations of these methods73* will typically be "synchronized native"74*/7576Point2D.Float getGlyphPoint(long pScalerContext,77int glyphCode, int ptNumber) {78return new Point2D.Float();79}8081/* These 3 metrics methods should be implemented to return82* values in user space.83*/84abstract StrikeMetrics getFontMetrics(long pScalerContext);8586abstract float getGlyphAdvance(long pScalerContext, int glyphCode);8788abstract void getGlyphMetrics(long pScalerContext, int glyphCode,89Point2D.Float metrics);9091abstract long getGlyphImage(long pScalerContext, int glyphCode);9293/* These 3 outline methods should be implemented to return94* values in device space. Callers need to be aware of this95* as typically Java client code will need to have them in user space.96*/97abstract Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext,98int glyphCode);99100abstract GeneralPath getGlyphOutline(long pScalerContext, int glyphCode,101float x, float y);102103abstract GeneralPath getGlyphVectorOutline(long pScalerContext,104int[] glyphs, int numGlyphs,105float x, float y);106}107108109