added background color option to Font.drawGlyph()
authoradam <adam@megacz.com>
Sun, 9 Jan 2005 09:23:11 +0000 (09:23 +0000)
committeradam <adam@megacz.com>
Sun, 9 Jan 2005 09:23:11 +0000 (09:23 +0000)
darcs-hash:20050109092311-5007d-dee0405ccf2b22c6986337bbd48d869fd49e9848.gz

src/org/ibex/graphics/Font.java

index 1f8f35c..8e29b22 100644 (file)
@@ -68,6 +68,9 @@ public class Font {
      *  @returns <code>(width&lt;&lt;32)|height</code>
      */
     public long rasterizeGlyphs(String text, PixelBuffer pb, int textcolor, int x, int y, int cx1, int cy1, int cx2, int cy2) {
+        return rasterizeGlyphs(text, pb, textcolor, x, y, cx1, cy1, cx2, cy2, 0); }
+    public long rasterizeGlyphs(String text, PixelBuffer pb, int textcolor, int x, int y,
+                                int cx1, int cy1, int cx2, int cy2, int bg) {
         int width = 0, height = 0;
         if (!latinCharsPreloaded) {       // preload the Latin-1 charset with low priority (we'll probably want it)
             for(int i=48; i<57; i++) if (glyphs[i]==null) glyphsToBeCached.put(glyphs[i]=Platform.createGlyph(this, (char)i),"");
@@ -84,7 +87,14 @@ public class Font {
             Glyph g = glyphs[c];
             if (g == null) glyphs[c] = g = Platform.createGlyph(this, c);
             g.render();
-            if (pb != null) pb.drawGlyph(g, x + width, y + g.font.max_ascent - g.baseline, cx1, cy1, cx2, cy2, textcolor);
+            if (pb != null) pb.drawGlyph(g,
+                                         x + width,
+                                         y + g.font.max_ascent - g.baseline,
+                                         x+width,
+                                         cy1,
+                                         x+width+g.advance,
+                                         cy2,
+                                         textcolor, bg);
             width += g.advance;
             height = java.lang.Math.max(height, max_ascent + max_descent);
         }