1 18 package org.apache.batik.gvt.font; 19 20 import java.awt.Font ; 21 import java.awt.font.TextAttribute ; 22 import java.text.AttributedCharacterIterator ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 import org.apache.batik.gvt.text.GVTAttributedCharacterIterator; 26 27 33 public class AWTFontFamily implements GVTFontFamily { 34 35 protected GVTFontFace fontFace; 36 protected Font font; 37 38 43 public AWTFontFamily(GVTFontFace fontFace) { 44 this.fontFace = fontFace; 45 } 46 47 52 public AWTFontFamily(String familyName) { 53 this(new GVTFontFace(familyName)); 54 } 55 56 61 public AWTFontFamily(GVTFontFace fontFace, Font font) { 62 this.fontFace = fontFace; 63 this.font = font; 64 } 65 66 71 public String getFamilyName() { 72 return fontFace.getFamilyName(); 73 } 74 75 78 public GVTFontFace getFontFace() { 79 return fontFace; 80 } 81 82 89 public GVTFont deriveFont(float size, AttributedCharacterIterator aci) { 90 if (font != null) 91 return new AWTGVTFont(font, size); 92 93 return deriveFont(size, aci.getAttributes()); 94 } 95 96 97 102 public GVTFont deriveFont(float size, Map attrs) { 103 if (font != null) 104 return new AWTGVTFont(font, size); 105 106 Map fontAttributes = new HashMap (attrs); 107 fontAttributes.put(TextAttribute.SIZE, new Float (size)); 108 fontAttributes.put(TextAttribute.FAMILY, fontFace.getFamilyName()); 109 fontAttributes.remove(GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER); 110 return new AWTGVTFont(fontAttributes); 111 } 112 113 } 114 | Popular Tags |