/** * Returns a bold version of the given {@link Font}. * * @param baseFont the {@link Font} for which a bold version is desired * @return the bold version of the given {@link Font} */ public static Font getBoldFont(Font baseFont) { Font font = m_fontToBoldFontMap.get(baseFont); if (font == null) { FontData fontDatas[] = baseFont.getFontData(); FontData data = fontDatas[0]; font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); m_fontToBoldFontMap.put(baseFont, font); } return font; }
private static void paintImage2(GC gc, Point size, int f) { gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(0, 0, size.x, size.y); // Scale line width, corner roundness, and font size. // Caveat: line width expands in all directions, so the origin also has to move. gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION)); gc.fillRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f); gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.setLineWidth(f); gc.drawRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f); FontData fontData = gc.getFont().getFontData()[0]; fontData.setHeight(fontData.getHeight() * f); Font font = new Font(gc.getDevice(), fontData); try { gc.setFont(font); gc.drawText(fontData.toString(), 10 * f, 10 * f, true); } finally { font.dispose(); } }