List of usage examples for com.lowagie.text Font getCalculatedBaseFont
public BaseFont getCalculatedBaseFont(boolean specialEncoding)
BaseFont
this class represents. From source file:com.krawler.accounting.fontsetting.FontFamily.java
License:Open Source License
public void addFont(FontContext context, Font font) { if (font.getBaseFont() == null) { BaseFont bf = font.getCalculatedBaseFont(true); font = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor()); }/*from w w w .ja va 2s.com*/ fontsMap.put(context, font); if (primaryFont == null) primaryFont = font; }
From source file:com.krawler.accounting.fontsetting.FontFamily.java
License:Open Source License
public void addFont(FontContext context, Font font, boolean isPrimary) { if (font.getBaseFont() == null) { BaseFont bf = font.getCalculatedBaseFont(true); font = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor()); }// w w w .j a v a2 s .c o m fontsMap.put(context, font); if (isPrimary) primaryFont = font; }
From source file:com.krawler.accounting.fontsetting.FontFamilySelector.java
License:Open Source License
public void addFontFamily(FontFamily fontFamily) { Font font = fontFamily.getPrimaryFont(); if (font.getBaseFont() == null) { BaseFont bf = font.getCalculatedBaseFont(true); font = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor()); }/*from w w w . j av a2 s . c o m*/ families.add(fontFamily); }
From source file:org.mapfish.print.config.layout.ScalebarBlock.java
License:Open Source License
/** * Try recursively to find the correct layout. *//*from w ww . j a va 2s .c o m*/ private void tryLayout(RenderingContext context, PdfElement target, Font pdfFont, DistanceUnit scaleUnit, int scale, double intervalDistance, int tryNumber) throws DocumentException { if (tryNumber > 3) { //noinspection ThrowableInstanceNeverThrown context.addError(new InvalidValueException("maxSize too small", maxSize)); return; } DistanceUnit intervalUnit = DistanceUnit.getBestUnit(intervalDistance, scaleUnit); final float intervalPaperWidth = (float) scaleUnit.convertTo(intervalDistance / scale, DistanceUnit.PT); //compute the label positions final List<Label> labels = new ArrayList<Label>(intervals + 1); final float leftLabelMargin; final float rightLabelMargin; final BaseFont baseFont = pdfFont.getCalculatedBaseFont(false); if (intervals > 1 || subIntervals) { //the label will be centered under each tick marks for (int i = 0; i <= intervals; ++i) { String labelText = createLabelText(scaleUnit, intervalDistance * i, intervalUnit); if (i == intervals) { labelText += intervalUnit; } labels.add(new Label(intervalPaperWidth * i, labelText, baseFont, getFontSize(), !barDirection.isSameOrientation(textDirection))); } leftLabelMargin = labels.get(0).width / 2.0f; rightLabelMargin = labels.get(labels.size() - 1).width / 2.0f; } else { //if there is only one interval, place the label centered between the two tick marks final Label label = new Label(intervalPaperWidth / 2.0f, createLabelText(scaleUnit, intervalDistance, intervalUnit) + intervalUnit, baseFont, getFontSize(), !barDirection.isSameOrientation(textDirection)); labels.add(label); leftLabelMargin = rightLabelMargin = Math.max(0.0f, label.width - intervalPaperWidth) / 2.0f; } if (intervals * intervalPaperWidth + leftLabelMargin + rightLabelMargin <= maxSize) { //the layout fits the maxSize doLayout(context, target, pdfFont, labels, intervalPaperWidth, scaleUnit, intervalDistance, intervalUnit, leftLabelMargin, rightLabelMargin); } else { //not enough room because of the labels, try a smaller bar double nextIntervalDistance = getNearestNiceValue(intervalDistance * 0.9, scaleUnit); tryLayout(context, target, pdfFont, scaleUnit, scale, nextIntervalDistance, tryNumber + 1); } }
From source file:org.mapfish.print.PDFUtils.java
License:Open Source License
public static BaseFont getBaseFont(String fontFamily, String fontSize, String fontWeight) { int myFontValue; float myFontSize; int myFontWeight; if (fontFamily.toUpperCase().contains("COURIER")) { myFontValue = Font.COURIER; } else if (fontFamily.toUpperCase().contains("HELVETICA")) { myFontValue = Font.HELVETICA; } else if (fontFamily.toUpperCase().contains("ROMAN")) { myFontValue = Font.TIMES_ROMAN; } else {// w w w .j av a 2s . c o m myFontValue = Font.HELVETICA; } myFontSize = (float) Double.parseDouble(fontSize.toLowerCase().replaceAll("px", "")); if (fontWeight.toUpperCase().contains("NORMAL")) { myFontWeight = Font.NORMAL; } else if (fontWeight.toUpperCase().contains("BOLD")) { myFontWeight = Font.BOLD; } else if (fontWeight.toUpperCase().contains("ITALIC")) { myFontWeight = Font.ITALIC; } else { myFontWeight = Font.NORMAL; } Font pdfFont = new Font(myFontValue, myFontSize, myFontWeight); BaseFont bf = pdfFont.getCalculatedBaseFont(false); return bf; }
From source file:org.mapfish.print.TotalPageNum.java
License:Open Source License
public TotalPageNum(PdfWriter writer, Font font) { dc = writer.getDirectContent(); totalPageNumFont = font.getCalculatedBaseFont(false); totalPageNumFontSize = font.getSize(); }