Bhushan Lodha
Bhushan Lodha

Reputation: 6862

Change Font dynamically in console

Is there a proper plugin or a class to change font size, font type and decoration within a common output console?

You can change terminal's font by going into preferences but that is not what I'm looking for here. I want to be able to change font dynamically from within code.

Is there anything in Ruby or some terminal commands to do so (I use Mac OS X).

Upvotes: 4

Views: 4182

Answers (4)

dcts
dcts

Reputation: 1639

If you are looking for a solution for the rails default webconsole (displayed inside a browser) I suggest to get a browserextension where you can add additional styling to a page and then just override the following classes:

.console-prompt-label,
.console-prompt-display, 
.console-message {
  font-size: 16px;
  line-height: 16px;
}

If you're using chrome you can use StyleBot. Then you would need to:

  1. Install Stylebot
  2. run rails server and open localhost inside your browser
  3. click on the stylebot extension logo (CSS) and click Open Stylebot...
  4. a sidenav should open, at the bottom left press the button Edit CSS
  5. add the CSS from above and save

that's it, no more small console ouput ever.

enter image description here

Upvotes: 0

azurewraith
azurewraith

Reputation: 388

The font/font size used in ANSI terminals are implementation specific, and ANSI color/style codes are the only way to provide decoration. Simplest way I've found to add color and style to console output is use the colorize gem.

gem install colorize

Examples:

puts "This is blue".colorize( :blue )
puts "This is light blue".colorize( :light_blue )
puts "This is also blue".colorize( :color => :blue )
puts "This is red on blue and underline".colorize( :red ).on_blue.underline
puts "This is blue text on red".blue.on_red.blink

Here is the colorize README.

Or if you'd like to get fancier and do some UI elements, you can use the rbcurse gem:

gem install rbcurse

Here are some rbcurse screenshots.

Upvotes: 3

Michael Slade
Michael Slade

Reputation: 13877

There is no way to dynamically change the font face or font size in standard terminals. They mostly only recognise the standard ANSI/VT escape codes, which only support colors and (some) style.

Upvotes: 1

Kit Ho
Kit Ho

Reputation: 26998

I suggest you can use fancy_irb modules, which can decorate your irb console. :)

gem install fancy_irb

Upvotes: 0

Related Questions