List of usage examples for com.lowagie.text Font isStandardFont
public boolean isStandardFont()
From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableList.java
License:Open Source License
@SuppressWarnings("unchecked") private void addElement(Element element, boolean addLabel) { if (element instanceof Chunk) { // may it happen? Chunk ch = (Chunk) element;/*w ww . j a v a 2 s.c om*/ StylableParagraph p = new StylableParagraph(null, null); p.setFont(ch.getFont()); p.addElement(ch); element = p.getElement(); } if (element instanceof Phrase) { Phrase p = (Phrase) element; StylableListItem li = new StylableListItem(p); // determine font, it may be set explicitly or use paragraph font Font symbolFont = symbol.getFont(); if (symbolFont.isStandardFont()) { ArrayList<Chunk> chunks = p.getChunks(); for (Chunk chunk : chunks) { // use first specified font if (!chunk.getFont().isStandardFont()) { symbolFont = chunk.getFont(); break; } } if (symbolFont.isStandardFont()) { // use paragraph font symbolFont = p.getFont(); } } // determine line height float lineHeight = StylableParagraph.DEFAULT_LINE_HEIGHT; boolean lineHeightProportional = true; if (element instanceof IStylableElement) { IStylableElement stylableElement = (IStylableElement) element; Style style = stylableElement.getLastStyleApplied(); if (style != null) { StyleParagraphProperties paragraphProperties = style.getParagraphProperties(); StyleLineHeight lineHeightObj = paragraphProperties.getLineHeight(); if (lineHeightObj != null && lineHeightObj.getLineHeight() != null) { lineHeight = lineHeightObj.getLineHeight(); lineHeightProportional = lineHeightObj.isLineHeightProportional(); } } } if (addLabel) { if (numbered || lettered || romanNumbered) { StringBuilder sbuf = new StringBuilder(preSymbol); int index = first + list.size(); if (lettered) { sbuf.append(RomanAlphabetFactory.getString(index, lowercase)); } else if (romanNumbered) { sbuf.append(RomanNumberFactory.getString(index, lowercase)); } else { sbuf.append(index); } sbuf.append(postSymbol); li.setListSymbol(sbuf.toString(), symbolFont, lineHeight, lineHeightProportional); } else { li.setListSymbol(symbol.getContent(), symbolFont, lineHeight, lineHeightProportional); } } else { li.setListSymbol("", symbolFont, lineHeight, lineHeightProportional); } li.setIndentationLeft(symbolIndent); li.setIndentationRight(0.0f); list.add(li); } else if (element instanceof List) { List l = (List) element; // open office specifies absolute list indentation // but iText computes indentation relative to parent list // so we have to set difference l.setIndentationLeft(l.getIndentationLeft() - this.getIndentationLeft()); first--; list.add(l); } }