Module: Cooltrainer::DistorteD::Technology::TTFunk
- Included in:
- Molecule::Font, Molecule::Text
- Defined in:
- lib/distorted/modular_technology/ttfunk.rb
Instance Method Summary collapse
-
#font_copyright ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String copyright information of the font.
-
#font_description ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String font file description.
-
#font_name ⇒ Object
Returns the Family and Subfamily as one string suitable for libvips.
-
#font_spacing ⇒ Object
Returns a boolean for whether or not this font is monospaced.
-
#font_version ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String version + revision of the font.
- #to_ttfunk ⇒ Object
Instance Method Details
#font_copyright ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String copyright information of the font
44 45 46 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 44 def font_copyright g_markup_escape_text(to_ttfunk.name&.copyright&.first&.encode('UTF-8').to_s) end |
#font_description ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String font file description
39 40 41 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 39 def font_description g_markup_escape_text(to_ttfunk.name&.description&.first&.encode('UTF-8').to_s) end |
#font_name ⇒ Object
Returns the Family and Subfamily as one string suitable for libvips
29 30 31 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 29 def font_name "#{to_ttfunk.name.font_family.first.encode('UTF-8')} #{to_ttfunk.name.font_subfamily.first.encode('UTF-8')}" end |
#font_spacing ⇒ Object
Returns a boolean for whether or not this font is monospaced. true == monospace false == proportional
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 17 def font_spacing # Monospace fonts will (read: should) have the same width # for every glyph, so we can tell a monospace font by # checking if a deduplicated widths table has size == 1: # irb(main)> font.horizontal_metrics.widths.count # => 256 # irb(main)> font.horizontal_metrics.widths.uniq.compact.length # => 1 to_ttfunk.horizontal_metrics.widths.uniq.compact.length == 1 ? :monospace : :proportional end |
#font_version ⇒ Object
Returns the Pango-Markup-encoded UTF-8 String version + revision of the font
34 35 36 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 34 def font_version g_markup_escape_text(to_ttfunk.name&.version&.first&.encode('UTF-8').to_s) end |
#to_ttfunk ⇒ Object
8 9 10 11 12 |
# File 'lib/distorted/modular_technology/ttfunk.rb', line 8 def to_ttfunk # TODO: Check that src exists, because TTFunk won't and will just # give us an unusable object instead. @ttfunk_file ||= TTFunk::File.open(font_path) end |