ChunkCssApplier implements CssApplier<Chunk> { public Chunk apply(final Chunk c, final Tag t) { return apply(c, t, null, null, null); } ChunkCssApplier();  ChunkCssApplier(FontProvider fontProvider); Chunk apply(final Chunk c, final Tag t); Chunk apply(final Chunk c, final Tag t, final MarginMemory mm, final PageSizeContainable psc, final HtmlPipelineContext ctx); Font applyFontStyles(final Tag t); float getWidestWord(final Chunk c); void copyChunkStyles(final Chunk source, final Chunk target); FontProvider getFontProvider(); void setFontProvider(FontProvider fontProvider); static final List<String> BOLD; }
@Test public void resolveColor() throws IOException { assertEquals(BaseColor.BLACK, c.getFont().getColor()); t.getCSS().put("color", "#00f"); c = applier.apply(c, t); assertEquals(255, c.getFont().getColor().getBlue(), 0); t.getCSS().put("color", "#00ff00"); c = applier.apply(c, t); assertEquals(255, c.getFont().getColor().getGreen(), 0); t.getCSS().put("color", "rgb(255,0,0)"); c = applier.apply(c, t); assertEquals(255, c.getFont().getColor().getRed(), 0); }
@Test public void resolveVerticalAlign() throws IOException { assertEquals(0, c.getTextRise(), 0); t.getCSS().put("vertical-align", "5pt"); c = applier.apply(c, t); assertEquals(5, c.getTextRise(), 0); t.getCSS().put("vertical-align", "sub"); c = applier.apply(c, t); assertEquals(12, c.getFont().getSize(), 0); assertEquals(-c.getFont().getSize() / 2, c.getTextRise(), 0); t.getCSS().put("vertical-align", "super"); c = applier.apply(c, t); assertEquals(12, c.getFont().getSize(), 0); assertEquals(c.getFont().getSize() / 2 + 0.5, c.getTextRise(), 0); }
@Test public void resolveFontSize() throws IOException { assertEquals(12, c.getFont().getSize(), 0); t.getCSS().put("font-size", "18pt"); c = applier.apply(c, t); assertEquals(18, c.getFont().getSize(), 0); }
@Test public void resolveCharacterSpacing() throws IOException { assertEquals(0, c.getCharacterSpacing(), 0); t.getCSS().put("letter-spacing", "15pt"); c = applier.apply(c, t); assertEquals(15, c.getCharacterSpacing(), 0); }
@Test public void resolveHorizontalAndVerticalScaling() throws IOException { t.getCSS().put("xfa-font-vertical-scale", "75pt"); assertEquals(1, c.getHorizontalScaling(), 0); t.getCSS().put("xfa-font-horizontal-scale", "75%"); c = applier.apply(c, t); assertEquals(0.75f, c.getHorizontalScaling(), 0); t.getCSS().put("xfa-font-vertical-scale", "75%"); c = applier.apply(c, t); assertEquals(9, c.getFont().getSize(), 0); assertEquals(100 / 75f, c.getHorizontalScaling(), 0); }