mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibWeb: Add Canvas Context2D basic text align and text baseline support
Add the CanvasTextDrawingStyles mixin with the textAlign and textBaseline attributes. Update fill_text in CanvasRenderingContext2D to move the text rect by the text align and text baseline attributes. Wrote a simple HTML example to showcase the new features.
This commit is contained in:
parent
e689422564
commit
220e34b69d
9 changed files with 159 additions and 9 deletions
|
@ -0,0 +1,22 @@
|
|||
// https://html.spec.whatwg.org/multipage/canvas.html#canvastextalign
|
||||
// enum CanvasTextAlign { "start", "end", "left", "right", "center" };
|
||||
// enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" };
|
||||
enum CanvasDirection { "ltr", "rtl", "inherit" };
|
||||
enum CanvasFontKerning { "auto", "normal", "none" };
|
||||
enum CanvasFontStretch { "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" };
|
||||
enum CanvasFontVariantCaps { "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase", "titling-caps" };
|
||||
enum CanvasTextRendering { "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision" };
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/canvas.html#canvastextdrawingstyles
|
||||
interface mixin CanvasTextDrawingStyles {
|
||||
// FIXME: attribute DOMString font; // (default 10px sans-serif)
|
||||
attribute CanvasTextAlign textAlign; // (default: "start")
|
||||
attribute CanvasTextBaseline textBaseline; // (default: "alphabetic")
|
||||
// FIXME: attribute CanvasDirection direction; // (default: "inherit")
|
||||
// FIXME: attribute DOMString letterSpacing; // (default: "0px")
|
||||
// FIXME: attribute CanvasFontKerning fontKerning; // (default: "auto")
|
||||
// FIXME: attribute CanvasFontStretch fontStretch; // (default: "normal")
|
||||
// FIXME: attribute CanvasFontVariantCaps fontVariantCaps; // (default: "normal")
|
||||
// FIXME: attribute CanvasTextRendering textRendering; // (default: "auto")
|
||||
// FIXME: attribute DOMString wordSpacing; // (default: "0px")
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue