Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CanvasRenderingContext2D.font property #26176

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Add empty getter and setter for font attribute

  • Loading branch information
pylbrecht committed May 11, 2020
commit ec3d5b47462161aec7c48cf959fed5e2bba9fc19
@@ -1558,6 +1558,16 @@ impl CanvasState {
));
Ok(())
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
pub fn font(&self) -> DOMString {
unimplemented!()
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
pub fn set_font(&self, _value: DOMString) {
unimplemented!()
}
}

pub fn parse_color(string: &str) -> Result<RGBA, ()> {
@@ -606,6 +606,16 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
fn SetShadowColor(&self, value: DOMString) {
self.canvas_state.set_shadow_color(value)
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
fn Font(&self) -> DOMString {
self.canvas_state.borrow().font()
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
fn SetFont(&self, value: DOMString) {
self.canvas_state.borrow().set_font(value)
}
}

impl Drop for CanvasRenderingContext2D {
@@ -513,4 +513,14 @@ impl OffscreenCanvasRenderingContext2DMethods for OffscreenCanvasRenderingContex
self.canvas_state
.ellipse(x, y, rx, ry, rotation, start, end, ccw)
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
fn Font(&self) -> DOMString {
self.canvas_state.borrow().font()
}

// https://html.spec.whatwg.org/multipage/#dom-context-2d-font
fn SetFont(&self, value: DOMString) {
self.canvas_state.borrow().set_font(value)
}
}
@@ -211,7 +211,7 @@ interface mixin CanvasPathDrawingStyles {
[Exposed=(PaintWorklet, Window, Worker)]
interface mixin CanvasTextDrawingStyles {
// text
//attribute DOMString font; // (default 10px sans-serif)
attribute DOMString font; // (default 10px sans-serif)
//attribute CanvasTextAlign textAlign; // "start", "end", "left", "right", "center" (default: "start")
//attribute CanvasTextBaseline textBaseline; // "top", "hanging", "middle", "alphabetic",
// "ideographic", "bottom" (default: "alphabetic")
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.