mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
Improve text layout
This commit is contained in:
Binary file not shown.
@@ -63,8 +63,7 @@ function paint_command(canvas, cmd) {
|
||||
case "text":
|
||||
ctx.fillStyle = styleFromColor(cmd.fill_color);
|
||||
ctx.font = cmd.font_size + "px " + cmd.font_name;
|
||||
ctx.textAlign = cmd.text_align;
|
||||
ctx.textBaseline = "top";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillText(cmd.text, cmd.pos.x, cmd.pos.y);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ interface Text {
|
||||
pos: Vec2;
|
||||
stroke_color: Color | null;
|
||||
text: string;
|
||||
text_align: "start" | "center" | "end";
|
||||
}
|
||||
|
||||
type PaintCmd = Circle | Clear | Line | Rect | Text;
|
||||
@@ -132,8 +131,7 @@ function paint_command(canvas, cmd: PaintCmd) {
|
||||
case "text":
|
||||
ctx.fillStyle = styleFromColor(cmd.fill_color);
|
||||
ctx.font = `${cmd.font_size}px ${cmd.font_name}`;
|
||||
ctx.textAlign = cmd.text_align;
|
||||
ctx.textBaseline = "top";
|
||||
ctx.textBaseline = "middle";
|
||||
ctx.fillText(cmd.text, cmd.pos.x, cmd.pos.y);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user