List of usage examples for com.itextpdf.text.pdf BaseFont getWidthPoint
public float getWidthPoint(int char1, float fontSize)
char
in points. From source file:com.softwaremagico.tm.pdf.complete.skills.SkillsTable.java
License:Open Source License
private static Paragraph createSpecializedSkill(CharacterPlayer characterPlayer, AvailableSkill availableSkill, BaseFont font, int fontSize, int maxColumnWidth) { Paragraph paragraph = new Paragraph(); float usedWidth = font.getWidthPoint( availableSkill.getName() + " []" + (availableSkill.getSkillDefinition().isNatural() ? DEFAULT_NATURAL_SKILL_VALUE : ""), fontSize);// w w w . j av a 2s . com paragraph.add(new Paragraph(availableSkill.getName() + " [", new Font(font, fontSize))); if (characterPlayer != null && characterPlayer.getSelectedSkill(availableSkill) == null) { if (availableSkill.getSpecialization() != null && availableSkill.getSpecialization().getName() != null) { paragraph.add(new Paragraph( CellUtils.getSubStringFitsIn(availableSkill.getSpecialization().getName(), FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize), maxColumnWidth - usedWidth), new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize)))); } else { paragraph.add(new Paragraph(CellUtils.getSubStringFitsIn(DEFAULT_WHITE_SPACES, font, fontSize, maxColumnWidth - usedWidth), new Font(font, fontSize))); } } else { paragraph.add(new Paragraph( CellUtils.getSubStringFitsIn( characterPlayer != null ? characterPlayer.getSelectedSkill(availableSkill).getName() .replace(availableSkill.getName(), "").replace("[", "").replace("]", "").trim() : DEFAULT_WHITE_SPACES, FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize), maxColumnWidth - usedWidth), new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize)))); } paragraph.add(new Paragraph("]", new Font(font, fontSize))); return paragraph; }
From source file:com.softwaremagico.tm.pdf.complete.skills.SkillsTable.java
License:Open Source License
private static Paragraph createSpecializedSkill(SkillDefinition skillDefinition, BaseFont font, int fontSize, int maxColumnWidth) { Paragraph paragraph = new Paragraph(); float usedWidth = font.getWidthPoint(skillDefinition.getName() + " []" + (skillDefinition.isNatural() ? DEFAULT_NATURAL_SKILL_VALUE : ""), fontSize); paragraph.add(new Paragraph(skillDefinition.getName() + " [", new Font(font, fontSize))); paragraph.add(new Paragraph( CellUtils.getSubStringFitsIn(DEFAULT_WHITE_SPACES, font, fontSize, maxColumnWidth - usedWidth), new Font(font, fontSize))); paragraph.add(new Paragraph("]", new Font(font, fontSize))); return paragraph; }
From source file:com.softwaremagico.tm.pdf.complete.utils.CellUtils.java
License:Open Source License
public static boolean fitsIn(String text, BaseFont font, int fontSize, float width) { return font.getWidthPoint(text, fontSize) < width; }
From source file:org.gephi.preview.plugin.renderers.NodeLabelRenderer.java
License:Open Source License
private float getTextWidth(BaseFont baseFont, float fontSize, String text) { return baseFont.getWidthPoint(text, fontSize); }