jdk/src/share/classes/sun/font/FreetypeFontScaler.java
author prr
Fri, 27 May 2011 13:25:54 -0700
changeset 9759 90976a831a86
parent 9035 1255eb81cc2f
child 20414 c43f5228a1f9
permissions -rw-r--r--
7046587: Outlines in OTF/CFF fonts are misclassified as quadratic curves Reviewed-by: igor
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7940
diff changeset
     2
 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3928
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.geom.GeneralPath;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.geom.Point2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.geom.Rectangle2D;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.ref.WeakReference;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/* This is Freetype based implementation of FontScaler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Note that in case of runtime error it is expected that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * native code will release all native resources and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * call invalidateScaler() (that will throw FontScalerException).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Note that callee is responsible for releasing native scaler context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
class FreetypeFontScaler extends FontScaler {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    /* constants aligned with native code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static final int TRUETYPE_FONT = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static final int TYPE1_FONT = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        /* At the moment fontmanager library depends on freetype library
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
           and therefore no need to load it explicitly here */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        FontManagerNativeLibrary.load();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        initIDs(FreetypeFontScaler.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private static native void initIDs(Class FFS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private void invalidateScaler() throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        nativeScaler = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        font = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        throw new FontScalerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    public FreetypeFontScaler(Font2D font, int indexInCollection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                     boolean supportsCJK, int filesize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        int fonttype = TRUETYPE_FONT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        if (font instanceof Type1Font) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            fonttype = TYPE1_FONT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        nativeScaler = initNativeScaler(font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                                        fonttype,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                                        indexInCollection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                                        supportsCJK,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                                        filesize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        this.font = new WeakReference(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    synchronized StrikeMetrics getFontMetrics(long pScalerContext)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                return getFontMetricsNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                            pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                                            nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
    82
        return FontScaler.getNullScaler().getFontMetrics(0L);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    synchronized float getGlyphAdvance(long pScalerContext, int glyphCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            return getGlyphAdvanceNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
                                         pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                                         nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                                         glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
    93
        return FontScaler.getNullScaler().
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
    94
            getGlyphAdvance(0L, glyphCode);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    synchronized void getGlyphMetrics(long pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                     int glyphCode, Point2D.Float metrics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            getGlyphMetricsNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                                  pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                                  nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                                  glyphCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                                  metrics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   108
        FontScaler.getNullScaler().
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   109
            getGlyphMetrics(0L, glyphCode, metrics);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    synchronized long getGlyphImage(long pScalerContext, int glyphCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            return getGlyphImageNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                       pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                       nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                       glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   120
        return FontScaler.getNullScaler().
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   121
            getGlyphImage(0L, glyphCode);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    synchronized Rectangle2D.Float getGlyphOutlineBounds(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                     long pScalerContext, int glyphCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            return getGlyphOutlineBoundsNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                               pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                               nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                                               glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   133
        return FontScaler.getNullScaler().
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   134
            getGlyphOutlineBounds(0L,glyphCode);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    synchronized GeneralPath getGlyphOutline(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                     long pScalerContext, int glyphCode, float x, float y)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                     throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            return getGlyphOutlineNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                                         pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                                         nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                         glyphCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                                         x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   147
        return FontScaler.getNullScaler().
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   148
            getGlyphOutline(0L, glyphCode, x,y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    synchronized GeneralPath getGlyphVectorOutline(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                     long pScalerContext, int[] glyphs, int numGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                     float x, float y) throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            return getGlyphVectorOutlineNative(font.get(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                               pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                               nativeScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                               glyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                                               numGlyphs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                               x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   162
        return FontScaler
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   163
            .getNullScaler().getGlyphVectorOutline(0L, glyphs, numGlyphs, x, y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    synchronized long getLayoutTableCache() throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        return getLayoutTableCacheNative(nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public synchronized void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            disposeNativeScaler(nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            nativeScaler = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    synchronized int getNumGlyphs() throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            return getNumGlyphsNative(nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   181
        return FontScaler.getNullScaler().getNumGlyphs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    synchronized int getMissingGlyphCode()  throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            return getMissingGlyphCodeNative(nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   188
        return FontScaler.getNullScaler().getMissingGlyphCode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    synchronized int getGlyphCode(char charCode) throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            return getGlyphCodeNative(nativeScaler, charCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   195
        return FontScaler.getNullScaler().getGlyphCode(charCode);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    synchronized Point2D.Float getGlyphPoint(long pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                       int glyphCode, int ptNumber)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                               throws FontScalerException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            return getGlyphPointNative(font.get(), pScalerContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                      nativeScaler, glyphCode, ptNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
3928
be186a33df9b 6795908: Refactor FontManager
rkennke
parents: 2
diff changeset
   205
        return FontScaler.getNullScaler().getGlyphPoint(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                   pScalerContext, glyphCode,  ptNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    synchronized long getUnitsPerEm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        return getUnitsPerEMNative(nativeScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
9759
90976a831a86 7046587: Outlines in OTF/CFF fonts are misclassified as quadratic curves
prr
parents: 9035
diff changeset
   213
    long createScalerContext(double[] matrix,
7940
7d20d72dd3b9 6930980: Disable TrueType hinting for fonts known not to hint well
prr
parents: 5506
diff changeset
   214
            int aa, int fm, float boldness, float italic,
7d20d72dd3b9 6930980: Disable TrueType hinting for fonts known not to hint well
prr
parents: 5506
diff changeset
   215
            boolean disableHinting) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (nativeScaler != 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return createScalerContextNative(nativeScaler, matrix,
9759
90976a831a86 7046587: Outlines in OTF/CFF fonts are misclassified as quadratic curves
prr
parents: 9035
diff changeset
   218
                                             aa, fm, boldness, italic);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        return NullFontScaler.getNullScalerContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    //Note: native methods can throw RuntimeException if processing fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private native long initNativeScaler(Font2D font, int type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            int indexInCollection, boolean supportsCJK, int filesize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private native StrikeMetrics getFontMetricsNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            long pScalerContext, long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    private native float getGlyphAdvanceNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            long pScalerContext, long pScaler, int glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    private native void getGlyphMetricsNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            long pScalerContext, long pScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            int glyphCode, Point2D.Float metrics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    private native long getGlyphImageNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            long pScalerContext, long pScaler, int glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    private native Rectangle2D.Float getGlyphOutlineBoundsNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            long pScalerContext, long pScaler, int glyphCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    private native GeneralPath getGlyphOutlineNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            long pScalerContext, long pScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            int glyphCode, float x, float y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    private native GeneralPath getGlyphVectorOutlineNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            long pScalerContext, long pScaler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            int[] glyphs, int numGlyphs, float x, float y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    native Point2D.Float getGlyphPointNative(Font2D font,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            long pScalerContext, long pScaler, int glyphCode, int ptNumber);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    private native long getLayoutTableCacheNative(long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    private native void disposeNativeScaler(long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    private native int getGlyphCodeNative(long pScaler, char charCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private native int getNumGlyphsNative(long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    private native int getMissingGlyphCodeNative(long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    private native long getUnitsPerEMNative(long pScaler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    native long createScalerContextNative(long pScaler, double[] matrix,
9759
90976a831a86 7046587: Outlines in OTF/CFF fonts are misclassified as quadratic curves
prr
parents: 9035
diff changeset
   257
            int aa, int fm, float boldness, float italic);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /* Freetype scaler context does not contain any pointers that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
       has to be invalidated if native scaler is bad */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    void invalidateScalerContext(long pScalerContext) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
}