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