Class: Fontisan::Commands::GlyphsCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Fontisan::Commands::GlyphsCommand
- Defined in:
- lib/fontisan/commands/glyphs_command.rb
Overview
Command to list glyph names from a font file
Retrieves glyph names from the post table. Different post table versions provide different levels of glyph name information:
-
Version 1.0: Standard 258 Mac glyph names
-
Version 2.0: Custom glyph names
-
Version 3.0+: No glyph names
Instance Method Summary collapse
-
#run ⇒ Models::GlyphInfo
Execute the command to retrieve glyph names.
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from Fontisan::Commands::BaseCommand
Instance Method Details
#run ⇒ Models::GlyphInfo
Execute the command to retrieve glyph names
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fontisan/commands/glyphs_command.rb', line 21 def run glyph_info = Models::GlyphInfo.new # Try to get glyph names from post table first if font.has_table?(Constants::POST_TAG) post_table = font.table(Constants::POST_TAG) names = post_table.glyph_names if names&.any? glyph_info.glyph_names = names glyph_info.glyph_count = names.length glyph_info.source = "post_#{post_table.version}" return glyph_info end end # Future: Try CFF table if no post table or no names # if font.has_table?('CFF ') # # Get names from CFF # end # No glyph name information available glyph_info.glyph_names = [] glyph_info.glyph_count = 0 glyph_info.source = "none" glyph_info end |