Showing the changes to java/pkg/sun/font/PhysicalFont.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,107 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.font; | ||
| 27 | |||
| 28 | import java.awt.FontFormatException; | ||
| 29 | import java.awt.geom.GeneralPath; | ||
| 30 | import java.awt.geom.Point2D; | ||
| 31 | import java.awt.geom.Rectangle2D; | ||
| 32 | import java.io.FileInputStream; | ||
| 33 | import java.lang.ref.WeakReference; | ||
| 34 | import java.nio.ByteBuffer; | ||
| 35 | import java.nio.channels.FileChannel; | ||
| 36 | |||
| 37 | public abstract class PhysicalFont extends Font2D { | ||
| 38 | |||
| 39 | protected String platName; | ||
| 40 | // nativeNames is a String or a (possibly null) String[]. | ||
| 41 | protected Object nativeNames; | ||
| 42 | |||
| 43 | public boolean equals(Object o) { | ||
| 44 | return (o != null && o.getClass() == this.getClass() && | ||
| 45 | ((Font2D)o).fullName.equals(this.fullName)); | ||
| 46 | } | ||
| 47 | |||
| 48 | public int hashCode() { | ||
| 49 | return fullName.hashCode(); | ||
| 50 | } | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Opens the file (temporarily) and does basic verification. | ||
| 54 | * Initializes the CMAP | ||
| 55 | * @throws FontFormatException - if the font can't be opened | ||
| 56 | * or fails verification, or there's no usable cmap | ||
| 57 | */ | ||
| 58 | PhysicalFont(String platname, Object nativeNames) | ||
| 59 | throws FontFormatException { | ||
| 60 | |||
| 61 | handle = new Font2DHandle(this); | ||
| 62 | this.platName = platname; | ||
| 63 | this.nativeNames = nativeNames; | ||
| 64 | } | ||
| 65 | |||
| 66 | protected PhysicalFont() { | ||
| 67 | handle = new Font2DHandle(this); | ||
| 68 | } | ||
| 69 | |||
| 70 | /* The following methods are delegated to the font by the strike | ||
| 71 | * for physical fonts as the PhysicalFont holds a shared reference | ||
| 72 | * to the native resource, so all invocations need to be directed | ||
| 73 | * through a synchronization point. Implementations of these methods | ||
| 74 | * will typically be "synchronized native" | ||
| 75 | */ | ||
| 76 | |||
| 77 | Point2D.Float getGlyphPoint(long pScalerContext, | ||
| 78 | int glyphCode, int ptNumber) { | ||
| 79 | return new Point2D.Float(); | ||
| 80 | } | ||
| 81 | |||
| 82 | /* These 3 metrics methods should be implemented to return | ||
| 83 | * values in user space. | ||
| 84 | */ | ||
| 85 | abstract StrikeMetrics getFontMetrics(long pScalerContext); | ||
| 86 | |||
| 87 | abstract float getGlyphAdvance(long pScalerContext, int glyphCode); | ||
| 88 | |||
| 89 | abstract void getGlyphMetrics(long pScalerContext, int glyphCode, | ||
| 90 | Point2D.Float metrics); | ||
| 91 | |||
| 92 | abstract long getGlyphImage(long pScalerContext, int glyphCode); | ||
| 93 | |||
| 94 | /* These 3 outline methods should be implemented to return | ||
| 95 | * values in device space. Callers need to be aware of this | ||
| 96 | * as typically Java client code will need to have them in user space. | ||
| 97 | */ | ||
| 98 | abstract Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext, | ||
| 99 | int glyphCode); | ||
| 100 | |||
| 101 | abstract GeneralPath getGlyphOutline(long pScalerContext, int glyphCode, | ||
| 102 | float x, float y); | ||
| 103 | |||
| 104 | abstract GeneralPath getGlyphVectorOutline(long pScalerContext, | ||
| 105 | int[] glyphs, int numGlyphs, | ||
| 106 | float x, float y); | ||
| 107 | } | ||