Module: Fontisan::Ufo::Compile::Name
- Defined in:
- lib/fontisan/ufo/compile/name.rb
Overview
Builds the OpenType name table from UFO fontinfo data.
Writes Windows-Unicode (platform 3, encoding 1) name records
for the standard 6 name IDs (copyright, family, subfamily,
unique ID, full name, version, PostScript name).
BinData's Tables::Name structure doesn't make construction
from a record list easy (it has a custom after_read_hook and
a rest :string_storage); this builder produces the bytes
directly so we don't fight the BinData shape.
Constant Summary collapse
- PLATFORM_WINDOWS_UNICODE =
3- ENCODING_WINDOWS_UNICODE_BMP =
1- LANGUAGE_WINDOWS_ENGLISH_US =
0x0409
Class Method Summary collapse
-
.build(font, **_opts) ⇒ String
The name table bytes.
- .default_records(font) ⇒ Array<Hash{name_id: Integer, value: String}>
Class Method Details
.build(font, **_opts) ⇒ String
Returns the name table bytes.
23 24 25 26 |
# File 'lib/fontisan/ufo/compile/name.rb', line 23 def self.build(font, **_opts) records = default_records(font) format0_bytes(records) end |
.default_records(font) ⇒ Array<Hash{name_id: Integer, value: String}>
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fontisan/ufo/compile/name.rb', line 30 def self.default_records(font) family = font.info.family_name || "Untitled" subfamily = font.info.style_name || "Regular" ps_name = font.info.postscript_font_name || "#{family}-#{subfamily}" full_name = font.info.postscript_full_name || "#{family} #{subfamily}".strip major = font.info.version_major || 0 minor = font.info.version_minor || 0 version_str = "Version #{major}.#{minor}" unique_id = "#{family}-#{subfamily};#{version_str}" copyright = font.info.copyright || "" [ { name_id: 0, value: copyright }, # copyright { name_id: 1, value: family }, # family { name_id: 2, value: subfamily }, # subfamily { name_id: 3, value: unique_id }, # unique ID { name_id: 4, value: full_name }, # full name { name_id: 5, value: version_str }, # version { name_id: 6, value: ps_name }, # PostScript name ] end |