src/share/classes/sun/font/CMap.java

Print this page
rev 677 : 8006795: Improve font warning messages
Reviewed-by: bae, jgodinez, mschoene

 824                         (idRangeOffSetArray[key] - glyphArrayOffset)/2;
 825                 char glyphCode = glyphIndexArray[glyphSubArrayStart+mapMe];
 826                 if (glyphCode != 0) {
 827                     glyphCode += idDeltaArray[key]; //idDelta
 828                     return glyphCode;
 829                 }
 830             }
 831             return 0;
 832         }
 833     }
 834 
 835     // Format 6: Trimmed table mapping
 836     static class CMapFormat6 extends CMap {
 837 
 838         char firstCode;
 839         char entryCount;
 840         char[] glyphIdArray;
 841 
 842         CMapFormat6(ByteBuffer bbuffer, int offset, char[] xlat) {
 843 
 844              System.err.println("WARNING: CMapFormat8 is untested.");
 845              bbuffer.position(offset+6);
 846              CharBuffer buffer = bbuffer.asCharBuffer();
 847              firstCode = buffer.get();
 848              entryCount = buffer.get();
 849              glyphIdArray = new char[entryCount];
 850              for (int i=0; i< entryCount; i++) {
 851                  glyphIdArray[i] = buffer.get();
 852              }
 853          }
 854 
 855          char getGlyph(int charCode) {
 856             int controlGlyph = getControlCodeGlyph(charCode, true);
 857             if (controlGlyph >= 0) {
 858                 return (char)controlGlyph;
 859             }
 860 
 861              if (xlat != null) {
 862                  charCode = xlat[charCode];
 863              }
 864 


 867                   return 0;
 868              } else {
 869                   return glyphIdArray[charCode];
 870              }
 871          }
 872     }
 873 
 874     // Format 8: mixed 16-bit and 32-bit coverage
 875     // Seems unlikely this code will ever get tested as we look for
 876     // MS platform Cmaps and MS states (in the Opentype spec on their website)
 877     // that MS doesn't support this format
 878     static class CMapFormat8 extends CMap {
 879          byte[] is32 = new byte[8192];
 880          int nGroups;
 881          int[] startCharCode;
 882          int[] endCharCode;
 883          int[] startGlyphID;
 884 
 885          CMapFormat8(ByteBuffer bbuffer, int offset, char[] xlat) {
 886 
 887              System.err.println("WARNING: CMapFormat8 is untested.");
 888              bbuffer.position(12);
 889              bbuffer.get(is32);
 890              nGroups = bbuffer.getInt();
 891              startCharCode = new int[nGroups];
 892              endCharCode   = new int[nGroups];
 893              startGlyphID  = new int[nGroups];
 894          }
 895 
 896         char getGlyph(int charCode) {
 897             if (xlat != null) {
 898                 throw new RuntimeException("xlat array for cmap fmt=8");
 899             }
 900             return 0;
 901         }
 902 
 903     }
 904 
 905 
 906     // Format 4-byte 10: Trimmed table mapping
 907     // Seems unlikely this code will ever get tested as we look for
 908     // MS platform Cmaps and MS states (in the Opentype spec on their website)
 909     // that MS doesn't support this format
 910     static class CMapFormat10 extends CMap {
 911 
 912          long firstCode;
 913          int entryCount;
 914          char[] glyphIdArray;
 915 
 916          CMapFormat10(ByteBuffer bbuffer, int offset, char[] xlat) {
 917 
 918              System.err.println("WARNING: CMapFormat10 is untested.");
 919              firstCode = bbuffer.getInt() & INTMASK;
 920              entryCount = bbuffer.getInt() & INTMASK;
 921              bbuffer.position(offset+20);
 922              CharBuffer buffer = bbuffer.asCharBuffer();
 923              glyphIdArray = new char[entryCount];
 924              for (int i=0; i< entryCount; i++) {
 925                  glyphIdArray[i] = buffer.get();
 926              }
 927          }
 928 
 929          char getGlyph(int charCode) {
 930 
 931              if (xlat != null) {
 932                  throw new RuntimeException("xlat array for cmap fmt=10");
 933              }
 934 
 935              int code = (int)(charCode - firstCode);
 936              if (code < 0 || code >= entryCount) {
 937                  return 0;
 938              } else {



 824                         (idRangeOffSetArray[key] - glyphArrayOffset)/2;
 825                 char glyphCode = glyphIndexArray[glyphSubArrayStart+mapMe];
 826                 if (glyphCode != 0) {
 827                     glyphCode += idDeltaArray[key]; //idDelta
 828                     return glyphCode;
 829                 }
 830             }
 831             return 0;
 832         }
 833     }
 834 
 835     // Format 6: Trimmed table mapping
 836     static class CMapFormat6 extends CMap {
 837 
 838         char firstCode;
 839         char entryCount;
 840         char[] glyphIdArray;
 841 
 842         CMapFormat6(ByteBuffer bbuffer, int offset, char[] xlat) {
 843 

 844              bbuffer.position(offset+6);
 845              CharBuffer buffer = bbuffer.asCharBuffer();
 846              firstCode = buffer.get();
 847              entryCount = buffer.get();
 848              glyphIdArray = new char[entryCount];
 849              for (int i=0; i< entryCount; i++) {
 850                  glyphIdArray[i] = buffer.get();
 851              }
 852          }
 853 
 854          char getGlyph(int charCode) {
 855             int controlGlyph = getControlCodeGlyph(charCode, true);
 856             if (controlGlyph >= 0) {
 857                 return (char)controlGlyph;
 858             }
 859 
 860              if (xlat != null) {
 861                  charCode = xlat[charCode];
 862              }
 863 


 866                   return 0;
 867              } else {
 868                   return glyphIdArray[charCode];
 869              }
 870          }
 871     }
 872 
 873     // Format 8: mixed 16-bit and 32-bit coverage
 874     // Seems unlikely this code will ever get tested as we look for
 875     // MS platform Cmaps and MS states (in the Opentype spec on their website)
 876     // that MS doesn't support this format
 877     static class CMapFormat8 extends CMap {
 878          byte[] is32 = new byte[8192];
 879          int nGroups;
 880          int[] startCharCode;
 881          int[] endCharCode;
 882          int[] startGlyphID;
 883 
 884          CMapFormat8(ByteBuffer bbuffer, int offset, char[] xlat) {
 885 

 886              bbuffer.position(12);
 887              bbuffer.get(is32);
 888              nGroups = bbuffer.getInt();
 889              startCharCode = new int[nGroups];
 890              endCharCode   = new int[nGroups];
 891              startGlyphID  = new int[nGroups];
 892          }
 893 
 894         char getGlyph(int charCode) {
 895             if (xlat != null) {
 896                 throw new RuntimeException("xlat array for cmap fmt=8");
 897             }
 898             return 0;
 899         }
 900 
 901     }
 902 
 903 
 904     // Format 4-byte 10: Trimmed table mapping
 905     // Seems unlikely this code will ever get tested as we look for
 906     // MS platform Cmaps and MS states (in the Opentype spec on their website)
 907     // that MS doesn't support this format
 908     static class CMapFormat10 extends CMap {
 909 
 910          long firstCode;
 911          int entryCount;
 912          char[] glyphIdArray;
 913 
 914          CMapFormat10(ByteBuffer bbuffer, int offset, char[] xlat) {
 915 

 916              firstCode = bbuffer.getInt() & INTMASK;
 917              entryCount = bbuffer.getInt() & INTMASK;
 918              bbuffer.position(offset+20);
 919              CharBuffer buffer = bbuffer.asCharBuffer();
 920              glyphIdArray = new char[entryCount];
 921              for (int i=0; i< entryCount; i++) {
 922                  glyphIdArray[i] = buffer.get();
 923              }
 924          }
 925 
 926          char getGlyph(int charCode) {
 927 
 928              if (xlat != null) {
 929                  throw new RuntimeException("xlat array for cmap fmt=10");
 930              }
 931 
 932              int code = (int)(charCode - firstCode);
 933              if (code < 0 || code >= entryCount) {
 934                  return 0;
 935              } else {