CssUtils { public Map<String, String> processFont(final String font) { Map<String, String> rules = new HashMap<String, String>(); String[] styleAndRest = font.split("\\s"); for (int i = 0 ; i < styleAndRest.length ; i++){ String style = styleAndRest[i]; if (style.equalsIgnoreCase(HtmlTags.ITALIC) || style.equalsIgnoreCase(HtmlTags.OBLIQUE)) { rules.put(HtmlTags.FONTSTYLE, style); } else if (style.equalsIgnoreCase("small-caps")){ rules.put("font-variant", style); } else if (style.equalsIgnoreCase(HtmlTags.BOLD)){ rules.put(HtmlTags.FONTWEIGHT, style); } else if (isMetricValue(style) || isNumericValue(style)){ if (style.contains("/")) { String[] sizeAndLineHeight = style.split("/"); style = sizeAndLineHeight[0]; rules.put(HtmlTags.LINEHEIGHT, sizeAndLineHeight[1]); } rules.put(HtmlTags.FONTSIZE, style); if (i != styleAndRest.length-1){ String rest = styleAndRest[i+1]; rest = rest.replaceAll("\"", ""); rest = rest.replaceAll("'", ""); rules.put(HtmlTags.FONTFAMILY, rest); } } } return rules; } private  CssUtils(); static CssUtils getInstance(); Map<String, String> parseBoxValues(final java.lang.String box,
                                             final java.lang.String pre, final java.lang.String post); Map<String, String> parseBoxValues(final String box,
                                              final String pre, final String post, String preKey); Map<String, String> parseBorder(final String border); Map<String, String> parseBorder(final String border, final String borderKey); String stripDoubleSpacesAndTrim(final String str); String stripDoubleSpacesTrimAndToLowerCase(final String str); Map<String, String> processBackground(final String background); Map<String, String> processListStyle(final String listStyle); Map<String, String> processFont(final String font); float checkMetricStyle(final Tag t, final String style); Float checkMetricStyle(final Map<String,String> css, final String style); boolean isMetricValue(final String value); boolean isRelativeValue(final String value); boolean isNumericValue(final String value); float parseValueToPt(final String value, final float baseValue); float parseRelativeValue(final String relativeValue, final float baseValue); float parsePxInCmMmPcToPt(final String length, final String defaultMetric); float parsePxInCmMmPcToPt(final String length); int determinePositionBetweenValueAndUnit(final String string); float getLeftAndRightMargin(final Tag t, final float pageWidth); String extractUrl(final String url); float validateTextHeight(final Map<String, String> css,
			float textHeight); float calculateMarginTop(final String value, final float largestFont, final MarginMemory configuration); float calculateMarginTop(final float value, final MarginMemory configuration); String trimAndRemoveQuoutes(String s); String[] splitComplexCssStyle(String s); static final int DEFAULT_FONT_SIZE_PT; }
@Test public void splitFont() { Map<String, String> processFont = css.processFont("bold italic 16pt/3px Verdana"); Assert.assertEquals("bold", processFont.get("font-weight")); Assert.assertEquals("italic", processFont.get("font-style")); Assert.assertEquals("16pt", processFont.get("font-size")); Assert.assertEquals("3px", processFont.get("line-height")); Assert.assertEquals("Verdana", processFont.get("font-family")); }