1 package org.joshy.html.css; 2 3 import java.awt.Font ; 4 import org.joshy.html.Context; 5 import org.joshy.u; 6 7 public class FontResolver { 8 9 public Font resolveFont(Context c, String [] families, float size, String weight, String style) { 10 Font f = c.getGraphics().getFont(); 11 f = f.deriveFont((float)size); 12 13 if(weight.equals("bold")) { 14 f = f.deriveFont(Font.BOLD); 15 } 16 17 String family = families[0]; 18 19 String fontname = "SansSerif"; 20 if(family.equals("serif")) { 22 fontname = "Serif"; 23 } 24 if(family.equals("sans-serif")) { 25 fontname = "SansSerif"; 26 } 27 if(family.equals("monospace")) { 28 fontname = "Monospaced"; 29 } 30 31 32 f = new Font (fontname,f.getStyle(),f.getSize()); 33 34 if(style != null) { 35 if(style.equals("italic")) { 36 f = f.deriveFont(Font.ITALIC|f.getStyle()); 39 } 40 } 41 return f; 42 } 43 44 } 45 | Popular Tags |