/** * Gets the hash key for a concrete instance of a font. * This incorporates size, weight, etc. */ protected static String getFontInstanceHashName(SharedContext ctx, String name, float size, IdentValue weight, IdentValue style, IdentValue variant) { return name + "-" + (size * ctx.getTextRenderer().getFontScale()) + "-" + weight + "-" + style + "-" + variant; }
public FSFontMetrics getFSFontMetrics(FSFont font) { return getTextRenderer().getFSFontMetrics(getFontContext(), font, ""); }
public int getSpaceWidth(LayoutContext c) { return c.getTextRenderer().getWidth( c.getFontContext(), getStyle().getFSFont(c), WhitespaceStripper.SPACE); }
private RenderingContext newRenderingContext() { RenderingContext result = _sharedContext.newRenderingContextInstance(); result.setFontContext(new PdfBoxFontContext()); result.setOutputDevice(_outputDevice); if (_reorderer != null) result.setBidiReorderer(_reorderer); _outputDevice.setRenderingContext(result); _sharedContext.getTextRenderer().setup(result.getFontContext()); result.setRootLayer(_root.getLayer()); return result; }
private void ensureGlyphPositions(RenderingContext c) { if (_glyphPositions == null) { FSGlyphVector glyphVector = c.getTextRenderer().getGlyphVector( c.getOutputDevice(), getParent().getStyle().getFSFont(c), getSubstring()); _glyphPositions = c.getTextRenderer().getGlyphPositions( c.getOutputDevice(), getParent().getStyle().getFSFont(c), glyphVector); } }
private static void drawText(RenderingContext c, BlockBox box, IdentValue listStyle) { MarkerData.TextMarker text = box.getMarkerData().getTextMarker(); int x = getReferenceX(c, box); x += -text.getLayoutWidth(); int y = getReferenceBaseline(c, box); c.getOutputDevice().setColor(box.getStyle().getColor()); c.getOutputDevice().setFont(box.getStyle().getFSFont(c)); c.getTextRenderer().drawString( c.getOutputDevice(), text.getText(), x, y); } }
private RenderingContext newRenderingContext() { RenderingContext result = _sharedContext.newRenderingContextInstance(); result.setFontContext(new PdfBoxFontContext()); result.setOutputDevice(_outputDevice); if (_reorderer != null) result.setBidiReorderer(_reorderer); _outputDevice.setRenderingContext(result); _sharedContext.getTextRenderer().setup(result.getFontContext()); result.setRootLayer(_root.getLayer()); return result; }
info.setNonSpaceAdjust(inlineText.getLetterSpacing()); info.setSpaceAdjust(inlineText.getLetterSpacing()); c.getTextRenderer().drawString( c.getOutputDevice(), text, c.getTextRenderer().drawString( c.getOutputDevice(), text, info); } else { c.getTextRenderer().drawString( c.getOutputDevice(), text, c.getTextRenderer().drawString( c.getOutputDevice(), text,
/** * Gets the hash key for a concrete instance of a font. * This incorporates size, weight, etc. */ protected static String getFontInstanceHashName(SharedContext ctx, String name, float size, IdentValue weight, IdentValue style, IdentValue variant) { return name + "-" + (size * ctx.getTextRenderer().getFontScale()) + "-" + weight + "-" + style + "-" + variant; }
private RenderingContext newRenderingContext() { RenderingContext result = _sharedContext.newRenderingContextInstance(); result.setFontContext(new Java2DFontContext(_outputDevice.getGraphics())); result.setOutputDevice(_outputDevice); if (_reorderer != null) result.setBidiReorderer(_reorderer); _outputDevice.setRenderingContext(result); _sharedContext.getTextRenderer().setup(result.getFontContext()); result.setRootLayer(_root.getLayer()); return result; }
private int getTextWidth(LayoutContext c, String s) { return c.getTextRenderer().getWidth( c.getFontContext(), c.getFont(getStyle().getFont(c)), s); }
public FSFontMetrics getFSFontMetrics(FSFont font) { return getTextRenderer().getFSFontMetrics(getFontContext(), font, ""); }
/** * Creates a concrete instance of a font at specified size, weight, style and variant. */ protected static Font createFont(SharedContext ctx, Font rootFont, float size, IdentValue weight, IdentValue style, IdentValue variant) { //Uu.p("creating font: " + root_font + " size = " + size + // " weight = " + weight + " style = " + style + " variant = " + variant); int fontConst = Font.PLAIN; if (weight != null && (weight == IdentValue.BOLD || weight == IdentValue.FONT_WEIGHT_700 || weight == IdentValue.FONT_WEIGHT_800 || weight == IdentValue.FONT_WEIGHT_900)) { fontConst = fontConst | Font.BOLD; } if (style != null && (style == IdentValue.ITALIC || style == IdentValue.OBLIQUE)) { fontConst = fontConst | Font.ITALIC; } // scale vs font scale value too size *= ctx.getTextRenderer().getFontScale(); Font fnt = rootFont.deriveFont(fontConst, size); if (variant != null) { if (variant == IdentValue.SMALL_CAPS) { fnt = fnt.deriveFont((float) (((float) fnt.getSize()) * 0.6)); } } return fnt; }
public void updateDynamicValue(RenderingContext c) { String value = _functionData.getContentFunction().calculate( c, _functionData.getFunction(), this); _start = 0; _end = value.length(); _masterText = value; _width = c.getTextRenderer().getWidth( c.getFontContext(), getParent().getStyle().getFSFont(c), value); }
public float getXHeight(FontContext fontContext, FontSpecification fs) { FSFont font = getFontResolver().resolveFont(this, fs); FSFontMetrics fm = getTextRenderer().getFSFontMetrics(fontContext, font, " "); float sto = fm.getStrikethroughOffset(); return fm.getAscent() - 2 * Math.abs(sto) + fm.getStrikethroughThickness(); }
/** * Creates a concrete instance of a font at specified size, weight, style and variant. */ protected static Font createFont(SharedContext ctx, Font rootFont, float size, IdentValue weight, IdentValue style, IdentValue variant) { //Uu.p("creating font: " + root_font + " size = " + size + // " weight = " + weight + " style = " + style + " variant = " + variant); int fontConst = Font.PLAIN; if (weight != null && (weight == IdentValue.BOLD || weight == IdentValue.FONT_WEIGHT_700 || weight == IdentValue.FONT_WEIGHT_800 || weight == IdentValue.FONT_WEIGHT_900)) { fontConst = fontConst | Font.BOLD; } if (style != null && (style == IdentValue.ITALIC || style == IdentValue.OBLIQUE)) { fontConst = fontConst | Font.ITALIC; } // scale vs font scale value too size *= ctx.getTextRenderer().getFontScale(); Font fnt = rootFont.deriveFont(fontConst, size); if (variant != null) { if (variant == IdentValue.SMALL_CAPS) { fnt = fnt.deriveFont((float) (((float) fnt.getSize()) * 0.6)); } } return fnt; }
tmp.append(value); float valueWidth = c.getTextRenderer().getWidth(c.getFontContext(), iB.getStyle().getFSFont(c), tmp.toString()) / 100f; int spaceWidth = c.getTextRenderer().getWidth(c.getFontContext(), iB.getStyle().getFSFont(c), " "); int leaderStringWidth = c.getTextRenderer().getWidth(c.getFontContext(), iB.getStyle().getFSFont(c), leaderString); iB.setMarginLeft(c, leaderWidth - leaderStringWidth);
size *= ctx.getTextRenderer().getFontScale();
public void trimTrailingSpace(LayoutContext c) { if (! isEmpty() && _masterText.charAt(_end-1) == ' ') { _end--; setWidth(c.getTextRenderer().getWidth(c.getFontContext(), getParent().getStyle().getFSFont(c), getSubstring())); setTrimmedTrailingSpace(true); } }
private MarkerData.TextMarker makeTextMarker(LayoutContext c, IdentValue listStyle) { String text; int listCounter = getListCounter(); text = CounterFunction.createCounterText(listStyle, listCounter); text += ". "; int w = c.getTextRenderer().getWidth( c.getFontContext(), getStyle().getFSFont(c), text); MarkerData.TextMarker result = new MarkerData.TextMarker(); result.setText(text); result.setLayoutWidth(w); return result; }