private BoundingBox generateBoundingBox() throws IOException { if (getFontDescriptor() != null) { PDRectangle bbox = getFontDescriptor().getFontBoundingBox(); if (isNonZeroBoundingBox(bbox)) { return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(), bbox.getUpperRightX(), bbox.getUpperRightY()); } } return genericFont.getFontBBox(); }
FontMapping<FontBoxFont> mapping = FontMappers.instance() .getFontBoxFont(getBaseFont(), getFontDescriptor()); genericFont = mapping.getFont();
codeToBytesMap = new HashMap<>(); PDFontDescriptor fd = getFontDescriptor(); Type1Font t1 = null; boolean fontIsDamaged = false;
private TextStyle(PDType1Font f, double sz, Color tc, double leadingFactor) { if (f == null) { throw new IllegalArgumentException("Font must not be null"); } if (tc == null) { tc = Color.BLACK; } font = f; textColor = tc; fontSize = sz; // Somewhere it says that font units are 1000 times page units, but my tests with // PDType1Font.HELVETICA and PDType1Font.HELVETICA_BOLD from size 5-200 show that 960x is // pretty darn good. // TODO: Fix font-size for other fonts. factor = fontSize / 960; PDFontDescriptor fontDescriptor = font.getFontDescriptor(); double rawAscent = fontDescriptor.getAscent(); double rawDescent = fontDescriptor.getDescent(); // Characters look best with the descent size both above and below. Also acts as a good // default leading. ascent = rawAscent * factor; descent = rawDescent * -factor; leading = descent * leadingFactor; // height = ascent + descent + leading; double avgFontWidth = 500; try { avgFontWidth = font.getAverageFontWidth(); } catch (Exception ioe) { //throw new IllegalStateException("IOException probably means an issue reading font metrics from the underlying font file used in this PDF", ioe); ; // just use default if there's an exception. } avgCharWidth = avgFontWidth * fontSize; }
private BoundingBox generateBoundingBox() throws IOException { if (getFontDescriptor() != null) { PDRectangle bbox = getFontDescriptor().getFontBoundingBox(); if (bbox != null && (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 || bbox.getUpperRightX() != 0 || bbox.getUpperRightY() != 0)) { return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(), bbox.getUpperRightX(), bbox.getUpperRightY()); } } return genericFont.getFontBBox(); }
private BoundingBox generateBoundingBox() throws IOException { if (getFontDescriptor() != null) { PDRectangle bbox = getFontDescriptor().getFontBoundingBox(); if (bbox != null && (bbox.getLowerLeftX() != 0 || bbox.getLowerLeftY() != 0 || bbox.getUpperRightX() != 0 || bbox.getUpperRightY() != 0)) { return new BoundingBox(bbox.getLowerLeftX(), bbox.getLowerLeftY(), bbox.getUpperRightX(), bbox.getUpperRightY()); } } return genericFont.getFontBBox(); }
FontMapping<FontBoxFont> mapping = FontMappers.instance() .getFontBoxFont(getBaseFont(), getFontDescriptor()); genericFont = mapping.getFont();
FontMapping<FontBoxFont> mapping = FontMappers.instance() .getFontBoxFont(getBaseFont(), getFontDescriptor()); genericFont = mapping.getFont();
codeToBytesMap = new HashMap<Integer,byte[]>(); PDFontDescriptor fd = getFontDescriptor(); Type1Font t1 = null; boolean fontIsDamaged = false;
codeToBytesMap = new HashMap<>(); PDFontDescriptor fd = getFontDescriptor(); Type1Font t1 = null; boolean fontIsDamaged = false;