< prev index next >

src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2006, 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


  36  * to the maximum surrogate pair code point.
  37  * This implementation will not cache as much, since the storage
  38  * requirements are not justifiable. Even so it still can use up
  39  * to 216*256*4 bytes of storage per composite font. If an app
  40  * calls canDisplay on this range for all 20 composite fonts that's
  41  * over 1Mb of cached data. May need to employ WeakReferences if
  42  * this appears to cause problems.
  43  */
  44 
  45 public class CompositeGlyphMapper extends CharToGlyphMapper {
  46 
  47     public static final int SLOTMASK =  0xff000000;
  48     public static final int GLYPHMASK = 0x00ffffff;
  49 
  50     public static final int NBLOCKS = 216;
  51     public static final int BLOCKSZ = 256;
  52     public static final int MAXUNICODE = NBLOCKS*BLOCKSZ;
  53 
  54 
  55     CompositeFont font;
  56     CharToGlyphMapper slotMappers[];
  57     int[][] glyphMaps;
  58     private boolean hasExcludes;
  59 
  60     public CompositeGlyphMapper(CompositeFont compFont) {
  61         font = compFont;
  62         initMapper();
  63         /* This is often false which saves the overhead of a
  64          * per-mapped char method call.
  65          */
  66         hasExcludes = compFont.exclusionRanges != null &&
  67                       compFont.maxIndices != null;
  68     }
  69 
  70     public int compositeGlyphCode(int slot, int glyphCode) {
  71         return (slot << 24 | (glyphCode & GLYPHMASK));
  72     }
  73 
  74     private void initMapper() {
  75         if (missingGlyph == CharToGlyphMapper.UNINITIALIZED_GLYPH) {
  76             if (glyphMaps == null) {


   1 /*
   2  * Copyright (c) 2003, 2018, 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


  36  * to the maximum surrogate pair code point.
  37  * This implementation will not cache as much, since the storage
  38  * requirements are not justifiable. Even so it still can use up
  39  * to 216*256*4 bytes of storage per composite font. If an app
  40  * calls canDisplay on this range for all 20 composite fonts that's
  41  * over 1Mb of cached data. May need to employ WeakReferences if
  42  * this appears to cause problems.
  43  */
  44 
  45 public class CompositeGlyphMapper extends CharToGlyphMapper {
  46 
  47     public static final int SLOTMASK =  0xff000000;
  48     public static final int GLYPHMASK = 0x00ffffff;
  49 
  50     public static final int NBLOCKS = 216;
  51     public static final int BLOCKSZ = 256;
  52     public static final int MAXUNICODE = NBLOCKS*BLOCKSZ;
  53 
  54 
  55     CompositeFont font;
  56     CharToGlyphMapper[] slotMappers;
  57     int[][] glyphMaps;
  58     private boolean hasExcludes;
  59 
  60     public CompositeGlyphMapper(CompositeFont compFont) {
  61         font = compFont;
  62         initMapper();
  63         /* This is often false which saves the overhead of a
  64          * per-mapped char method call.
  65          */
  66         hasExcludes = compFont.exclusionRanges != null &&
  67                       compFont.maxIndices != null;
  68     }
  69 
  70     public int compositeGlyphCode(int slot, int glyphCode) {
  71         return (slot << 24 | (glyphCode & GLYPHMASK));
  72     }
  73 
  74     private void initMapper() {
  75         if (missingGlyph == CharToGlyphMapper.UNINITIALIZED_GLYPH) {
  76             if (glyphMaps == null) {


< prev index next >