-
Notifications
You must be signed in to change notification settings - Fork 148
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 cosmic text example #739
base: main
Are you sure you want to change the base?
Add cosmic text example #739
Conversation
Thanks, it's really good to see this. Would you consider making this a test scene (i.e. in the I think that would be useful because this new example has a lot of interleaving of logic between cosmic text and Vello and winit. If not, I think we can still land this nearly as-is, although it being another usage of winit is likely to cause us pain in future when we need to perform updates. |
Sure, I will do that. |
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.
This is looking good and runs as expected. Thanks for pulling this together
The exact integration with scenes could be cleaner, given that there's only one scene; if my guidance isn't clear enough, let me know and I can apply it myself.
|
||
for (font_id, index) in font_faces { | ||
if let Some(font) = font_system.get_font(font_id) { | ||
let resource = Arc::new(font.data().to_vec()); |
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.
There are two allocations here, one to put the data in the vec, and one to allocate the Arc
. The first could be avoided by creating an adapter which implements AsRef<[u8]>
by containing an Arc<Font>
and using the data parameter. The second would use https://docs.rs/bytemuck/latest/bytemuck/allocation/trait.TransparentWrapperAlloc.html#method.wrap_arc, and is definitely out-of-scope.
The best resolution to this would probably be to have a comment: "These allocations are avoidable, but used for simplicity.", maybe with a link to this comment?
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.
Not in time for this patch, but improving this is also a design goal for splitting these resource handles out of Peniko. (linebender/peniko#68)
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.
I have used an adapter and added a link to this comment.
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.
A wrapper/adapter is fine, but we should probably just submit a PR to cosmic-text to make Font
implement AsRef<[u8]>
. Alternatively, the correct type can be obtained using unsafe { font_system.db().make_shared_face_data(font_id).unwrap() }
.
Thanks for the feedback. I will work on this tomorrow. |
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.
What needs to happen to get this out of draft? It's looking quite good
} | ||
} | ||
|
||
let text = "おはよう (ja) (ohayō) 🌅✨ (morning), こんにちは (ja) (konnichi wa) ☀️😊 (daytime), こんばんは (ja) (konban wa) 🌙🌟 (evening)"; |
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.
For future reviewers:
These translations do also appear to be correct.
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.
Would you be able to also document that this exists at the top level of the repository, in https://github.com/linebender/vello?tab=readme-ov-file#integrations
Is there anything left here other than what I just commented on? Or is this basically ready to go? It would be nice to land it soon! |
I will rebase this hopefully in the next day or two |
14b9023
to
0a1ebba
Compare
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.
This is still blocked on the licensing question for the newly imported code - I'd still prefer us to just avoid importing that code entirely, but I might be missing something.
vello_tests/Cargo.toml
Outdated
@@ -22,3 +22,6 @@ nv-flip = "0.1.2" | |||
image = { workspace = true, features = ["png"] } | |||
|
|||
scenes = { workspace = true } | |||
|
|||
[features] | |||
cosmic_text = ["scenes/cosmic_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.
And here
0a1ebba
to
e504dac
Compare
@xStrom are you willing to review the name licensing things I've done here? I think I've covered it properly |
Add an example for cosmic text.
Related:
306