List of usage examples for com.lowagie.text.pdf BaseFont BBOXLLY
int BBOXLLY
To view the source code for com.lowagie.text.pdf BaseFont BBOXLLY.
Click Source Link
From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontInfo.java
License:Open Source License
protected void setupFontSize() { if (bf == null) { lineWidth = 1;//from w w w . j a v a 2s . c o m fontHeight = fontSize; baselinePosition = fontSize; underlinePosition = fontSize; linethroughPosition = fontSize / 2; overlinePosition = 0; return; } float ascent = bf.getFontDescriptor(BaseFont.AWT_ASCENT, fontSize); float descent = bf.getFontDescriptor(BaseFont.AWT_DESCENT, fontSize); if (BaseFont.FONT_TYPE_T1 == bf.getFontType()) { // uses the FontBBox for Type1 font, refer to the implementation // of free type API ascent = bf.getFontDescriptor(BaseFont.BBOXURY, fontSize); descent = bf.getFontDescriptor(BaseFont.BBOXLLY, fontSize); } if (descent > 0) { // In some cases, the Type1 font (perhaps loading from PFM?) return // positive descent descent = -descent; } float baseline = bf.getFontDescriptor(BaseFont.UNDERLINE_POSITION, fontSize); float baseline_thickness = bf.getFontDescriptor(BaseFont.UNDERLINE_THICKNESS, fontSize); float strike = bf.getFontDescriptor(BaseFont.STRIKETHROUGH_POSITION, fontSize); float strike_thickness = bf.getFontDescriptor(BaseFont.STRIKETHROUGH_THICKNESS, fontSize); lineWidth = baseline_thickness; if (lineWidth == 0) { lineWidth = strike_thickness; if (lineWidth == 0) { lineWidth = fontSize / 20; } } fontHeight = ascent - descent; //TODO: the -lineWidth/2 should be move to the draw function baselinePosition = ascent - lineWidth / 2; underlinePosition = ascent - baseline - lineWidth / 2; if (strike == 0) { linethroughPosition = fontHeight / 2 - lineWidth / 2; } else { linethroughPosition = ascent - strike - lineWidth / 2; } //TODO: overline is not same with the HTML, we need change it in future. overlinePosition = 0; }
From source file:org.pentaho.reporting.libraries.fonts.itext.BaseFontFontMetrics.java
License:Open Source License
public BaseFontFontMetrics(final FontNativeContext record, final BaseFont baseFont, final float size) { if (baseFont == null) { throw new NullPointerException("BaseFont is invalid."); }/*from www.j a v a2 s. c o m*/ this.record = record; this.baseFont = baseFont; this.size = size; this.cpBuffer = new char[4]; this.cachedWidths = new long[256 - 32]; Arrays.fill(cachedWidths, -1); sizeScaled = FontStrictGeomUtility.toInternalValue(size); this.ascent = (long) baseFont.getFontDescriptor(BaseFont.AWT_ASCENT, sizeScaled); this.descent = (long) -baseFont.getFontDescriptor(BaseFont.AWT_DESCENT, sizeScaled); this.leading = (long) baseFont.getFontDescriptor(BaseFont.AWT_LEADING, sizeScaled); italicsAngle = FontStrictGeomUtility .toInternalValue(baseFont.getFontDescriptor(BaseFont.ITALICANGLE, size)); maxAscent = (long) baseFont.getFontDescriptor(BaseFont.BBOXURY, sizeScaled); maxDescent = (long) -baseFont.getFontDescriptor(BaseFont.BBOXLLY, sizeScaled); maxCharAdvance = (long) baseFont.getFontDescriptor(BaseFont.AWT_MAXADVANCE, sizeScaled); final int[] charBBox = this.baseFont.getCharBBox('x'); if (charBBox != null) { this.xHeight = (long) (charBBox[3] * size); } if (this.xHeight == 0) { this.xHeight = getAscent() / 2; } this.trueTypeFont = baseFont.getFontType() == BaseFont.FONT_TYPE_TT || baseFont.getFontType() == BaseFont.FONT_TYPE_TTUNI; }
From source file:org.xhtmlrenderer.pdf.ITextTextRenderer.java
License:Open Source License
public FSFontMetrics getFSFontMetrics(FontContext context, FSFont font, String string) { FontDescription descr = ((ITextFSFont) font).getFontDescription(); BaseFont bf = descr.getFont();//from w w w .j a v a2 s . c om float size = font.getSize2D(); ITextFSFontMetrics result = new ITextFSFontMetrics(); result.setAscent(bf.getFontDescriptor(BaseFont.BBOXURY, size)); result.setDescent(-bf.getFontDescriptor(BaseFont.BBOXLLY, size)); result.setStrikethroughOffset(-descr.getYStrikeoutPosition() / 1000f * size); if (descr.getYStrikeoutSize() != 0) { result.setStrikethroughThickness(descr.getYStrikeoutSize() / 1000f * size); } else { result.setStrikethroughThickness(size / 12.0f); } result.setUnderlineOffset(-descr.getUnderlinePosition() / 1000f * size); result.setUnderlineThickness(descr.getUnderlineThickness() / 1000f * size); return result; }