1 /*
2  * Copyright (c) 2007, 2011, 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.geom.GeneralPath;
29 import java.awt.geom.Point2D;
30 import java.awt.geom.Rectangle2D;
31 
32 class NullFontScaler extends FontScaler {
NullFontScaler()33     NullFontScaler() {}
34 
NullFontScaler(Font2D font, int indexInCollection, boolean supportsCJK, int filesize)35     public NullFontScaler(Font2D font, int indexInCollection,
36         boolean supportsCJK, int filesize) {}
37 
getFontMetrics(long pScalerContext)38     StrikeMetrics getFontMetrics(long pScalerContext) {
39         return new StrikeMetrics(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
40                                  0.0f, 0.0f, 0.0f, 0.0f);
41     }
42 
getGlyphAdvance(long pScalerContext, int glyphCode)43     float getGlyphAdvance(long pScalerContext, int glyphCode) {
44         return 0.0f;
45     }
46 
getGlyphMetrics(long pScalerContext, int glyphCode, Point2D.Float metrics)47     void getGlyphMetrics(long pScalerContext, int glyphCode,
48         Point2D.Float metrics) {
49         metrics.x = 0;
50         metrics.y = 0;
51     }
52 
getGlyphOutlineBounds(long pContext, int glyphCode)53     Rectangle2D.Float getGlyphOutlineBounds(long pContext, int glyphCode) {
54         return new Rectangle2D.Float(0, 0, 0, 0);
55     }
56 
getGlyphOutline(long pScalerContext, int glyphCode, float x, float y)57     GeneralPath getGlyphOutline(long pScalerContext, int glyphCode,
58         float x, float y) {
59         return new GeneralPath();
60     }
61 
getGlyphVectorOutline(long pScalerContext, int[] glyphs, int numGlyphs, float x, float y)62     GeneralPath getGlyphVectorOutline(long pScalerContext, int[] glyphs,
63         int numGlyphs, float x, float y) {
64         return new GeneralPath();
65     }
66 
createScalerContext(double[] matrix, int aa, int fm, float boldness, float italic, boolean disableHinting)67     long createScalerContext(double[] matrix, int aa,
68         int fm, float boldness, float italic, boolean disableHinting) {
69         return getNullScalerContext();
70     }
71 
invalidateScalerContext(long pScalerContext)72     void invalidateScalerContext(long pScalerContext) {
73         //nothing to do
74     }
75 
getNumGlyphs()76     int getNumGlyphs() throws FontScalerException {
77         return 1;
78     }
79 
getMissingGlyphCode()80     int getMissingGlyphCode() throws FontScalerException {
81         return 0;
82     }
83 
getGlyphCode(char charCode)84     int getGlyphCode(char charCode) throws FontScalerException {
85         return 0;
86     }
87 
getUnitsPerEm()88     long getUnitsPerEm() {
89         return 2048;
90     }
91 
getGlyphPoint(long pScalerContext, int glyphCode, int ptNumber)92     Point2D.Float getGlyphPoint(long pScalerContext,
93                                 int glyphCode, int ptNumber) {
94         return null;
95     }
96 
97     /* Ideally NullFontScaler should not have native code.
98        However, at this moment we need these methods to be native because:
99          - glyph cache code assumes null pointers to GlyphInfo structures
100          - FileFontStrike needs native context
101     */
getNullScalerContext()102     static native long getNullScalerContext();
getGlyphImage(long pScalerContext, int glyphCode)103     native long getGlyphImage(long pScalerContext, int glyphCode);
104 }
105