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

Print this page




 745         String fontName = f.fullName;
 746         String familyName = f.familyName;
 747         if (fontName == null || "".equals(fontName)) {
 748             return null;
 749         }
 750         if (compositeFonts.containsKey(fontName)) {
 751             /* Don't register any font that has the same name as a composite */
 752             return null;
 753         }
 754         f.setRank(rank);
 755         if (!physicalFonts.containsKey(fontName)) {
 756             if (FontUtilities.isLogging()) {
 757                 FontUtilities.getLogger().info("Add to Family "+familyName +
 758                             ", Font " + fontName + " rank="+rank);
 759             }
 760             physicalFonts.put(fontName, f);
 761             FontFamily family = FontFamily.getFamily(familyName);
 762             if (family == null) {
 763                 family = new FontFamily(familyName, false, rank);
 764                 family.setFont(f, f.style);
 765             } else if (family.getRank() >= rank) {
 766                 family.setFont(f, f.style);
 767             }
 768             fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH), f);
 769             return f;
 770         } else {
 771             PhysicalFont newFont = f;
 772             PhysicalFont oldFont = physicalFonts.get(fontName);
 773             if (oldFont == null) {
 774                 return null;
 775             }
 776             /* If the new font is of an equal or higher rank, it is a
 777              * candidate to replace the current one, subject to further tests.
 778              */
 779             if (oldFont.getRank() >= rank) {
 780 
 781                 /* All fonts initialise their mapper when first
 782                  * used. If the mapper is non-null then this font
 783                  * has been accessed at least once. In that case
 784                  * do not replace it. This may be overly stringent,
 785                  * but its probably better not to replace a font that


 836                     }
 837                     return oldFont;
 838                 }
 839 
 840                 if (FontUtilities.isLogging()) {
 841                     FontUtilities.getLogger()
 842                           .info("Replace in Family " + familyName +
 843                                 ",Font " + fontName + " new rank="+rank +
 844                                 " from " + oldFont.platName +
 845                                 " with " + newFont.platName);
 846                 }
 847                 replaceFont(oldFont, newFont);
 848                 physicalFonts.put(fontName, newFont);
 849                 fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH),
 850                                    newFont);
 851 
 852                 FontFamily family = FontFamily.getFamily(familyName);
 853                 if (family == null) {
 854                     family = new FontFamily(familyName, false, rank);
 855                     family.setFont(newFont, newFont.style);
 856                 } else if (family.getRank() >= rank) {
 857                     family.setFont(newFont, newFont.style);
 858                 }
 859                 return newFont;
 860             } else {
 861                 return oldFont;
 862             }
 863         }
 864     }
 865 
 866     public Font2D[] getRegisteredFonts() {
 867         PhysicalFont[] physFonts = getPhysicalFonts();
 868         int mcf = maxCompFont; /* for MT-safety */
 869         Font2D[] regFonts = new Font2D[physFonts.length+mcf];
 870         System.arraycopy(compFonts, 0, regFonts, 0, mcf);
 871         System.arraycopy(physFonts, 0, regFonts, mcf, physFonts.length);
 872         return regFonts;
 873     }
 874 
 875     protected PhysicalFont[] getPhysicalFonts() {
 876         return physicalFonts.values().toArray(new PhysicalFont[0]);




 745         String fontName = f.fullName;
 746         String familyName = f.familyName;
 747         if (fontName == null || "".equals(fontName)) {
 748             return null;
 749         }
 750         if (compositeFonts.containsKey(fontName)) {
 751             /* Don't register any font that has the same name as a composite */
 752             return null;
 753         }
 754         f.setRank(rank);
 755         if (!physicalFonts.containsKey(fontName)) {
 756             if (FontUtilities.isLogging()) {
 757                 FontUtilities.getLogger().info("Add to Family "+familyName +
 758                             ", Font " + fontName + " rank="+rank);
 759             }
 760             physicalFonts.put(fontName, f);
 761             FontFamily family = FontFamily.getFamily(familyName);
 762             if (family == null) {
 763                 family = new FontFamily(familyName, false, rank);
 764                 family.setFont(f, f.style);
 765             } else {
 766                 family.setFont(f, f.style);
 767             }
 768             fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH), f);
 769             return f;
 770         } else {
 771             PhysicalFont newFont = f;
 772             PhysicalFont oldFont = physicalFonts.get(fontName);
 773             if (oldFont == null) {
 774                 return null;
 775             }
 776             /* If the new font is of an equal or higher rank, it is a
 777              * candidate to replace the current one, subject to further tests.
 778              */
 779             if (oldFont.getRank() >= rank) {
 780 
 781                 /* All fonts initialise their mapper when first
 782                  * used. If the mapper is non-null then this font
 783                  * has been accessed at least once. In that case
 784                  * do not replace it. This may be overly stringent,
 785                  * but its probably better not to replace a font that


 836                     }
 837                     return oldFont;
 838                 }
 839 
 840                 if (FontUtilities.isLogging()) {
 841                     FontUtilities.getLogger()
 842                           .info("Replace in Family " + familyName +
 843                                 ",Font " + fontName + " new rank="+rank +
 844                                 " from " + oldFont.platName +
 845                                 " with " + newFont.platName);
 846                 }
 847                 replaceFont(oldFont, newFont);
 848                 physicalFonts.put(fontName, newFont);
 849                 fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH),
 850                                    newFont);
 851 
 852                 FontFamily family = FontFamily.getFamily(familyName);
 853                 if (family == null) {
 854                     family = new FontFamily(familyName, false, rank);
 855                     family.setFont(newFont, newFont.style);
 856                 } else {
 857                     family.setFont(newFont, newFont.style);
 858                 }
 859                 return newFont;
 860             } else {
 861                 return oldFont;
 862             }
 863         }
 864     }
 865 
 866     public Font2D[] getRegisteredFonts() {
 867         PhysicalFont[] physFonts = getPhysicalFonts();
 868         int mcf = maxCompFont; /* for MT-safety */
 869         Font2D[] regFonts = new Font2D[physFonts.length+mcf];
 870         System.arraycopy(compFonts, 0, regFonts, 0, mcf);
 871         System.arraycopy(physFonts, 0, regFonts, mcf, physFonts.length);
 872         return regFonts;
 873     }
 874 
 875     protected PhysicalFont[] getPhysicalFonts() {
 876         return physicalFonts.values().toArray(new PhysicalFont[0]);