public FSFont getFSFont(CssContext cssContext) { if (_FSFont == null) { _FSFont = cssContext.getFont(getFont(cssContext)); } return _FSFont; }
public FSFont getFSFont(CssContext cssContext) { if (_FSFont == null) { _FSFont = cssContext.getFont(getFont(cssContext)); } return _FSFont; }
public float getLineHeight(CssContext ctx) { if (! _lineHeightResolved) { if (isIdent(CSSName.LINE_HEIGHT, IdentValue.NORMAL)) { float lineHeight1 = getFont(ctx).size * 1.1f; // Make sure rasterized characters will (probably) fit inside // the line box FSFontMetrics metrics = getFSFontMetrics(ctx); float lineHeight2 = (float)Math.ceil(metrics.getDescent() + Math.round(metrics.getAscent())); _lineHeight = Math.max(lineHeight1, lineHeight2); } else if (isLength(CSSName.LINE_HEIGHT)) { //could be more elegant, I suppose _lineHeight = getFloatPropertyProportionalHeight(CSSName.LINE_HEIGHT, 0, ctx); } else { //must be a number _lineHeight = getFont(ctx).size * valueByName(CSSName.LINE_HEIGHT).asFloat(); } _lineHeightResolved = true; } return _lineHeight; }
public float getLineHeight(CssContext ctx) { if (! _lineHeightResolved) { if (isIdent(CSSName.LINE_HEIGHT, IdentValue.NORMAL)) { float lineHeight1 = getFont(ctx).size * 1.1f; // Make sure rasterized characters will (probably) fit inside // the line box FSFontMetrics metrics = getFSFontMetrics(ctx); float lineHeight2 = (float)Math.ceil(metrics.getDescent() + Math.round(metrics.getAscent())); _lineHeight = Math.max(lineHeight1, lineHeight2); } else if (isLength(CSSName.LINE_HEIGHT)) { //could be more elegant, I suppose _lineHeight = getFloatPropertyProportionalHeight(CSSName.LINE_HEIGHT, 0, ctx); } else { //must be a number _lineHeight = getFont(ctx).size * valueByName(CSSName.LINE_HEIGHT).asFloat(); } _lineHeightResolved = true; } return _lineHeight; }
private int getTextWidth(LayoutContext c, CalculatedStyle cs, String s) { return c.getTextRenderer().getWidth(c.getFontContext(), c.getFont(cs.getFont(c)), s); }
private int getTextWidth(LayoutContext c, CalculatedStyle cs, String s) { return c.getTextRenderer().getWidth(c.getFontContext(), c.getFont(cs.getFont(c)), s); }
private int getTextWidth(LayoutContext c, String s) { return c.getTextRenderer().getWidth( c.getFontContext(), c.getFont(getStyle().getFont(c)), s); }
private int getTextWidth(LayoutContext c, String s) { return c.getTextRenderer().getWidth( c.getFontContext(), c.getFont(getStyle().getFont(c)), s); }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { if (cssHeight != -1) { setWidth(cssHeight); } else { setWidth((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } if (cssHeight != -1) { setHeight(cssHeight); } else { if (cssWidth != -1) { setHeight(cssWidth); } else { setHeight((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { if (cssHeight != -1) { setWidth(cssHeight); } else { setWidth((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } if (cssHeight != -1) { setHeight(cssHeight); } else { if (cssWidth != -1) { setHeight(cssWidth); } else { setHeight((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { if (cssHeight != -1) { setWidth(cssHeight); } else { setWidth((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } if (cssHeight != -1) { setHeight(cssHeight); } else { if (cssWidth != -1) { setHeight(cssWidth); } else { setHeight((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { if (cssHeight != -1) { setWidth(cssHeight); } else { setWidth((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } if (cssHeight != -1) { setHeight(cssHeight); } else { if (cssWidth != -1) { setHeight(cssWidth); } else { setHeight((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { if (cssHeight != -1) { setWidth(cssHeight); } else { setWidth((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } if (cssHeight != -1) { setHeight(cssHeight); } else { if (cssWidth != -1) { setHeight(cssWidth); } else { setHeight((int) (box.getStyle().getFont(c).size * FONT_SIZE_ADJUSTMENT)); } } }
FontSpecification parentFont = style.getParent().getFont(ctx); absVal = relVal * style.getFont(ctx).size;//ctx.getFontSize2D(style.getFont(ctx)); FontSpecification parentFont = style.getParent().getFont(ctx); xHeight = ctx.getXHeight(parentFont); } else { FontSpecification font = style.getFont(ctx); xHeight = ctx.getXHeight(font); } else if (cssName == CSSName.FONT_SIZE) { FontSpecification parentFont = style.getParent().getFont(ctx); baseValue = ctx.getFontSize2D(parentFont); } else if (cssName == CSSName.LINE_HEIGHT) { FontSpecification font = style.getFont(ctx); baseValue = ctx.getFontSize2D(font);
FontSpecification parentFont = style.getParent().getFont(ctx); absVal = relVal * style.getFont(ctx).size;//ctx.getFontSize2D(style.getFont(ctx)); FontSpecification parentFont = style.getParent().getFont(ctx); xHeight = ctx.getXHeight(parentFont); } else { FontSpecification font = style.getFont(ctx); xHeight = ctx.getXHeight(font); } else if (cssName == CSSName.FONT_SIZE) { FontSpecification parentFont = style.getParent().getFont(ctx); baseValue = ctx.getFontSize2D(parentFont); } else if (cssName == CSSName.LINE_HEIGHT) { FontSpecification font = style.getFont(ctx); baseValue = ctx.getFontSize2D(font);
private static InlineBoxMeasurements getInitialMeasurements( LayoutContext c, Box container, FSFontMetrics strutM) { float lineHeight = container.getStyle().getLineHeight(c); int halfLeading = Math.round((lineHeight - container.getStyle().getFont(c).size) / 2); if (halfLeading > 0) { halfLeading = Math.round((lineHeight - (strutM.getDescent() + strutM.getAscent())) / 2); } InlineBoxMeasurements measurements = new InlineBoxMeasurements(); measurements.setBaseline((int) (halfLeading + strutM.getAscent())); measurements.setTextTop(halfLeading); measurements.setTextBottom((int) (measurements.getBaseline() + strutM.getDescent())); measurements.setInlineTop(halfLeading); measurements.setInlineBottom((int) (halfLeading + lineHeight)); return measurements; }
private static InlineBoxMeasurements getInitialMeasurements( LayoutContext c, Box container, FSFontMetrics strutM) { float lineHeight = container.getStyle().getLineHeight(c); int halfLeading = Math.round((lineHeight - container.getStyle().getFont(c).size) / 2); if (halfLeading > 0) { halfLeading = Math.round((lineHeight - (strutM.getDescent() + strutM.getAscent())) / 2); } InlineBoxMeasurements measurements = new InlineBoxMeasurements(); measurements.setBaseline((int) (halfLeading + strutM.getAscent())); measurements.setTextTop((int) halfLeading); measurements.setTextBottom((int) (measurements.getBaseline() + strutM.getDescent())); measurements.setInlineTop((int) halfLeading); measurements.setInlineBottom((int) (halfLeading + lineHeight)); return measurements; }
private static InlineBoxMeasurements calculateInlineMeasurements(LayoutContext c, InlineLayoutBox iB, VerticalAlignContext vaContext) { FSFontMetrics fm = iB.getStyle().getFSFontMetrics(c); CalculatedStyle style = iB.getStyle(); float lineHeight = style.getLineHeight(c); int halfLeading = Math.round((lineHeight - iB.getStyle().getFont(c).size) / 2); if (halfLeading > 0) { halfLeading = Math.round((lineHeight - (fm.getDescent() + fm.getAscent())) / 2); } iB.setBaseline(Math.round(fm.getAscent())); alignInlineContent(c, iB, fm.getAscent(), fm.getDescent(), vaContext); List decorations = calculateTextDecorations(iB, iB.getBaseline(), fm); if (decorations != null) { iB.setTextDecorations(decorations); } InlineBoxMeasurements result = new InlineBoxMeasurements(); result.setBaseline(iB.getY() + iB.getBaseline()); result.setInlineTop(iB.getY() - halfLeading); result.setInlineBottom(Math.round(result.getInlineTop() + lineHeight)); result.setTextTop(iB.getY()); result.setTextBottom((int) (result.getBaseline() + fm.getDescent())); RectPropertySet padding = iB.getPadding(c); BorderPropertySet border = iB.getBorder(c); result.setPaintingTop((int)Math.floor(iB.getY() - border.top() - padding.top())); result.setPaintingBottom((int)Math.ceil(iB.getY() + fm.getAscent() + fm.getDescent() + border.bottom() + padding.bottom())); return result; }
float lineHeight = style.getLineHeight(c); int halfLeading = Math.round((lineHeight - iB.getStyle().getFont(c).size) / 2); if (halfLeading > 0) { halfLeading = Math.round((lineHeight -