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
/*
 * %W% %G%
 *
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package sun.font;

import java.awt.FontFormatException;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.FileInputStream;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public abstract class PhysicalFont extends Font2D {

    protected String platName;
    // nativeNames is a String or a (possibly null) String[].
    protected Object nativeNames;

    public boolean equals(Object o) {
    return (o != null && o.getClass() == this.getClass() &&
        ((Font2D)o).fullName.equals(this.fullName));
    }
    
    public int hashCode() {
    return fullName.hashCode();
    }

    /**
     * Opens the file (temporarily) and does basic verification.
     * Initializes the CMAP
     * @throws FontFormatException - if the font can't be opened
     * or fails verification,  or there's no usable cmap
     */
    PhysicalFont(String platname, Object nativeNames)
    throws FontFormatException {

    handle = new Font2DHandle(this);
    this.platName = platname;
    this.nativeNames = nativeNames;
    }

    protected PhysicalFont() {
    handle = new Font2DHandle(this);
    }

    /* The following methods are delegated to the font by the strike
     * for physical fonts as the PhysicalFont holds a shared reference
     * to the native resource, so all invocations need to be directed
     * through a synchronization point. Implementations of these methods
     * will typically be "synchronized native"
     */

    Point2D.Float getGlyphPoint(long pScalerContext,
                 int glyphCode, int ptNumber) {
    return new Point2D.Float();
    }

    /* These 3 metrics methods should be implemented to return
     * values in user space.
     */
    abstract StrikeMetrics getFontMetrics(long pScalerContext);

    abstract float getGlyphAdvance(long pScalerContext, int glyphCode);

    abstract void getGlyphMetrics(long pScalerContext, int glyphCode,
                  Point2D.Float metrics);

    abstract long getGlyphImage(long pScalerContext, int glyphCode);

    /* These 3 outline methods should be implemented to return
     * values in device space. Callers need to be aware of this
     * as typically Java client code will need to have them in user space.
     */
    abstract Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext,
                             int glyphCode);

    abstract GeneralPath getGlyphOutline(long pScalerContext, int glyphCode,
                     float x, float y);

    abstract GeneralPath getGlyphVectorOutline(long pScalerContext,
                           int[] glyphs, int numGlyphs,
                           float x, float y);
}
			
			

Browsed Source: [clear]