Add a command for printing rasterized text #165
Draft
+50
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows us to print a line with a custom font, sizes and weights
which resolves problems with printing text of unsupported sizes (#132)
and unsupported character sets/code pages (#116)
We achieve this by rendering an image with text, sized to fit the text
itself and returning
byte[]
to be compatible with other commands.Fixes #132, #116
I'm opening this as a draft, as I'm a bit stuck on testing and some feedback on the API itself would be great. I'm using this in production currently and it's working quite well.
On the project which this is extracted from, I'm comparing the rendered text to a fixture using a library I cobbled together from some example code. It uses
System.Drawing.Common
, rather thanImageSharp
so one option would be for me to refactor that then use it here, but I'm open to any thoughts on that.Another problem with testing is needing a
ttf
font. A good choice here might be to bundle an open source font for this purpose, but I'm open to ideas.Finally, it's in the command emitters for images, which felt the most appropriate for what it's doing but it could easily go somewhere else.