Skip to content

Commit

Permalink
Outputs a list of font and unicode chars
Browse files Browse the repository at this point in the history
  • Loading branch information
averyvery committed May 3, 2012
1 parent 701808f commit 0b6c729
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/hieroglyph/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ def initialize
@execute = true
parse_options
if @execute
Hieroglyph.make @options
font = Hieroglyph.make @options
Hieroglyph.header "#{@options[:name]} generated"
Hieroglyph.log "Saved to #{@options[:output_folder]}"
Hieroglyph.log "To create a full set of webfonts, upload to:"
Hieroglyph.log "http://www.fontsquirrel.com/fontface/generator"
Hieroglyph.log
Hieroglyph.log "If you're having trouble uploading SVGs, try converting to a TTF first using http://www.freefontconverter.com"
Hieroglyph.log
Hieroglyph.log "Font characters: #{font.characters.join(',')}"
Hieroglyph.log "Unicode characters: #{font.unicode_values.join(',')}"
Hieroglyph.log
end
end

Expand Down
7 changes: 6 additions & 1 deletion lib/hieroglyph/font.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module Hieroglyph

class Font

attr_accessor :characters, :unicode_values

def initialize(options)
@characters = []
@unicode_values = []
@contents = ""
@options = options
@output_path = File.join(@options[:output_folder], @options[:name] + ".svg")
Expand All @@ -17,6 +21,7 @@ def include(file)
end

def setup

Hieroglyph.header "Generating #{@options[:name]}"
Hieroglyph.delete @output_path
@character_sheet = Hieroglyph.imagemagick_installed? ? CharacterSheet.new(@options) : NoopSheet.new
Expand Down Expand Up @@ -44,7 +49,7 @@ def add(str)
def add_glyphs
Hieroglyph.log
Dir.glob(File.join(@options[:glyph_folder], "*.svg")).each do |file|
glyph = Glyph.new(file, @options[:glyph_folder])
glyph = Glyph.new(file, @options[:glyph_folder], self)
@character_sheet.add file
add glyph.to_node
end
Expand Down
17 changes: 15 additions & 2 deletions lib/hieroglyph/glyph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,29 @@ class Glyph

NAME_REGEX = /^..*?(?=(-|\.))/

UNICODE_REGEX = /(?<=^&#x).*(?=;)/

@@too_many_shapes = false

def initialize(file, source)
@name = file.gsub(source, "").gsub("/", "").match(NAME_REGEX)
def initialize(file, source, font)
@font = font
set_name(file, source)
@contents = Nokogiri::XML(File.new(file))
@path =
Hieroglyph.log "#{@name} -> reading...", 4
@path = parse_shapes
end

def set_name(file, source)
@name = file.gsub(source, "").gsub("/", "").match(NAME_REGEX).to_s
unicode = @name.match(UNICODE_REGEX)
if unicode
@font.unicode_values.push(unicode.to_s.upcase)
else
@font.characters.push(@name)
end
end

def parse_shapes
path = Savage::Path.new
count = 0
Expand Down

0 comments on commit 0b6c729

Please sign in to comment.