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

Print this page




  25 
  26 package sun.font;
  27 
  28 /* remember that the API requires a Font use a
  29  * consistent glyph id. for a code point, and this is a
  30  * problem if a particular strike uses native scaler sometimes
  31  * and T2K others. That needs to be dealt with somewhere, but
  32  * here we can just always get the same glyph code without
  33  * needing a strike.
  34  *
  35  * The C implementation would cache the results of anything up
  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 final 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          */




  25 
  26 package sun.font;
  27 
  28 /* remember that the API requires a Font use a
  29  * consistent glyph id. for a code point, and this is a
  30  * problem if a particular strike uses native scaler sometimes
  31  * and T2K others. That needs to be dealt with somewhere, but
  32  * here we can just always get the same glyph code without
  33  * needing a strike.
  34  *
  35  * The C implementation would cache the results of anything up
  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          */