BoundingBox bbox = font.getBoundingBox();
BoundingBox bbox = font.getBoundingBox();
float highlightBoxHeight = font.getBoundingBox().getHeight() * fontSize / FONTSCALE;
float height = font.getBoundingBox().getHeight() / FONTSCALE; PDRectangle actualMediaBox = mediaBox; if (landscape)
yTextPos = yTextPos - font.getBoundingBox().getHeight() / FONTSCALE * fontSize; contents.beginText();
if (height <= 0) height = font.getBoundingBox().getHeight() * font.getFontMatrix().getScaleY();
public static float getBoundingBoxDescent(PDFont font, float fontSize) { try { BoundingBox bBox = font.getBoundingBox(); float boxDescent = bBox.getLowerLeftY(); return (boxDescent / 1000) * fontSize; } catch (IOException e) { } return 0.0f; }
public static float getBoundingBoxAscent(PDFont font, float fontSize) { try { BoundingBox bBox = font.getBoundingBox(); float boxAscent = bBox.getUpperRightY(); return (boxAscent / 1000) * fontSize; } catch (IOException e) { } return 0.0f; }
public static float getAverageFontHeight(PDFont font, float fontSize) throws IOException { return font.getBoundingBox().getHeight() / PDF_PIXEL_SIZE * fontSize; }
public static float getFontHeightForString(String str, PDFont font, float fontSize) throws IOException { return font.getBoundingBox().getHeight() / PDF_PIXEL_SIZE * fontSize; }
Matrix textMatrix = getTextMatrix(); BoundingBox bbox = font.getBoundingBox(); if (bbox.getLowerLeftY() < Short.MIN_VALUE)
float fontBoundingBoxAtSize = font.getBoundingBox().getHeight() * fontScaleY; float fontCapAtSize = font.getFontDescriptor().getCapHeight() * fontScaleY; float fontDescentAtSize = font.getFontDescriptor().getDescent() * fontScaleY; appearanceStyle.setLeading(font.getBoundingBox().getHeight() * fontScaleY);
/** * Creates the font bounds. * * @param font * the font * @return the rectangle 2 D */ private Rectangle2D createFontBounds(PDFont font) { BoundingBox box; try { box = font.getBoundingBox(); } catch (IOException e) { throw new IllegalArgumentException("Failed to get bounding box for font", e); } float width = font.getSpaceWidth(); float height = box.getHeight(); return new Rectangle2D.Float(0, 0, width, height); }
public static PdfBoxRawPDFontMetrics fromPdfBox(PDFont font, PDFontDescriptor descriptor) throws IOException { return new PdfBoxRawPDFontMetrics( font.getBoundingBox().getUpperRightY(), // Ascent -font.getBoundingBox().getLowerLeftY(), // Descent -descriptor.getFontBoundingBox().getUpperRightY() / 3f, // Strikethrough offset 100f, // FIXME: Strikethrough thickness -descriptor.getDescent(), // Underline position 50f); // FIXME: Underline thickness }
public static PdfBoxRawPDFontMetrics fromPdfBox(PDFont font, PDFontDescriptor descriptor) throws IOException { return new PdfBoxRawPDFontMetrics( font.getBoundingBox().getUpperRightY(), // Ascent -font.getBoundingBox().getLowerLeftY(), // Descent -descriptor.getFontBoundingBox().getUpperRightY() / 3f, // Strikethrough offset 100f, // FIXME: Strikethrough thickness -descriptor.getDescent(), // Underline position 50f); // FIXME: Underline thickness }
Shape calculateFontBounds(TextPosition text) throws IOException { // glyph space -> user space // note: text.getTextMatrix() is *not* the Text Matrix, it's the Text Rendering Matrix AffineTransform at = text.getTextMatrix().createAffineTransform(); // show rectangle with the real vertical bounds, based on the font bounding box y values // usually, the height is identical to what you see when marking text in Adobe Reader PDFont font = text.getFont(); BoundingBox bbox = font.getBoundingBox(); // advance width, bbox height (glyph space) float xadvance = font.getWidth(text.getCharacterCodes()[0]); // todo: should iterate all chars Rectangle2D.Float rect = new Rectangle2D.Float(0, bbox.getLowerLeftY(), xadvance, bbox.getHeight()); if (font instanceof PDType3Font) { // bbox and font matrix are unscaled at.concatenate(font.getFontMatrix().createAffineTransform()); } else { // bbox and font matrix are already scaled to 1000 at.scale(1/1000f, 1/1000f); } Shape s = at.createTransformedShape(rect); s = flipAT.createTransformedShape(s); s = rotateAT.createTransformedShape(s); return s; }
float highlightBoxHeight = font.getBoundingBox().getHeight() * fontSize / FONTSCALE;
float highlightBoxHeight = font.getBoundingBox().getHeight() * fontSize / FONTSCALE;
if (height <= 0) height = font.getBoundingBox().getHeight() * font.getFontMatrix().getScaleY();
if (height <= 0) height = font.getBoundingBox().getHeight() * font.getFontMatrix().getScaleY();