1 17 18 19 20 package org.apache.fop.fonts; 21 22 25 public class FontUtil { 26 27 35 public static int parseCSS2FontWeight(String text) { 36 int weight = 400; 37 try { 38 weight = Integer.parseInt(text); 39 weight = ((int)weight / 100) * 100; 40 weight = Math.max(weight, 100); 41 weight = Math.min(weight, 900); 42 } catch (NumberFormatException nfe) { 43 if (text.equals("normal")) { 45 weight = 400; 46 } else if (text.equals("bold")) { 47 weight = 700; 48 } else { 49 throw new IllegalArgumentException ( 50 "Illegal value for font weight: '" 51 + text 52 + "'. Use one of: 100, 200, 300, " 53 + "400, 500, 600, 700, 800, 900, " 54 + "normal (=400), bold (=700)"); 55 } 56 } 57 return weight; 58 } 59 60 } 61 | Popular Tags |