-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add basic font and text support #5
Conversation
WIP, please fix paths and workspace at very least
Cairo and web are stubbed out. Still work in progress, lots of things to fix.
self.set_brush(brush); | ||
let pos = pos.round_into(); | ||
self.ctx.move_to(pos.x, pos.y); | ||
self.ctx.show_text(&layout.text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth adding a comment that this doesn't shape the text while the other backends do shape the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. At some point I'd like to blend in proper text layout, which is then likely to be useful with a number of back-ends, particularly lower level GPU-tuned ones. This is a bit of a hard problem, and I'm not sure what solution is best. But you're certainly right; as long as I'm using the "toy" text API of Cairo, that should be documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrmuizel I added a README, do you think that addresses your concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. That looks good. You may want to mention the option of using font-kit to handle font discovery.
@raphlinus Do you need assistance converting the progress here in piet-web to wasm-bindgen? |
@rylev Thanks for the offer, but the merge was pretty easy. You can double-check my work if you like. |
This is mostly to address the review comment about the limitations of using the "toy text API".
Go Rust-native solutions to thorny problems!
This patch adds basic ability to draw text, supported by all three back-ends. More work is needed to specify font options, measure text, etc., but it's a start.