The Victor Mono font family supplies distinct oblique and italics font faces. I would like to use Italics for the comment.block.documentation scope, and Oblique for other comment scopes. However, the obvious settings.json section:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Documentation",
"scope": "comment.block.documentation",
"settings": { "fontStyle": "italic" }
},
{
"name": "Comment",
"scope": "comment",
"settings": { "fontStyle": "oblique" }
},
]
}
does not work, because the rendering engine seems to interpret "oblique" and "italics" as "whichever of oblique or italics is provided in the last font file to be loaded that provides either.
I adapted a previously published approach for supporting multiple fonts in VS Code, and then transformed the problem statement to that form. The solution uses two "font families": one named "Victor Mono Medium" and being the "real" font family, providing normal and italic styles and an inaccessible oblique style; and one named "Victor Mono Medium Oblique", providing normal and oblique styles only, and only used for the oblique style.
As a simplification, I chose to sacrifice the ability to use an underlined font style. This is acceptable for my use case, and simplifies the solution significantly. The approach is then:
fontStyle: "italic" where italics are desired, and fontStyle: "underline" where oblique is desired.@font-face that has oblique but not italic styles.fontStyle: "underline" to use the oblique font face, obliquely, and not underline.After installing "Enable Custom CSS and JS" and following its instructions to enable use of a custom CSS file, and copying the VictorMono-MediumOblique.otf font file to a chosen location, here's the relevant contents of my settings.json:
...
"editor.fontLigatures": true,
"editor.fontFamily": "'Victor Mono Medium'",
"vscode_custom_css.imports": ["file:///MYPATH/.vscode/style.css"],
"vscode_custom_css.policy": true,
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"name": "Documentation",
"scope": "comment.block.documentation",
"settings": { "fontStyle": "italic" }
},
{
"name": "Comment",
"scope": "comment",
"settings": { "fontStyle": "underline" }
},
]
},
...
and my style.css:
/* Replace underline with oblique */
@font-face {
font-family: 'Victor Mono Medium Oblique';
src: url('file:///MYPATH/VictorMono-MediumOblique.otf');
}
.mtku {
font-family: 'Victor Mono Medium Oblique';
font-style: oblique;
text-decoration: none;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With