### TTY::Font Available Fonts Reference Source: https://context7.com/piotrmurach/tty-font/llms.txt Provides examples of various available fonts in TTY::Font, including 'standard', 'doom', 'starwars', '3d', 'block', and 'straight'. Shows the rendered output for each font. ```ruby require 'tty-font' # Standard font - Clean, readable (height: 6 lines) puts TTY::Font.new(:standard).write("ABC") # _ ____ ____ # / \ | __ ) / ___| # / _ \ | _ \ | | # / ___ \ | |_) | | |___ # /_/ \_\ |____/ \____| # Doom font - Bold, game-inspired (height: 8 lines) puts TTY::Font.new(:doom).write("ABC") # ___ ______ _____ # / _ \ | ___ \/ __ \ # / /_\ \| |_/ /| / \/ # | _ || ___ \| | # | | | || |_/ /| \__/\ # \_| |_/\____/ \____/ # Star Wars font - Iconic movie style (height: 6 lines) puts TTY::Font.new(:starwars).write("ABC") # ___ .______ ______ # / \ | _ \ / | # / ^ \ | |_) | | ,----' # / /_ \ | _ < | | # / _____ \ | |_) | | `----. # /__/ \__\ |______/ \______| # 3D font - Dimensional effect (height: 6-8 lines) puts TTY::Font.new(:3d).write("ABC") # ______ ____ ____ # /\ _ \/\ _`\ /\ _`\ # \ \ \_\ \ \ \_\ \ \ \/\_\ # \ \ __ \ \ _ <'\ \ \/_/_ # \ \ \/\ \ \ \_\ \ \ \_\ \ # \ \_\ \_\ \____/ \ \____/ # \/_/\/_/\___/ \___/ # Block font - Solid, heavy (height: 7 lines) puts TTY::Font.new(:block).write("ABC") # _|_| _|_|_| _|_|_| # _| _| _| _| _| # _|_|_|_| _|_|_| _| # _| _| _| _| _| # _| _| _|_|_| _|_|_| # Straight font - Minimal, compact (height: 3-4 lines) puts TTY::Font.new(:straight).write("ABC") # __ __ # /\ |__)/ # /--\|__)\__ ``` -------------------------------- ### Install TTY::Font Gem Source: https://github.com/piotrmurach/tty-font/blob/master/README.md This snippet shows how to add the TTY::Font gem to your project's Gemfile and install it using Bundler, or how to install it directly using the gem command. ```ruby gem 'tty-font' # Then execute: # $ bundle # Or install yourself as: # $ gem install tty-font ``` -------------------------------- ### Render Text as ASCII Art with TTY::Font Source: https://context7.com/piotrmurach/tty-font/llms.txt Shows how to use the `#write` method to convert strings into multi-line ASCII art. This method supports various characters and allows overriding letter spacing. Examples include rendering basic text, numbers, and text with spaces. ```ruby require 'tty-font' # Basic text rendering with standard font font = TTY::Font.new(:standard) puts font.write("Hello") # Output: # _ _ _ _ # | | | | ___ | | | | ___ # | |_| | / _ \ | | | | / _ \ # | _ | | __/ | | | | | (_) | # |_| |_| \___| |_| |_| \___/ # Rendering with doom font doom = TTY::Font.new(:doom) puts doom.write("DOOM") # Output: # ______ _____ _____ ___ ___ # | _ \| _ || _ || \/ | # | | | || | | || | | || . . | # | | | || | | || | | || |\/| | # | |/ / \ \_/ /\ \_/ /| | | | # |___/ \___/ \___/ \_| |_/ # Rendering numbers font = TTY::Font.new(:standard) puts font.write("12345") # Output: # _ ____ _____ _ _ ____ # / | |___ \ |___ / | || | | ___| # | | __) | |_ \ | || |_ |___ \ # | | / __/ ___) | |__ _| ___) | # |_| |_____| |____/ |_| |____/ # Rendering with custom letter spacing font = TTY::Font.new(:doom) puts font.write("DOOM", letter_spacing: 4) # Output: # ______ _____ _____ ___ ___ # | _ \ | _ | | _ | | \/ | # | | | | | | | | | | | | | . . | # | | | | | | | | | | | | | |\/| | # | |/ / \ \_/ / \ \_/ / | | | | # |___/ \___/ \___/ \_| |_/ # Rendering with spaces in text font = TTY::Font.new(:standard) puts font.write("a b c") # Output: # _ # __ _ | |__ ___ # / _` | | '_ \ / __| # | (_| | | |_) | | (__ # \__,_| |_.__/ \___| # Rendering special characters font = TTY::Font.new(:standard) puts font.write("*+-.") # Output: # # __\/\__ _ # \ / _| |_ _ # /_ _\ |_ _| _ (_) # \/ |_| ( ) # |/ ``` -------------------------------- ### Display TTY::Font Instance Information Source: https://context7.com/piotrmurach/tty-font/llms.txt Explains how to use the `#inspect` method (aliased as `#to_s`) to get a string representation of a TTY::Font instance. This output includes the font's name, letter spacing, and character height, useful for debugging. ```ruby require 'tty-font' font = TTY::Font.new(:doom) puts font.inspect # => # # Using to_s (alias for inspect) puts font.to_s # => # # Checking different fonts standard = TTY::Font.new(:standard) puts standard.inspect # => # starwars = TTY::Font.new(:starwars) puts starwars.inspect # => # ``` -------------------------------- ### Initialize and Write Text with TTY::Font Source: https://github.com/piotrmurach/tty-font/blob/master/README.md Demonstrates how to initialize a TTY::Font object with a chosen font (e.g., :doom) and then use the 'write' method to render text in that font to the console. ```ruby font = TTY::Font.new(:doom) puts font.write("DOOM") ``` -------------------------------- ### Initialize TTY::Font Instance Source: https://context7.com/piotrmurach/tty-font/llms.txt Demonstrates how to create a new TTY::Font instance. You can specify a font style like :doom or :starwars, or use the default :standard font. Custom letter spacing can also be set during initialization. ```ruby require 'tty-font' # Initialize with default 'standard' font font = TTY::Font.new # => # # Initialize with a specific font doom_font = TTY::Font.new(:doom) # => # # Initialize with custom letter spacing spaced_font = TTY::Font.new(:standard, letter_spacing: 2) # => # # Available fonts: :standard, :doom, :starwars, :3d, :block, :straight starwars_font = TTY::Font.new(:starwars) block_font = TTY::Font.new(:block) font_3d = TTY::Font.new(:3d) straight_font = TTY::Font.new(:straight) ``` -------------------------------- ### Basic Banner Creation with TTY::Font Source: https://context7.com/piotrmurach/tty-font/llms.txt Demonstrates how to create banners with different fonts and apply colors using the TTY::Font and Pastel gems. Initializes a font, writes text, and colors the output. ```ruby require 'tty-font' require 'pastel' pastel = Pastel.new # Yellow DOOM banner font = TTY::Font.new(:doom) puts pastel.yellow(font.write("DOOM")) # Red Star Wars style banner font = TTY::Font.new(:starwars) puts pastel.red(font.write("STAR WARS")) # Green standard banner font = TTY::Font.new(:standard) puts pastel.green(font.write("SUCCESS")) # Bold cyan banner font = TTY::Font.new(:block) puts pastel.cyan.bold(font.write("HELLO")) # Multi-color effect (line by line) font = TTY::Font.new(:doom) output = font.write("RUBY") colors = [:red, :yellow, :green, :cyan, :blue, :magenta] output.lines.each_with_index do |line, i| puts pastel.decorate(line, colors[i % colors.length]) end ``` -------------------------------- ### Error Handling for TTY::Font Source: https://context7.com/piotrmurach/tty-font/llms.txt Shows how to handle potential `ArgumentError` exceptions when using TTY::Font, such as for unknown fonts or unsupported characters. Includes a safe rendering function with fallbacks. ```ruby require 'tty-font' # Handling unknown font begin font = TTY::Font.new(:unknown_font) rescue ArgumentError => e puts "Error: #{e.message}" # => Error: Font 'unknown_font.yml' not found end # Handling unsupported characters begin font = TTY::Font.new(:standard) font.write("Hello みる") rescue ArgumentError => e puts "Error: #{e.message}" # => Error: Font standard doesn't support 'み' character end # Safe rendering with fallback def safe_render(text, font_name = :standard) font = TTY::Font.new(font_name) font.write(text) rescue ArgumentError => e "Could not render: #{e.message}" end puts safe_render("Hello World") # Works puts safe_render("Test", :invalid) # Returns error message ``` -------------------------------- ### Integrate TTY::Font with Pastel for Colored Output Source: https://context7.com/piotrmurach/tty-font/llms.txt Demonstrates how to combine TTY::Font with the Pastel gem to add color to ASCII art. By wrapping the output of `font.write` with Pastel color methods, developers can create vibrant, colorful terminal banners. ```ruby require 'tty-font' require 'pastel' pastel = Pastel.new # Example usage (assuming you have a font instance and text) # font = TTY::Font.new(:standard) # ascii_art = font.write("Color") # puts pastel.red(ascii_art) ``` -------------------------------- ### Colorize TTY::Font Output with Pastel Source: https://github.com/piotrmurach/tty-font/blob/master/README.md Illustrates how to combine TTY::Font with the Pastel gem to add color to the stylized text output in the terminal. ```ruby require 'pastel' pastel = Pastel.new font = TTY::Font.new(:doom) puts pastel.yellow(font.write("DOOM")) ``` -------------------------------- ### Adjust Letter Spacing with TTY::Font Source: https://github.com/piotrmurach/tty-font/blob/master/README.md Shows how to use the 'letter_spacing' option when calling the 'write' method to control the spacing between characters in the rendered text. ```ruby font = TTY::Font.new(:doom) puts font.write("DOOM", letter_spacing: 4) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.