Giter Site home page Giter Site logo

Customizing Webfonts about ttyd HOT 14 CLOSED

tsl0922 avatar tsl0922 commented on May 16, 2024
Customizing Webfonts

from ttyd.

Comments (14)

athrunsun avatar athrunsun commented on May 16, 2024 11

@AGhost-7 @tsl0922
OK, I played with this around and I can be certain that we can't use CSS to control font in the terminal, since everything is now drawn into canvas elements in xterm.js.

However changing font attribute of canvas element on the fly doesn't have any effect either.

The correct way to do it is via the -t, --client-option option. I read source code to learn option keys then I started a terminal with:

ttyd -p 9090 -t fontSize=16 -t fontFamily="'IBM Plex Mono Medium', 'Noto Sans CJK SC'" fish

and it works perfectly.

from ttyd.

tsl0922 avatar tsl0922 commented on May 16, 2024

ttyd bundles a inlined index.html to it's executable file, no other external dependencies, You can modify and build your own index.html and rebuild ttyd if you want, see the instructions.

I'd like to add an option for using an external index.html or html root for this, but no deadline, I'm a little busy recently, PRs are welcomed 😄

from ttyd.

AGhost-7 avatar AGhost-7 commented on May 16, 2024

That's is what I did - I forked the project for now but I feel this is more of a temporary solution.

I'm afraid that C is not something that I'm very good at.

from ttyd.

foxundermoon avatar foxundermoon commented on May 16, 2024

+1

from ttyd.

tsl0922 avatar tsl0922 commented on May 16, 2024

Added the --index option for this (c9ffa8a).

Be aware that only external index.html file is supported, not html root.

from ttyd.

AGhost-7 avatar AGhost-7 commented on May 16, 2024

While I appreciate the feature which was added, its currently easier to just fork and use the gulp build in ttyd to customize the terminal instead of using the new --index option. If I use the --index option which was added I need to provide my own build script to generate the one html file.

What I am looking for is something closer to what you'd see in a regular terminal - more along the lines of being able to set terminal profiles.

from ttyd.

tsl0922 avatar tsl0922 commented on May 16, 2024

I don't think recompile index.html is needed if you just want to change something like font-family, since your can add your own css block to override any existed class.

from ttyd.

athrunsun avatar athrunsun commented on May 16, 2024

@tsl0922 Which element should we set font-family upon? Is it a canvas element?

from ttyd.

tsl0922 avatar tsl0922 commented on May 16, 2024

Great! This feature wasn't well documented, there is similar issues I've answered before (like #122, #134).

You can get the full list of options here:

https://xtermjs.org/docs/api/terminal/interfaces/iterminaloptions/

from ttyd.

Zibri avatar Zibri commented on May 16, 2024

hmm no, tls0922: you should put an option for background/foreground color without the need to write a css or modify the index.html

from ttyd.

Zibri avatar Zibri commented on May 16, 2024

IMHO hterm is way better anyways... I use it extensively and is very easy to manage...

from ttyd.

tsl0922 avatar tsl0922 commented on May 16, 2024

Hi, @Zibri you can custom the full color scheme with -t, --client-option. For example, to change the background/foreground:

ttyd -t 'theme={"foreground":"green","background":"cyan"}' bash

The code above only override the foreground/background color, you can get a full list of the predefined colors here.

from ttyd.

Zibri avatar Zibri commented on May 16, 2024
-t fontSize=16 -t fontFamily="'IBM Plex Mono Medium', 'Noto Sans CJK SC'"

I gave it another go today... and I still have a problem:
even though I used: --terminal-type xterm-256color
in linux I see the correct terminal type but there is no color.
why is that?
I tried both /bin/login both /bash -i -l

from ttyd.

metorm avatar metorm commented on May 16, 2024

Folks, I had built a forked version that has embedded nerd font. You can also replace your font.

https://github.com/metorm/ttyd-nerd-font

https://www.weiran.ink/oss/ttyd-with-nerd-font.html

from ttyd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.