private void applyLineHeightHack(CssContext cssCtx, Box line, Rectangle bounds) { // this is a hack to deal with lines w/o width or height. is this valid? // possibly, since the line doesn't know how long it should be until it's already // done float adjustments if (line.getHeight() == 0) { bounds.height = (int)line.getStyle().getLineHeight(cssCtx); } }
private void applyLineHeightHack(CssContext cssCtx, Box line, Rectangle bounds) { // this is a hack to deal with lines w/o width or height. is this valid? // possibly, since the line doesn't know how long it should be until it's already // done float adjustments if (line.getHeight() == 0) { bounds.height = (int)line.getStyle().getLineHeight(cssCtx); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(calcDefaultWidth(c, box)); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c) * getSize(box.getElement()))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(calcDefaultWidth(c, box)); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c) * getSize(box.getElement()))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(calcDefaultWidth(c, box)); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c) * getSize(box.getElement()))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(calcDefaultWidth(c, box)); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c) * getSize(box.getElement()))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(calcDefaultWidth(c, box)); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c) * getSize(box.getElement()))); } }
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 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 void alignInlineContent(LayoutContext c, Box box, float ascent, float descent, VerticalAlignContext vaContext) { InlineBoxMeasurements measurements = vaContext.getParentMeasurements(); CalculatedStyle style = box.getStyle(); if (style.isLength(CSSName.VERTICAL_ALIGN)) { box.setY((int) (measurements.getBaseline() - ascent - style.getFloatPropertyProportionalTo(CSSName.VERTICAL_ALIGN, style.getLineHeight(c), c))); } else { IdentValue vAlign = style.getIdent(CSSName.VERTICAL_ALIGN); if (vAlign == IdentValue.BASELINE) { box.setY(Math.round(measurements.getBaseline() - ascent)); } else if (vAlign == IdentValue.TEXT_TOP) { box.setY(measurements.getTextTop()); } else if (vAlign == IdentValue.TEXT_BOTTOM) { box.setY(Math.round(measurements.getTextBottom() - descent - ascent)); } else if (vAlign == IdentValue.MIDDLE) { // FIXME: findbugs, loss of precision, try / (float)2 box.setY(Math.round((measurements.getBaseline() - measurements.getTextTop()) / 2 - (ascent + descent) / 2)); } else if (vAlign == IdentValue.SUPER) { box.setY(Math.round(measurements.getBaseline() - (3*ascent/2))); } else if (vAlign == IdentValue.SUB) { box.setY(Math.round(measurements.getBaseline() - ascent / 2)); } else { box.setY(Math.round(measurements.getBaseline() - ascent)); } } }
private static void alignInlineContent(LayoutContext c, Box box, float ascent, float descent, VerticalAlignContext vaContext) { InlineBoxMeasurements measurements = vaContext.getParentMeasurements(); CalculatedStyle style = box.getStyle(); if (style.isLength(CSSName.VERTICAL_ALIGN)) { box.setY((int) (measurements.getBaseline() - ascent - style.getFloatPropertyProportionalTo(CSSName.VERTICAL_ALIGN, style.getLineHeight(c), c))); } else { IdentValue vAlign = style.getIdent(CSSName.VERTICAL_ALIGN); if (vAlign == IdentValue.BASELINE) { box.setY(Math.round(measurements.getBaseline() - ascent)); } else if (vAlign == IdentValue.TEXT_TOP) { box.setY(measurements.getTextTop()); } else if (vAlign == IdentValue.TEXT_BOTTOM) { box.setY(Math.round(measurements.getTextBottom() - descent - ascent)); } else if (vAlign == IdentValue.MIDDLE) { box.setY(Math.round((measurements.getBaseline() - measurements.getTextTop()) / 2 - (ascent + descent) / 2)); } else if (vAlign == IdentValue.SUPER) { box.setY(Math.round(measurements.getBaseline() - (3*ascent/2))); } else if (vAlign == IdentValue.SUB) { box.setY(Math.round(measurements.getBaseline() - ascent / 2)); } else { box.setY(Math.round(measurements.getBaseline() - ascent)); } } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(c.getTextRenderer().getWidth( c.getFontContext(), box.getStyle().getFSFont(c), spaces(getSize(box.getElement())))); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(c.getTextRenderer().getWidth( c.getFontContext(), box.getStyle().getFSFont(c), spaces(getSize(box.getElement())))); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c))); } }
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);
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(c.getTextRenderer().getWidth( c.getFontContext(), box.getStyle().getFSFont(c), spaces(getSize(box.getElement())))); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(c.getTextRenderer().getWidth( c.getFontContext(), box.getStyle().getFSFont(c), spaces(getSize(box.getElement())))); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c))); } }
protected void initDimensions(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { if (cssWidth != -1) { setWidth(cssWidth); } else { setWidth(c.getTextRenderer().getWidth( c.getFontContext(), box.getStyle().getFSFont(c), spaces(getSize(box.getElement())))); } if (cssHeight != -1) { setHeight(cssHeight); } else { setHeight((int) (box.getStyle().getLineHeight(c))); } }
baseValue = style.getParent().getLineHeight(ctx); } else if (cssName == CSSName.FONT_SIZE) {
relVal = style.getParent().getLineHeight(ctx); } else if (cssName == CSSName.FONT_SIZE) {