-
Notifications
You must be signed in to change notification settings - Fork 225
Open
Labels
area-renderingEverything related to the renderingEverything related to the renderingplatform-allAffects all platformsAffects all platformsstate-acceptedThis is a valid topic to work on.This is a valid topic to work on.
Description
The SVG rendering currently uses a rather hacky text measurement engine where we pre-compute certain character sizes and then sum them up. for bold and italic we just add a factor.
This is error prone and often imprecise.
To eliminate this problem we should implement a new text-renderer for all platforms.
C#/Kotlin
For C# and Kotlin it's fairly easy: We simply use alphaSkia. Any potential custom-fonts should be registered there already.
JS Node
Same as for C#/Kotlin we can rely on alphaSkia.
JS Browser
Here it gets tricky. In Web Workers we do not have access to the web fonts loaded so we need to find something different:
- The general idea is to use a OffScreenCanvas and load all fonts into the worker context using the font loading APIs.
- To pass the web fonts to the worker context we do the following:
- We allow users to explicitly specify the font sources. If users specify the location we can pass the metadata to the worker and load the fonts there. The config would be similar to how we have it for the SMuFl Fonts. For one font, we might have multiple sources.
- We should align the options to the properties available for
FontFacedefinitions (family, style, weight, src, unicode-range). As this feature is web-only we can use the web type definitions directly.
- We should align the options to the properties available for
- If no font source is specified, we try to auto-detect it. Unfortunately
FontFacedoes not give us access to the original source.Array.from(document.styleSheets).flatMap(y => Array.from(y.rules).filter(z => z instanceof CSSFontFaceRule))gives us access to all custom web font definitions.- For every font needed in the rendering, we lookup the matching CSS font rules (matching can be rather loose, better have more fonts than less).
- We fill the remaining font definitions.
- We allow users to explicitly specify the font sources. If users specify the location we can pass the metadata to the worker and load the fonts there. The config would be similar to how we have it for the SMuFl Fonts. For one font, we might have multiple sources.
LIUBINfighter
Metadata
Metadata
Assignees
Labels
area-renderingEverything related to the renderingEverything related to the renderingplatform-allAffects all platformsAffects all platformsstate-acceptedThis is a valid topic to work on.This is a valid topic to work on.
Type
Projects
Status
No status