Class: Fontist::FontFile

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/font_file.rb

Constant Summary collapse

PLATFORM_MACINTOSH =
1
PLATFORM_MICROSOFT =
3
ENCODING_MAC_ROMAN =
0
ENCODING_MS_UNICODE_BMP =
1
LANGUAGE_MAC_ENGLISH =
0
LANGUAGE_MS_ENGLISH_AMERICAN =
0x409

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ttfunk_file) ⇒ FontFile

Returns a new instance of FontFile.



49
50
51
# File 'lib/fontist/font_file.rb', line 49

def initialize(ttfunk_file)
  @file = ttfunk_file
end

Class Method Details

.from_collection_index(collection, index) ⇒ Object



25
26
27
# File 'lib/fontist/font_file.rb', line 25

def from_collection_index(collection, index)
  new(build_font_from_collection_index(collection, index))
end

.from_content(content) ⇒ Object



21
22
23
# File 'lib/fontist/font_file.rb', line 21

def from_content(content)
  new(build_font(content))
end

.from_path(path) ⇒ Object



15
16
17
18
19
# File 'lib/fontist/font_file.rb', line 15

def from_path(path)
  content = File.read(path, mode: "rb")

  from_content(content)
end

Instance Method Details

#familyObject



57
58
59
# File 'lib/fontist/font_file.rb', line 57

def family
  english_name(main_name.font_family)
end

#full_nameObject



53
54
55
# File 'lib/fontist/font_file.rb', line 53

def full_name
  english_name(main_name.font_name)
end

#preferred_familyObject



65
66
67
68
69
# File 'lib/fontist/font_file.rb', line 65

def preferred_family
  return if main_name.preferred_family.empty?

  english_name(main_name.preferred_family)
end

#preferred_subfamilyObject



71
72
73
74
75
# File 'lib/fontist/font_file.rb', line 71

def preferred_subfamily
  return if main_name.preferred_subfamily.empty?

  english_name(main_name.preferred_subfamily)
end

#subfamilyObject



61
62
63
# File 'lib/fontist/font_file.rb', line 61

def subfamily
  english_name(main_name.font_subfamily)
end