use of processing.app.syntax.TextAreaPainter in project processing by processing.
the class CompositionTextManager method getTextLayout.
private TextLayout getTextLayout(AttributedCharacterIterator text, int committedCount) {
boolean antialias = Preferences.getBoolean("editor.smooth");
TextAreaPainter painter = textArea.getPainter();
// create attributed string with font info.
AttributedString composed = new AttributedString(text, committedCount, text.getEndIndex());
Font font = painter.getFontMetrics().getFont();
composed.addAttribute(TextAttribute.FONT, font);
// set hint of antialiasing to render target.
Graphics2D g2d = (Graphics2D) painter.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialias ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
FontRenderContext frc = g2d.getFontRenderContext();
Messages.log("debug: FontRenderContext is Antialiased = " + frc.getAntiAliasingHint());
return new TextLayout(composed.getIterator(), frc);
}
use of processing.app.syntax.TextAreaPainter in project processing by processing.
the class InputMethodSupport method getTextLayout.
private TextLayout getTextLayout(AttributedCharacterIterator text, int committedCount) {
boolean antialias = Preferences.getBoolean("editor.smooth");
TextAreaPainter painter = textArea.getPainter();
// create attributed string with font info.
if (text.getEndIndex() - (text.getBeginIndex() + committedCount) > 0) {
composedTextString = new AttributedString(text, committedCount, text.getEndIndex(), CUSTOM_IM_ATTRIBUTES);
Font font = painter.getFontMetrics().getFont();
TextAreaDefaults defaults = textArea.getDefaults();
Color bgColor = defaults.lineHighlight ? defaults.lineHighlightColor : defaults.bgcolor;
composedTextString.addAttribute(TextAttribute.FONT, font);
composedTextString.addAttribute(TextAttribute.FOREGROUND, defaults.fgcolor);
composedTextString.addAttribute(TextAttribute.BACKGROUND, bgColor);
} else {
composedTextString = new AttributedString("");
return null;
}
// set hint of antialiasing to render target.
Graphics2D g2d = (Graphics2D) painter.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antialias ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
FontRenderContext frc = g2d.getFontRenderContext();
if (Base.DEBUG) {
Messages.log("debug: FontRenderContext is Antialiased = " + frc.getAntiAliasingHint());
}
return new TextLayout(composedTextString.getIterator(), frc);
}
Aggregations