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

Add basic font and text support #5

Merged
merged 10 commits into from
Jan 7, 2019
Merged

Add basic font and text support #5

merged 10 commits into from
Jan 7, 2019

Conversation

raphlinus
Copy link
Contributor

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.

self.set_brush(brush);
let pos = pos.round_into();
self.ctx.move_to(pos.x, pos.y);
self.ctx.show_text(&layout.text);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@rylev
Copy link
Collaborator

rylev commented Jan 7, 2019

@raphlinus Do you need assistance converting the progress here in piet-web to wasm-bindgen?

@raphlinus
Copy link
Contributor Author

@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".
@raphlinus raphlinus mentioned this pull request Jan 7, 2019
Go Rust-native solutions to thorny problems!
@raphlinus raphlinus merged commit f8bae67 into master Jan 7, 2019
@raphlinus raphlinus deleted the text branch January 7, 2019 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants