juliawin icon indicating copy to clipboard operation
juliawin copied to clipboard

Add JuliaMono as default font in VSCode

Open heetbeet opened this issue 4 years ago • 10 comments

The idea is to download JuliaMono from: https://github.com/cormullion/juliamono/blob/master/juliamono-ttf.zip and add the .ttfs to packages\fonts.

Then before any VSCode launch, the following code can be adapted and run to ensure all fonts are temporary available to the system https://gist.github.com/Jaykul/d53a16ce5e7d50b13530acb4f98aaabd , for eg bin/activate-juliawin-fonts.ps1 with content:

add-type -name Session -namespace "" -member @"
[DllImport("gdi32.dll")]
public static extern int AddFontResource(string filePath);
"@

$null = foreach($font in Get-ChildItem -Path "$juliawin_packages\fonts" -Recurse -Include *.ttf, *.otg) {
    [Session]::AddFontResource($font.FullName)
}

On the VSCode side we should add JuliaMono in the font setting, (over here, https://github.com/heetbeet/juliawin/blob/main/userdata/.vscode/data/user-data/User/settings.json ), similarly to this guide https://dev.to/thegeoffstevens/vs-code-settings-you-should-customize-5e75 but replacing Fira with Juliamono:

"editor.fontFamily": "Fira Code"
"editor.fontLigatures": true

heetbeet avatar Mar 29 '21 07:03 heetbeet

Does it mean the Font will be added only for the session of VS Code? What happens if VS Code crashes? Or is it added for as long as the kernel (Windows Kernel) session is a live?

RoyiAvital avatar Mar 31 '21 08:03 RoyiAvital

This .ps1 script allows the fonts to be added to Windows's font cache without installing it. It is accessible by any program until the next reboot (for the duration of the current Windows Kernel).

Ideally I would have have wanted the font to only be active for the duration of the VSCode session and only accessible to VSCode. This, however, it not possible as far as I know.

heetbeet avatar Mar 31 '21 12:03 heetbeet

Hmm it seems like the font is added permanantly to the user's fonts. This is a bit rude and not ideal.

heetbeet avatar Jun 15 '21 21:06 heetbeet

Is the attachment a solution for this or the permanent addition?

RoyiAvital avatar Sep 28 '22 07:09 RoyiAvital

The attachment is a solution for portably adding the fonts to the current windows session. I'm still not sure if it's a good idea since every Windows app will reflect the fonts until the next reboot.

heetbeet avatar Sep 28 '22 14:09 heetbeet

Maybe have a documented option for Opt In?

RoyiAvital avatar Sep 28 '22 14:09 RoyiAvital

Yes, like maybe an env variable (that can now be set in startup.cmd). Like set JULIAWIN_JULIAMONO_FONTS=true

heetbeet avatar Sep 28 '22 21:09 heetbeet

Yep, that would be great. Once it is there, let me know, I will document it in the Wiki page.

RoyiAvital avatar Sep 29 '22 10:09 RoyiAvital

Any chance to have this in the 1.9.x version?

RoyiAvital avatar May 12 '23 18:05 RoyiAvital