Feature request: editor.fontWeight
Hi!
VS-Code added a while back "editor.fontWeight" option. I'm used to run with this setting as "bold". It would be nice if Oni also supposed this feature.
On Linux I usually use "Monaco" , and set it to bold so I can see it from a bit further away. (And I think it renders better as bold on my machines)
Thanks
Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.
@satotake Did #2232 address this issue? Should we have the respective webgl implementation to close?
Hey!
I just tried editor.fontWeight, and it works perfectly on my end.
Thanks for implenting this!
@Cryza Do you have any pointers on how to implement this for the webgl rendere? I'd like to take a stab
Should we have the respective webgl implementation to close?
It is worthwhile implementing webgl version beacause it has the potential to be set as default renderer when it is stable. If you do not mind, could you implement it? @badosu
Sorry for the late reply, I kind of missed the @.
As a prerequisite information, it might be relevant that our WebGL renderer works by rendering characters to a texture atlas and then copying and coloring these characters during the actual render call using WebGL. That means any character that should be displayed needs to be added to the WebGLAtlas. The rendering output depends on the font family, size, weight, and style. As of now, we support arbitrary font family and size, but only italic and/or bold style.
I think the implementation of a custom font weight could work in a similar way like we did with the bold and italic rendering. So what we do in the WebGLAtlas is we map cell styles to a certain font style string that is applied before rendering. That means e.g. the combination Fira Code, 14px, bold, non-italic would map to 14px bold Fira Code, which is then applied as canvasContext.font before the character is rendered to the atlas. To support a customizable font weight, the configured font weight would need to be inserted if the bold flag is not set. Maybe even it would make sense then to calculate the actual weight of the bold font to be something like configuredFontWeight + 300 or similar, so that the bold characters do not differ too much or too little from regular text? This would probably require some normalization from keywords like bold, bolder, etc. to numeric weights beforehand.
Bottom line: We need to adapt the logic that creates the style string for canvasContext.font to include the configured weight by default and maybe even calculate the bold weight based on it to keep things correct in relation.
I hope this helps!