servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
678 stars 100 forks source link

Add method to add to a `MemSource` after creation. #165

Closed derekdreery closed 3 years ago

derekdreery commented 3 years ago

This PR adds a method that allows a MemSource to be extended dynamically after creation. It is useful when implementing an interface that assumes this is possible (for me, the motivating interface is in https://github.com/linebender/piet).

derekdreery commented 3 years ago

I guess there might be an issue around what dynamic functionality you would be willing to support. If this library computes information about fonts eagerly and non-incrementally, then adding a new font could be a very expensive operation, requiring a rebuild of a lot of things. I still think its worth having the methods in that case, with a caveat in the docs that they should be avoided if possible.

derekdreery commented 3 years ago

I've also added https://github.com/derekdreery/font-kit/tree/multi_downcast to get at a MemSource dynamically for my needs. I don't want to open loads of PRs at the same time, but would invite comments on it.

jdm commented 3 years ago

@bors-servo r+ Looks good!

bors-servo commented 3 years ago

:pushpin: Commit 258a4da has been approved by jdm

bors-servo commented 3 years ago

:hourglass: Testing commit 258a4dadadac2005c46da8b882337440bbdafbd6 with merge 4b1ede011ff407e947c965942662dc0a177d9bd0...

bors-servo commented 3 years ago

:sunny: Test successful - checks-travis Approved by: jdm Pushing 4b1ede011ff407e947c965942662dc0a177d9bd0 to master...