Skip to content

Commit

Permalink
Fix text anchor handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Castelluccio committed Dec 4, 2014
1 parent 4ef62ca commit aea2a2d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions midp/gfx.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,21 @@
var w = withFont(g.class.getField("I.currentFont.Ljavax/microedition/lcdui/Font;").get(g), c, str);
c.textAlign = "left";
c.textBaseline = "top";
if (anchor & RIGHT)

if (anchor & RIGHT) {
x -= w;
if (anchor & HCENTER)
x -= (w/2)|0;
if (anchor & BOTTOM)
} else if (anchor & HCENTER) {
x -= (w >>> 1) | 0;
}

if (anchor & BOTTOM) {
c.textBaseline = "bottom";
if (anchor & VCENTER)
c.textBaseline = "middle";
if (anchor & BASELINE)
} else if (anchor & BASELINE) {
c.textBaseline = "alphabetic";
} else if (anchor & VCENTER) {
throw new JavaException("java/lang/IllegalArgumentException", "VCENTER not allowed with text");
}

cb(x, y, w);
});
}
Expand Down

0 comments on commit aea2a2d

Please sign in to comment.