-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom fonts #1374
Comments
You can do this with a Cloudflare app in front of your sub domain for code. Works pretty well. Was not able to find a way to do it via reverse proxy/etc. |
I would agree it should be a first class feature as fonts are a big part of editor customization and development. |
Will make this a priority. Agreed it's a big one. |
Thank you, it would really help at lot of people. |
This would be an amazing feature so I can finally include a powerline font that would go great with Oh My Zsh. |
@Just-Insane you say this is possible with cloudflare? where and how? |
Under the Apps section for your domain in Cloudflare, you should find an app called "Add CSS" developed by Cloudflare Labs. In the settings for this app, you select your subdomain that code-server is running on, and then enter the CSS: @font-face {
font-family: 'Fira Code';
src: url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff2/FiraCode-Light.woff2') format('woff2'),
url("https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff/FiraCode-Light.woff") format("woff");
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: 'Fira Code';
src: url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff2/FiraCode-Regular.woff2') format('woff2'),
url("https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff/FiraCode-Regular.woff") format("woff");
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: 'Fira Code';
src: url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff2/FiraCode-Medium.woff2') format('woff2'),
url("https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff/FiraCode-Medium.woff") format("woff");
font-weight: 500;
font-style: normal;
}
@font-face {
font-family: 'Fira Code';
src: url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff2/FiraCode-Bold.woff2') format('woff2'),
url("https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff/FiraCode-Bold.woff") format("woff");
font-weight: 700;
font-style: normal;
}
@font-face {
font-family: 'Fira Code VF';
src: url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff2/FiraCode-VF.woff2') format('woff2-variations'),
url('https://cdn.jsdelivr.net/gh/tonsky/FiraCode@2/distr/woff/FiraCode-VF.woff') format('woff-variations');
/* font-weight requires a range: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide#Using_a_variable_font_font-face_changes */
font-weight: 300 700;
font-style: normal;
} I don't exactly remember where I found this from (CDN URL in the CSS), but the overall CSS file is available on github: https://github.com/tonsky/FiraCode/blob/master/distr/fira_code.css |
neat, is it possible to make this an extension? to load a font off the internet? |
@Just-Insane very cool. Great workaround for now! |
There is probably a way you can intercept the pages using nginx/Apache as a reverse proxy, but I wasn’t able to get it working in the time I had. |
@Just-Insane does this enable font ligatures? like converting => to the special char? |
That is correct, it does the same as if you installed Fira Code for VS Code on your desktop.
On Mar 13, 2020, at 12:09 PM, Merith <[email protected]> wrote:
@Just-Insane<https://github.com/Just-Insane> does this enable font ligatures? like converting => to the special char?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1374 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADZKZDFECEUIBM7UKS62T53RHJLE5ANCNFSM4K4XF2LQ>.
|
For me using FiraCode just works. I am using macOS and I've added FiraCode to the OS. Probably if you register the font with other OSes it will work as well. |
Might have been added to vscode-web. cc @code-asher |
Installing the font should always work but I think this feature request is for using a webfont which I don't believe is supported yet. |
Yes, this is for the web server telling the client to use a specific font (usually CSS). Installing a font on the OS of each system you may want to use is not always possible. |
well installing the font assumes you are on a computer where you are able to do so. Windows: requires admin+reboot to properly install font, and even then custom fonts may be disabled by an admin at a workplace EDIT: just realized this ties in with
|
Installing fonts on macOS requires users to open the font file they want to install then click the The ability to load any font (without it installed on the user’s machine) would make it possible to bundle the font(s) directly into a package. Example would be a Docker image; all my code-server containers are in remote machines. |
honestly, making it so it loads custom font files from |
What I noticed on MacOS and iPadOS is that even if you install custom fonts, Safari doesn't use them. Though somehow Firefox manages to display them. So it's an issue with Safari as far as I can tell. To overcome this, it would be nice if we could inject @font-face{url(/font/dir/font)} etc. without client-side code injection extensions. (Extensions are not allowed on ipadOS.) |
@canbakiskan what could be done would be a simple addition to the code where it reads fonts and loads them in the CSS |
@canbakiskan wrote:
I’m having the same issue. I’ve tried to use the SourceCodePro+Powerline+Awesome+Regular.ttf fonts in iPad without success. I installed custom fonts in iPad but seems the Safari, Firefox and Chrome don’t recognize the custom font even if Yes, it would be nice if we could inject Regards. |
For those of you who are still looking for a solution I've managed to solve this by using NGINX as a reverse proxy to serve the downloaded fonts from a custom directory injecting a custom css file. Now I'm able to use VS Code on my iPad Pro with the programming ligatures enabled. Here's my nginx config: server {
listen 8081;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
sub_filter
'</head>'
'<link rel="stylesheet" type="text/css" href="/ios-fonts/css/fonts.css">
</head>';
sub_filter_once on;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
location /ios-fonts {
autoindex on;
root /var/www/html;
}
} And then I have inside
And this is the content of @font-face {
font-family: 'Fira Code';
src: url('/ios-fonts/fonts/FiraCode-Regular.woff2') format('woff2'),
url("/ios-fonts/fonts/FiraCode-Regular.woff") format("woff");
font-weight: 400;
font-style: normal;
} The reason I don't have any references to my domain or certificates on the nginx config is because I manage all my certificates using Traefik, so here's what I do: [http.routers]
[http.routers.code-server]
entryPoints = ["https"]
rule = "Host(`vscode.mydomain.com`)"
service = "code-server"
middlewares = ["secureheaders"]
[http.routers.code-server.tls]
certresolver = "letsencrypt"
[http.services]
[http.services.code-server]
[http.services.code-server.loadBalancer]
[[http.services.code-server.loadBalancer.servers]]
url = "http://ip-of-code-server:8081" So yeah, although not ideal, kinda hacky and double proxied, that's the only solution I could find for now. |
Thanks @mateusrevoredo !! |
My solution is inserting css directly to |
I have created a Pacman Hook that automatically insert Fira Code Font to website for Arch Linux users using method from tuanpham-dev's comment. |
me too. The powerlevel10k just need to install on the server-device, and you just install the fonts on your own device to call the powerlevel10k on server. |
In 4.4.0, this doesn't seem to work, as vscode's iframe has a security policy that you cannot override. Any ideas? |
@Sharpz7 - I have updated the font patch for version 4.4.0. If you don't find any solution, try mime. https://github.com/tuanpham-dev/code-server-font-patch |
Yeah this works. Thank you! |
How’d you get this working on the iPad? |
@dylanspag before you want to change the fonts of code-sever,you must change your fonts on web browser. Now you can use oh-my-zsh just like normal |
The Nginx method ain't working for me. Any help is appreciated. I am checking the index.html I am getting from the server and it is missing the
Edit: I haven't enabled SSL yet. |
Its really insane how slow this project is to implement something or solve bugs. I have been trying to complete this setup for 2 days and every issue I came across is still unresolved even though they are so trivial. Imagine having to wait 2-3 years to get native custom font support. Even if the maintainers are busy, 3 years is just way too long. Jesus. |
@ThatAnonyG You are always welcome to contribute.
There are several [working] ways to enable custom fonts. |
it would be nice if we could have a wiki page or something explaining the methods that are currently working. |
Feel free to raise a PR and add it to the docs! |
I think that we have to find a way to hammer out the different methods and turn them into Wiki pages as suggested. |
@ThatAnonyG The issue might be caused by the If code-server sends a compressed response, Nginx will ignore it. Try setting the Accept-Encoding header to an empty string ( |
None of the above works... |
@J4gQBqqR #1374 (comment) works just fine. |
Sorry, it does not work:
The code server that I use is the latest build installed by yay in Arch Linux. As you can see, this file does not exist. |
I successfully use https://github.com/b-data/jupyterlab-r-docker-stack/blob/main/base/latest.Dockerfile#L210-L215. Check out https://demo.jupyter.b-data.ch. Login with GitHub account.
@J4gQBqqR File location may change over time, so you have to adapt your script. |
For anyone looking for a solution using Caddy reverse proxy on macOS (as I happen too), here you go! In Caddyfile: your.domain.name {
handle_path /my_extras/* {
root * /Users/yourusername/apps/code-server-extras
file_server
}
handle {
reverse_proxy 127.0.0.1:8080
}
} And then I had to locate the main CSS file which was in: and add something like That would include the necessary |
You know, this would be really handy to set up for accessibility reasons |
or atleast an varient to what @jaredcwhite did, where the applications CSS automatically loads an customizations folder |
Sorry for the late reply but the file I modified is |
@demyxco Does it work in Safari on iPad if so, how did you get it to work? For me it only works in other browsers. |
@simon-bueler seems to be broken in Safari. |
Hey Does anyone have any idea how to do it with the latest build? I am using docker-compose with image lscr.io/linuxserver/code-server:latest. |
If yoy are using a docker image,
Create a dockerfile.
```
FROM containerimage
RUN commands to apply the patches
```
And then use that new.Docker image built
FROM basically says use this image as a base for these changes
…On Tue, Sep 24, 2024, 12:29 PM Prateek Mohanty ***@***.***> wrote:
Hey
Does anyone have any idea how to do it with the latest build? I am using
docker-compose with image lscr.io/linuxserver/code-server:latest.
—
Reply to this email directly, view it on GitHub
<#1374 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACPQOXU3VCZETNFAC5OTI4TZYG4QTAVCNFSM6AAAAABKIDKOKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGE4DKOBZGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I have tried to do something like this code-server:
container_name: code-server
image: lscr.io/linuxserver/code-server:latest
restart: unless-stopped
environment:
- PUID=${CODE_SERVER_PUID}
- PGID=${CODE_SERVER_PGID}
- TZ=${CODE_SERVER_TZ}
- SUDO_PASSWORD=${CODE_SERVER_SUDO_PASSWORD}
- PROXY_DOMAIN=${CODE_SERVER_PROXY_DOMAIN}
- DEFAULT_WORKSPACE=/workspace
- DOCKER_MODS=linuxserver/mods:code-server-zsh|linuxserver/mods:code-server-nvm|linuxserver/mods:universal-package-install
- INSTALL_PACKAGES=fontconfig
volumes:
- ./config/code-server/config:/config
- /home/strangenoob/workspace:/workspace
- ./fonts:/usr/share/fonts/custom
- ./custom/script.sh:/custom-cont-init.d:ro
env_file: .env
networks:
- proxy
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:8443/" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
labels:
- traefik.enable=true
- traefik.http.routers.code-server.rule=Host(`code-space.example.com`)
- traefik.http.routers.code-server.entrypoints=https
- traefik.http.routers.code-server.tls.certresolver=cloudflare
- traefik.http.services.code-server.loadbalancer.server.port=8443
- traefik.http.routers.code-server.middlewares=authentik@docker`
With script file is like #!/bin/sh
set -e
# Update font cache
fc-cache -f -v /usr/share/fonts/custom I have changed the settings but it didn't work. {
"editor.fontWeight": "normal",
"editor.fontLigatures": true,
"terminal.integrated.fontFamily": "'MesloLGS NF'",
"terminal.integrated.fontSize": 16,
"editor.fontFamily": "'FiraCode Nerd Font'",
} But if I tried to access the list of font installed. Its showing FiraCode ➜ workspace fc-list
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/custom/MesloLGS NF Bold Italic.ttf: MesloLGS NF:style=Bold Italic
/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf: DejaVu Sans Mono:style=Book
/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/custom/FiraCode-Retina.ttf: Fira Code,Fira Code Retina:style=Retina,Regular
/usr/share/fonts/custom/FiraCodeNerdFont-Regular.ttf: FiraCode Nerd Font:style=Regular
/usr/share/fonts/custom/FiraCodeNerdFont-Bold.ttf: FiraCode Nerd Font:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Oblique.ttf: DejaVu Sans Mono:style=Oblique
/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-BoldOblique.ttf: DejaVu Sans Mono:style=Bold Oblique
/usr/share/fonts/custom/FiraCode-Bold.ttf: Fira Code:style=Bold
/usr/share/fonts/custom/FiraCodeNerdFontPropo-Retina.ttf: FiraCode Nerd Font Propo,FiraCode Nerd Font Propo Ret:style=Retina,Regular
/usr/share/fonts/custom/FiraCode-Light.ttf: Fira Code,Fira Code Light:style=Light,Regular
/usr/share/fonts/custom/FiraCode-SemiBold.ttf: Fira Code,Fira Code SemiBold:style=SemiBold,Regular
/usr/share/fonts/custom/FiraCodeNerdFontPropo-Bold.ttf: FiraCode Nerd Font Propo:style=Bold
/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf: DejaVu Sans Mono:style=Bold
/usr/share/fonts/custom/MesloLGS NF Regular.ttf: MesloLGS NF:style=Regular
/usr/share/fonts/custom/FiraCodeNerdFontPropo-SemiBold.ttf: FiraCode Nerd Font Propo,FiraCode Nerd Font Propo SemBd:style=SemiBold,Regular
/usr/share/fonts/custom/FiraCodeNerdFontPropo-Light.ttf: FiraCode Nerd Font Propo,FiraCode Nerd Font Propo Light:style=Light,Regular
/usr/share/fonts/custom/FiraCodeNerdFont-SemiBold.ttf: FiraCode Nerd Font,FiraCode Nerd Font SemBd:style=SemiBold,Regular
/usr/share/fonts/custom/FiraCodeNerdFont-Light.ttf: FiraCode Nerd Font,FiraCode Nerd Font Light:style=Light,Regular
/usr/share/fonts/custom/FiraCodeNerdFont-Retina.ttf: FiraCode Nerd Font,FiraCode Nerd Font Ret:style=Retina,Regular
/usr/share/fonts/custom/FiraCode-Regular.ttf: Fira Code:style=Regular
/usr/share/fonts/custom/FiraCode-Medium.ttf: Fira Code,Fira Code Medium:style=Medium,Regular
/usr/share/fonts/custom/FiraCodeNerdFontPropo-Medium.ttf: FiraCode Nerd Font Propo,FiraCode Nerd Font Propo Med:style=Medium,Regular
/usr/share/fonts/custom/MesloLGS NF Bold.ttf: MesloLGS NF:style=Bold
/usr/share/fonts/custom/MesloLGS NF Italic.ttf: MesloLGS NF:style=Italic
/usr/share/fonts/custom/FiraCodeNerdFontPropo-Regular.ttf: FiraCode Nerd Font Propo:style=Regular
/usr/share/fonts/custom/FiraCodeNerdFont-Medium.ttf: FiraCode Nerd Font,FiraCode Nerd Font Med:style=Medium,Regular
/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf: DejaVu Serif:style=Book |
Perhaps it would be a good idea to provide a link to this issue in the FAQ section of the documentation? |
Feature Request
I would like the ability to have the ability to have the font I use for all my development FireCode to be included so its pushed to the client.
I'm not really a star when it comes to CSS, but maybe this would be possible with something like a
@font-face
which would push the font to the client. Then when you configure the font in Code, because its pushed to the client you can have the FireCode font and ligatures without installing the font on the client.I would also accept solutions from anyone, how to hack some files to get this working.
Hopefully I'm not the only one using this font.
With Kind Regards,
Gert-Jan Timmer
The text was updated successfully, but these errors were encountered: