else if (fontDescriptor.getFontWeight() > 0 && info.getWeightClass() > 0) float dist = Math.abs(fontDescriptor.getFontWeight() - info.getWeightClass()); match.score += 1 - (dist / 100) * 0.5;
@Override public Double getFontWeight() { if (descriptor.getCOSObject().containsKey(COSName.FONT_WEIGHT)) { return Double.valueOf(descriptor.getFontWeight()); } return null; }
/** * Checks if is bold. * * @param font * the font * @param graphicsState * the graphics state * @return true, if is bold */ private static boolean isBold(PDFont font, PDGraphicsState graphicsState) { String lowerCaseName = font.getName().toLowerCase(Locale.ROOT); boolean boldName = lowerCaseName.contains("black") || lowerCaseName.contains("bold") || lowerCaseName.contains("heavy"); PDFontDescriptor fontDescriptor = font.getFontDescriptor(); boolean forceBold = fontDescriptor.isForceBold(); boolean boldWeight = fontDescriptor.getFontWeight() >= 700; PDTextState textState = graphicsState.getTextState(); RenderingMode renderingMode = textState.getRenderingMode(); boolean boldLineStroke = graphicsState.getLineWidth() > 1.0f && renderingMode.isStroke(); return forceBold || boldWeight || boldLineStroke || boldName; }
else if (fontDescriptor.getFontWeight() > 0 && info.getWeightClass() > 0) float dist = Math.abs(fontDescriptor.getFontWeight() - info.getWeightClass()); match.score += 1 - (dist / 100) * 0.5;
else if (fontDescriptor.getFontWeight() > 0 && info.getWeightClass() > 0) float dist = Math.abs(fontDescriptor.getFontWeight() - info.getWeightClass()); match.score += 1 - (dist / 100) * 0.5;