зеркало из https://github.com/mozilla/pluotsorbet.git
Fix text anchor handling
This commit is contained in:
Родитель
4ef62ca598
Коммит
aea2a2d91c
19
midp/gfx.js
19
midp/gfx.js
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче