use of java.awt.font.FontRenderContext in project intellij-community by JetBrains.
the class TextPainter method getCharWidth.
private double getCharWidth(Graphics2D g) {
if (myCharWidth < 0) {
FontRenderContext fontRenderContext = (g).getFontRenderContext();
myCharWidth = myPlainFont.getStringBounds(DEFAULT_MEASURE_WIDTH_TEXT, fontRenderContext).getWidth();
}
return myCharWidth;
}
use of java.awt.font.FontRenderContext in project intellij-community by JetBrains.
the class TextPainter method getLineHeight.
private float getLineHeight(Graphics g) {
if (myLineHeight >= 0) {
return myLineHeight;
}
FontRenderContext fontRenderContext = ((Graphics2D) g).getFontRenderContext();
LineMetrics lineMetrics = myPlainFont.getLineMetrics(DEFAULT_MEASURE_HEIGHT_TEXT, fontRenderContext);
myLineHeight = lineMetrics.getHeight();
return myLineHeight;
}
use of java.awt.font.FontRenderContext in project intellij-community by JetBrains.
the class SimpleColoredComponent method computeStringWidth.
private float computeStringWidth(int fragmentIndex, Font font) {
String text = myFragments.get(fragmentIndex);
if (StringUtil.isEmpty(text))
return 0;
FontRenderContext fontRenderContext = getFontMetrics(font).getFontRenderContext();
TextLayout layout = getTextLayout(fragmentIndex, font, fontRenderContext);
if (layout != null) {
return layout.getAdvance();
} else {
return (float) font.getStringBounds(text, fontRenderContext).getWidth();
}
}
use of java.awt.font.FontRenderContext in project poi by apache.
the class BaseTestBugzillaIssues method computeCellWidthManually.
// FIXME: this function is a self-fulfilling prophecy: this test will always pass as long
// as the code-under-test and the testcase code are written the same way (have the same bugs).
private double computeCellWidthManually(Cell cell0, Font font) {
final FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);
RichTextString rt = cell0.getRichStringCellValue();
String[] lines = rt.getString().split("\\n");
assertEquals(1, lines.length);
String txt = lines[0] + "0";
AttributedString str = new AttributedString(txt);
copyAttributes(font, str, txt.length());
// TODO: support rich text fragments
/*if (rt.numFormattingRuns() > 0) {
}*/
TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
double frameWidth = getFrameWidth(layout);
return ((frameWidth / 1) / 8);
}
use of java.awt.font.FontRenderContext in project limelight by slagyr.
the class PropPanelTest method hasChangesWhenTextIsChanged.
@Test
public void hasChangesWhenTextIsChanged() throws Exception {
TextPanel.staticFontRenderingContext = new FontRenderContext(new AffineTransform(), true, true);
Layouts.on(panel, panel.getDefaultLayout());
panel.resetNeededLayout();
panel.setText("blah");
assertEquals(true, panel.needsLayout());
panel.resetNeededLayout();
panel.setText("blah");
assertEquals(false, panel.needsLayout());
panel.setText("new text");
assertEquals(true, panel.needsLayout());
}
Aggregations