-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Allow registering custom fonts from a buffer #386
Comments
Hi! I have the same problem, but another use case. I take a look at the code and in FontFace.cc there's a line that loads font face with FreeType: FreeType can load font faces another way too: http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Open_Face Here we can pass open arguments: In this struct if we set FT_OPEN_MEMORY flag then FreeType will read memory_size bytes starting from memory_base as a font. As soon as I have some time, I'll try to implement and test it. |
@6uliver if/when #715 gets merged in, you will have to use a different method. It will use Pango to lookup and draw the fonts, and FreeType isn't in the picture. You would want to send the buffer to an OS-specific call that registers the font with the operating system: CoreText, Fontconfig, or win32 APIs. Here is where I'm doing that on my PR. I haven't found a way to send a buffer to FontConfig but there are ways of doing it on both OSX and Windows |
Has this feature landed in node-canvas 2? |
No, not from a buffer. To do that on Linux we'd have to replace Pango with our own selection and font fallback code. I'd still love to do it at some point but it'd be another big overhaul. |
For use with jsdom package which simulates browser DOM in node.js and use node-canvas for canvas implementation a support to load fonts (truetype and openfont) from a buffer/content is needed. Because in HTML a custom font face can be specified as an URL, jsdom resolves this URL to a buffer/content by itself. So registration with buffer/content should be possible.
See jsdom/jsdom#744 for more details.
The text was updated successfully, but these errors were encountered: