Skip to content

Commit

Permalink
Fix kerning of default artii font rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
knaveofdiamonds committed May 9, 2012
1 parent e27b45e commit efe3173
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/pompom.rb
Expand Up @@ -44,7 +44,7 @@ class View

def initialize(screen)
@screen = screen
@asciifier = Artii::Base.new
@asciifier = Asciifier.new
end

def run(&block)
Expand All @@ -62,6 +62,20 @@ def format_for_screen(time)
end
end

class Asciifier
def initialize
@asciifier = Artii::Base.new
end

def asciify(text)
result = @asciifier.asciify(text).split("\n")
# Fix kerning for when 2nd character of minutes is a 4. This fix
# should really be moved back upstream to the figlet font.
result[3].sub!(/_\| /, '_|')
result.join("\n")
end
end

class NCursesScreen
include FFI::NCurses

Expand Down
18 changes: 18 additions & 0 deletions test/test_asciifier.rb
@@ -0,0 +1,18 @@
require 'helper'

describe Pompom::Asciifier do
before do
@asciifier = Pompom::Asciifier.new
end

# i.e. fix line 4:
# ___ _ _ __ ___
# |__ \| || | __ |/ _ \
# ) | || |__) | | | |
# / /|__ _| | | | | |
# / /_ | | _| | |_| |
# |____| |_|(_)_|\___/
it "fixes the problem with figlet font kerning" do
@asciifier.asciify("24:10").must_equal [" ___ _ _ __ ___ ", " |__ \\| || | __ |/ _ \\ ", " ) | || |__) | | | |", " / /|__ _|| | | | |", " / /_ | | _| | |_| |", " |____| |_|(_)_|\\___/ ", " ", " "].join("\n")
end
end

0 comments on commit efe3173

Please sign in to comment.