@Override public void draw(BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage input = new BufferedImage( scale * glyph.getWidth(), scale * glyph.getHeight(), BufferedImage.TYPE_BYTE_BINARY); drawGlyph(input, glyph); DistanceFieldGenerator generator = new DistanceFieldGenerator(); generator.setColor(color); generator.setDownscale(scale); // We multiply spread by the scale, so that changing scale will only affect accuracy // and not spread in the output image. generator.setSpread(scale * spread); BufferedImage distanceField = generator.generateDistanceField(input); g.drawImage(distanceField, new AffineTransform(), null); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g = (Graphics2D)g.create(); g.translate(xDistance, yDistance); g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), Math.round(opacity * 255))); g.fill(glyph.getShape()); // Also shadow the outline, if one exists. for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) { Effect effect = (Effect)iter.next(); if (effect instanceof OutlineEffect) { Composite composite = g.getComposite(); g.setComposite(AlphaComposite.Src); // Prevent shadow and outline shadow alpha from combining. g.setStroke(((OutlineEffect)effect).getStroke()); g.draw(glyph.getShape()); g.setComposite(composite); break; } } g.dispose(); if (blurKernelSize > 1 && blurKernelSize < NUM_KERNELS && blurPasses > 0) blur(image); }
public void createFont(final File fntFile, final String name, final int size, final boolean isBold, final boolean isItalic) { final JFrame frame = new JFrame() {{ pack(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // IMPORTANT }}; frame.getContentPane().add(new MyLwjglCanvas(new ApplicationAdapter() { private final UnicodeFont unicodeFont = new UnicodeFont(Font.decode(name), size, isBold, isItalic); @Override public void create() { unicodeFont.setMono(false); unicodeFont.setPaddingTop(PADDING); unicodeFont.setPaddingRight(PADDING); unicodeFont.setPaddingBottom(PADDING); unicodeFont.setPaddingLeft(PADDING); unicodeFont.setPaddingAdvanceX(-2 * PADDING); unicodeFont.setPaddingAdvanceY(-2 * PADDING); unicodeFont.setGlyphPageWidth(1024); unicodeFont.setGlyphPageHeight(512); unicodeFont.setRenderType(UnicodeFont.RenderType.Java); List effects = unicodeFont.getEffects(); effects.add(new ColorEffect(Color.white)); unicodeFont.addGlyphs(CHARACTERS); try { FileUtil.createNewFile(fntFile); new BMFontUtil(unicodeFont).save(fntFile); } catch (Throwable ex) { ex.printStackTrace(); } if ("studio".equals(System.getProperty("featurea.launcher"))) { frame.dispose(); } else { frame.setVisible(false); } } }).getCanvas()); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g = (Graphics2D)g.create(); if (stroke != null) g.setStroke(stroke); else g.setStroke(getStroke()); g.setColor(color); g.draw(glyph.getShape()); g.dispose(); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { int ascent = unicodeFont.getAscent(); float height = (ascent) * scale; float top = -glyph.getYOffset() + unicodeFont.getDescent() + offset + ascent / 2 - height / 2; g.setPaint(new GradientPaint(0, top, topColor, 0, top + height, bottomColor, cyclic)); g.fill(glyph.getShape()); }
/** Called to draw the effect. */ public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph);
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage scratchImage = EffectUtil.getScratchImage(); filter.filter(image, scratchImage); image.getGraphics().drawImage(scratchImage, 0, 0, null); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g.setColor(color); g.fill(glyph.getShape()); }
public BMFontUtil (UnicodeFont unicodeFont) { this.unicodeFont = unicodeFont; }