Possible to load fonts from string? #2112
-
Yesterday I did a quick try to integrate alphaTab in TiddlyWiki5, which is a self-contained Wiki in a single HTML file (or a little bit more advanced on Node.Js configuration) However, the struggles I came across are the way TiddlyWiki5 needs to load the fonts. We cannot access a directory outside but I can get the font as a string and pass that to the alphaTab API. Is there currently a way to do so? Thanks for your replies, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I'm not familiar with TiddlyWiki and you might have to check with the Community there how to best embed dynamic UI components there. What I can share from a general usage of alphaTab: Using alphaTab in a browser environment (similar to Electron having a Node.js backend and a Chromium frontend). Typically these "embedded" browsers still have some capabilities of interacting with the backend through some mechanism.Generally alphaTab is not loading the custom fonts used for display of texts, but rather only checking if the fonts are available via CSS Font loading APIs of the browser. Hence you have to check how to embedd web fonts in this environment and ensure they are available via the Font APIs. Some references around that: https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Text_styling/Web_fonts One special case is the Music Font (Bravura) where we create a Here we do not have (yet) much customization available. I haven't tried it yet but following workarounds might work:
I added #2113 as improvement feature to cover the need of fully customizing the URLs of the font. Using alphaTab in a headless environment (pure Node.js)If you use alphaSkia to render PNGs you can load fonts from any Uint8Array (which could be a base64 string you decode or you simply have a constant somewhere embedded):
If you want to use SVG display it gets a bit more tricky and we're back to "how does the UI handle custom fonts". If you can share some more bits how things are organized in this Wiki I might be able to help better. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @Danielku15 I got the fonts working with your help! |
Beta Was this translation helpful? Give feedback.
I'm not familiar with TiddlyWiki and you might have to check with the Community there how to best embed dynamic UI components there. What I can share from a general usage of alphaTab:
Using alphaTab in a browser environment (similar to Electron having a Node.js backend and a Chromium frontend). Typically these "embedded" browsers still have some capabilities of interacting with the backend through some mechanism.
Generally alphaTab is not loading the custom fonts used for display of texts, but rather only checking if the fonts are available via CSS Font loading APIs of the browser. Hence you have to check how to embedd web fonts in this environment and ensure they are available via the Fo…