Closed Phroneris closed 1 year ago
You can specific custom css using the markdown.styles
setting (this setting is a list if paths to custom custom stylesheets that should be loaded into the preview). This should let you override styling defaults, such as the font
Yes we can use the setting, but it's only with inward relative paths, for local stylesheets.
https://github.com/Microsoft/vscode/issues/45260#issuecomment-371428889
Root cause: We now restrict the markdown preview to only loading resources inside the current workspace for security reasons.
...Oh, this is your comment. Thanks. Anyway, while I am very sorry to say, this inconvenience sucks. While it's one of the causes I opened this issue, I forgot to mention that.
And, even if some stylesheet is referenced effectively, another problem is that there is no way to override reserved font family keywords in CSS to emulate that browser fallback. I mean this doesn't have any effect:
@font-face {
font-family: sans-serif;
src: local("My favorite font name");
}
due to the CSS specification:
https://github.com/w3c/csswg-drafts/issues/4580
Of cause, workaround is to write .github-markdown-body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, "My favorite font name", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; }
thing, but it isn't very generic.
I'm already doing this via https, but........................ this inconvenience sucks.
And since this behavior also seems doubtful in terms of the goals of this extension, I made this issue.
FYI, the trigger for my noticing this problem is this terrible pixel font, MS Gothic, that VS Code uses by default for monospace Japanese characters in the preview.
Windows 10 64-bit Home 22H2, VS Code 1.80.2, in Japan/Japanese.
Description
I wish for
sans-serif
andmonospace
font family options and hope their values are inserted just before thesans-serif
's and themonospace
's of the CSS.Namely for now:
and maybe:
Pitch
The default fonts of operation systems and browsers are not always satisfactory for users, so most browsers have the ability to register the user's preferred font for the
serif
,sans-serif
, andmonospace
fallback.For example: I am a Japanese speaker, so I have my favorite Japanese font set differently than the default in Chrome. This allows me to read sources and previews with Japanese characters on GitHub, a latin-character-based website, with some comfort due to the fallback.
Now let's see https://github.com/mjbvz/vscode-github-markdown-preview-style/issues/105#issuecomment-1547988644
Okay, it makes sense that the fonts should not be freely configurable for the purpose of reproducing the display of GitHub. Then, since GitHub is a website that is displayed in a browser, shouldn't it be possible to reproduce the browser's font fallback as well?
Method
One possibility is to use
markdown.preview.fontFamily
as thesans-serif
andeditor.fontFamily
as themonospace
, but users may not always want to use those fonts for GitHub previews.So, it would be nice to create two new options for that font families, use the above values as fallback, and indicate that in the description of the options:
Of course, it would also be nice as a safer way to not have anything inserted when the option is left blank.
Thanks.