Closed benesch closed 4 years ago
Thanks for asking, @benesch. You are right - this was missing. I have now pushed the tool that was used to generate those files, FontWidth.html.
The contract of Normal.get(i0)
is to return the width required when rendering codepoint i0
, with font-weight:normal
, in tenths of a pixel. My approach to implementing this is:
FontWidth.html
Normal.java.compress
Normal.java
Normal.java
manuallyThe same applies to Bold.get(i0)
, using font-weight:bold
. For best results, measure widths on multiple browsers and select the maximum measured width for each codepoint.
If you see better alternatives for static width calculation, please let me know.
Indeed, this works perfectly. Thanks very much, @GuntherRademacher!
By the way, I was impatient at first and generated a font width table with code points up until 0xFF
. Uploading this width table to REx resulted in a Java file with a syntax error. I've made a gist with the problematic input and output: https://gist.github.com/benesch/7f68ea2c6be87403a217e7ebd0882142. The error is on line 15. This wasn't a problem with a larger font table, which I guess tickles a different code path in REx's code generation. Not at all problematic for us—happy to just use larger font width tables—but thought you might want to know nonetheless.
Oh, also, I wanted to mention that our fork is here: https://github.com/MaterializeInc/rr/commits/master. Besides the font changes, which are likely irrelevant to everyone else, we added some patches to extract unstyled SVGs, so we can chop them up across our documentation site to our liking.
I'm not currently planning to upstream anything, but if you see anything you'd like to incorporate, I'm happy to try to clean up the patches and send up some PRs.
Thanks, @benesch, for reporting the badly generated file. This has been fixed in REx v5.52.
I don't currently have a usecase for unstyled SVGs, but if you want those changes integrated here, that's fine with me.
I don't currently have a usecase for unstyled SVGs, but if you want those changes integrated here, that's fine with me.
We have to maintain our own fork for several other reasons, so no need to integrate them here unless you have a use case for them.
Thanks so much for all your help with this, @GuntherRademacher! Very much appreciated.
Hi @GuntherRademacher, thanks very much for open sourcing this! It's a huge help. If you have a minute, could you shed some light on how you generated the font width tables in Normal.java and Bold.java? (I'd like to swap them out for a different font.) Thanks very much!