- public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
- g.drawImage(((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
- }
-
- public void drawString(String font, String text, int x, int y, int argb) {
- // FEATURE: use an LRU cache for Color objects
- g.setColor(new Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
- g.setFont(getFont(font));
- g.drawString(text, x, y + 2);
+ /** implemented with java.awt 1.1's setXORMode() */
+ public void drawGlyph(org.xwt.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
+
+ // XOR the target region
+ g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+ g.setColor(new Color(0x0, 0x0, 0x0));
+ g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+ // blacken the area we want the glyph to cover
+ g.setPaintMode();
+ g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
+ g.drawImage(((AWTGlyph)source).getImage(), dx, dy, null);
+ g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
+
+ // XOR back, turning black into the chosen rgb color
+ g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
+ g.setColor(new Color(0x0, 0x0, 0x0));
+ g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
+
+ // restore the graphics context
+ g.setPaintMode();