Title: Raster Graphics TextMeasure for SVG · Issue #2407 · CoderLine/alphaTab · GitHub
Open Graph Title: Raster Graphics TextMeasure for SVG · Issue #2407 · CoderLine/alphaTab
X Title: Raster Graphics TextMeasure for SVG · Issue #2407 · CoderLine/alphaTab
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 th...
Open Graph 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 pr...
X 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 pr...
Opengraph URL: https://github.com/CoderLine/alphaTab/issues/2407
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Raster Graphics TextMeasure for SVG","articleBody":"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. \n\nThis is error prone and often imprecise. \n\nTo eliminate this problem we should implement a new text-renderer for all platforms. \n\n## C#/Kotlin \nFor C# and Kotlin it's fairly easy: We simply use alphaSkia. Any potential custom-fonts should be registered there already. \n\n## JS Node\nSame as for C#/Kotlin we can rely on alphaSkia. \n\n## JS Browser\n\nHere it gets tricky. In Web Workers we do not have access to the web fonts loaded so we need to find something different:\n\n1. The general idea is to use a OffScreenCanvas and load all fonts into the worker context using the font loading APIs. \n2. To pass the web fonts to the worker context we do the following: \n 1. 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. \n 1. We should align the options to the properties available for `FontFace` definitions ([family, style, weight, src, unicode-range](https://developer.mozilla.org/en-US/docs/Web/API/FontFace/FontFace)). As this feature is web-only we can use the web type definitions directly.\n 3. If no font source is specified, we try to auto-detect it. Unfortunately `FontFace` does not give us access to the original source. \n 1. `Array.from(document.styleSheets).flatMap(y =\u003e Array.from(y.rules).filter(z =\u003e z instanceof CSSFontFaceRule))` gives us access to all custom web font definitions. \n 2. 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). \n 3. We fill the remaining font definitions. \n\n ","author":{"url":"https://github.com/Danielku15","@type":"Person","name":"Danielku15"},"datePublished":"2025-12-04T19:04:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2407/alphaTab/issues/2407"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8d37292a-a3d1-74b0-cd5a-8ba129ec9498 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ACBE:1E27CA:3C2DA:4B3AB:69905E9F |
| html-safe-nonce | e0dd56836ac647dec4de8ae5ae007ee61bbb16d64f42ae04eff52fa34b139778 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQ0JFOjFFMjdDQTozQzJEQTo0QjNBQjo2OTkwNUU5RiIsInZpc2l0b3JfaWQiOiI1OTE0NDcwNjAzMTg4ODg3MTk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4354e5c8648da9665073ff4a388b35094d4730d9db3edf9ba41ce3580d806565 |
| hovercard-subject-tag | issue:3696077167 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/CoderLine/alphaTab/2407/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afdb8e776e27b9ddb7e475f7f0d3a22c281b5054277e82a4d97d95653fdf7944/CoderLine/alphaTab/issues/2407 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afdb8e776e27b9ddb7e475f7f0d3a22c281b5054277e82a4d97d95653fdf7944/CoderLine/alphaTab/issues/2407 |
| og:image:alt | 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 pr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Danielku15 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/CoderLine/alphaTab git https://github.com/CoderLine/alphaTab.git |
| octolytics-dimension-user_id | 715045 |
| octolytics-dimension-user_login | CoderLine |
| octolytics-dimension-repository_id | 1491192 |
| octolytics-dimension-repository_nwo | CoderLine/alphaTab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1491192 |
| octolytics-dimension-repository_network_root_nwo | CoderLine/alphaTab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width