Path: blob/master/src/java.desktop/share/classes/sun/font/NullFontScaler.java
41154 views
/*1* Copyright (c) 2007, 2011, 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.geom.GeneralPath;28import java.awt.geom.Point2D;29import java.awt.geom.Rectangle2D;3031class NullFontScaler extends FontScaler {32NullFontScaler() {}3334public NullFontScaler(Font2D font, int indexInCollection,35boolean supportsCJK, int filesize) {}3637StrikeMetrics getFontMetrics(long pScalerContext) {38return new StrikeMetrics(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,390.0f, 0.0f, 0.0f, 0.0f);40}4142float getGlyphAdvance(long pScalerContext, int glyphCode) {43return 0.0f;44}4546void getGlyphMetrics(long pScalerContext, int glyphCode,47Point2D.Float metrics) {48metrics.x = 0;49metrics.y = 0;50}5152Rectangle2D.Float getGlyphOutlineBounds(long pContext, int glyphCode) {53return new Rectangle2D.Float(0, 0, 0, 0);54}5556GeneralPath getGlyphOutline(long pScalerContext, int glyphCode,57float x, float y) {58return new GeneralPath();59}6061GeneralPath getGlyphVectorOutline(long pScalerContext, int[] glyphs,62int numGlyphs, float x, float y) {63return new GeneralPath();64}6566long createScalerContext(double[] matrix, int aa,67int fm, float boldness, float italic) {68return getNullScalerContext();69}7071void invalidateScalerContext(long pScalerContext) {72//nothing to do73}7475int getNumGlyphs() throws FontScalerException {76return 1;77}7879int getMissingGlyphCode() throws FontScalerException {80return 0;81}8283int getGlyphCode(char charCode) throws FontScalerException {84return 0;85}8687long getUnitsPerEm() {88return 2048;89}9091Point2D.Float getGlyphPoint(long pScalerContext,92int glyphCode, int ptNumber) {93return null;94}9596/* Ideally NullFontScaler should not have native code.97However, at this moment we need these methods to be native because:98- glyph cache code assumes null pointers to GlyphInfo structures99- FileFontStrike needs native context100*/101static native long getNullScalerContext();102native long getGlyphImage(long pScalerContext, int glyphCode);103}104105106