protected void initFont() { myNormalFont = createFont(); myBoldFont = myNormalFont.deriveFont(Font.BOLD); myItalicFont = myNormalFont.deriveFont(Font.ITALIC); myBoldItalicFont = myBoldFont.deriveFont(Font.ITALIC); establishFontMetrics(); }
// {{{ parseHighlightStyle() SyntaxStyle parseHighlightStyle(String style) { Font f = (resultTree != null) ? resultTree.getFont() : UIManager.getFont("Tree.font"); SyntaxStyle s; try { s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true, null); } catch (Exception e) { style = "color:#000000"; s = SyntaxUtilities.parseStyle(style, f.getFamily(), f.getSize(), true); } return s; } // }}}
public void adjustFont(int w, int h) { if (h <= 0) return; int oldH = rHeight; if (font == null) { font = getFont(); fontH = font.getSize(); rHeight = fontH; } nHeight = h; if (fontH >= h) rHeight = h - 2; else rHeight = fontH; if ((rHeight < 10) && (fontH > 10)) rHeight = 10; if (oldH != rHeight) { // Font curFont = font.deriveFont((float) rHeight); Font curFont = DisplayOptions.getFont(font.getName(), font.getStyle(), rHeight); setFont(curFont); } if (rHeight > h) rHeight = h; }
public void changeFont() { font = DisplayOptions.getFont(fontName, fontStyle, fontSize); setFont(font); fontH = font.getSize(); rHeight = fontH; if (!inEditMode) { if ((curDim.height > 0) && (rHeight > curDim.height)) { adjustFont(curDim.width, curDim.height); } } repaint(); }
private void establishFontMetrics() { final BufferedImage img = createBufferedImage(1, 1); final Graphics2D graphics = img.createGraphics(); graphics.setFont(myNormalFont); final float lineSpace = mySettingsProvider.getLineSpace(); final FontMetrics fo = graphics.getFontMetrics(); myDescent = fo.getDescent(); myCharSize.width = fo.charWidth('W'); myCharSize.height = fo.getHeight() + (int) (lineSpace * 2); myDescent += lineSpace; myMonospaced = isMonospaced(fo); if (!myMonospaced) { LOG.info("WARNING: Font " + myNormalFont.getName() + " is non-monospaced"); } img.flush(); graphics.dispose(); }
public void setEditMode(boolean s) { if (s) { addMouseListener(ml); setOpaque(s); if (font != null) { setFont(font); fontH = font.getSize(); rHeight = fontH; } defDim = getPreferredSize(); curLoc.x = defLoc.x; curLoc.y = defLoc.y; curDim.width = defDim.width; curDim.height = defDim.height; xRatio = 1.0; yRatio = 1.0; } else { removeMouseListener(ml); if ((bg != null) || (isActive < 1)) setOpaque(true); else setOpaque(false); } inEditMode = s; }