Module: Fontisan::Constants
- Defined in:
- lib/fontisan/constants.rb
Overview
Constants module containing immutable constant definitions for font file operations.
This module defines all magic numbers, version identifiers, and file format constants used throughout the fontisan gem. These values are based on the TrueType Collection, TrueType Font, and OpenType Font specifications.
Constant Summary collapse
- TTC_TAG =
TrueType Collection file signature tag. All valid TTC files must begin with this 4-byte tag.
"ttcf"- TTC_VERSION_1 =
TrueType Collection Version 1.0 identifier. Represents the original TTC format version.
0x00010000- TTC_VERSION_2 =
TrueType Collection Version 2.0 identifier. Represents the extended TTC format with digital signature support.
0x00020000- SFNT_VERSION_TRUETYPE =
SFNT version for TrueType fonts
0x00010000- SFNT_VERSION_OTTO =
SFNT version for OpenType fonts with CFF outlines (‘OTTO’)
0x4F54544F- HEAD_TAG =
Head table tag identifier. The ‘head’ table contains global font header information including the checksum adjustment field.
"head"- HHEA_TAG =
Hhea table tag identifier (Horizontal Header)
"hhea"- HMTX_TAG =
Hmtx table tag identifier (Horizontal Metrics)
"hmtx"- MAXP_TAG =
Maxp table tag identifier (Maximum Profile)
"maxp"- NAME_TAG =
Name table tag identifier
"name"- OS2_TAG =
OS/2 table tag identifier
"OS/2"- POST_TAG =
Post table tag identifier
"post"- CMAP_TAG =
Cmap table tag identifier
"cmap"- GLYF_TAG =
Glyf table tag identifier (TrueType glyph data)
"glyf"- LOCA_TAG =
Loca table tag identifier (TrueType glyph index to location)
"loca"- CFF_TAG =
CFF table tag identifier (OpenType CFF glyph data)
"CFF "- GSUB_TAG =
GSUB table tag identifier (Glyph Substitution)
"GSUB"- GPOS_TAG =
GPOS table tag identifier (Glyph Positioning)
"GPOS"- FVAR_TAG =
Fvar table tag identifier (Font Variations)
"fvar"- GVAR_TAG =
Gvar table tag identifier (Glyph Variations for TrueType)
"gvar"- HVAR_TAG =
HVAR table tag identifier (Horizontal Metrics Variations)
"HVAR"- MVAR_TAG =
MVAR table tag identifier (Metrics Variations)
"MVAR"- VVAR_TAG =
VVAR table tag identifier (Vertical Metrics Variations)
"VVAR"- CVAR_TAG =
Cvar table tag identifier (CVT Variations)
"cvar"- CFF2_TAG =
CFF2 table tag identifier (CFF version 2 with variations)
"CFF2"- FPGM_TAG =
TrueType hinting tables Font Program table (TrueType bytecode executed once at font load)
"fpgm"- PREP_TAG =
Control Value Program table (TrueType bytecode for initialization)
"prep"- CVT_TAG =
Control Value Table (metrics used by TrueType hinting)
"cvt "- CHECKSUM_ADJUSTMENT_MAGIC =
Magic number used for font file checksum adjustment calculation. This constant is used in conjunction with the file checksum to compute the checksumAdjustment value stored in the ‘head’ table. Formula: checksumAdjustment = CHECKSUM_ADJUSTMENT_MAGIC - file_checksum
0xB1B0AFBA- SUPPORTED_VERSIONS =
Supported TTC version numbers. An array of valid version identifiers for TrueType Collection files.
[TTC_VERSION_1, TTC_VERSION_2].freeze
- TABLE_ALIGNMENT =
Table data alignment boundary in bytes. All table data in TTF files must be aligned to 4-byte boundaries, with padding added as necessary.
4- STRING_POOL =
Common font subfamily names for string interning
These strings are frozen and reused to reduce memory allocations when parsing fonts with common subfamily names.
{ "Regular" => "Regular", "Bold" => "Bold", "Italic" => "Italic", "Bold Italic" => "Bold Italic", "BoldItalic" => "BoldItalic", "Light" => "Light", "Medium" => "Medium", "Semibold" => "Semibold", "SemiBold" => "SemiBold", "Black" => "Black", "Thin" => "Thin", "ExtraLight" => "ExtraLight", "Extra Light" => "Extra Light", "ExtraBold" => "ExtraBold", "Extra Bold" => "Extra Bold", "Heavy" => "Heavy", "Book" => "Book", "Roman" => "Roman", "Normal" => "Normal", "Oblique" => "Oblique", "Light Italic" => "Light Italic", "Medium Italic" => "Medium Italic", "Semibold Italic" => "Semibold Italic", "Bold Oblique" => "Bold Oblique", }.freeze
Class Method Summary collapse
-
.intern_string(str) ⇒ String
Intern a string using the string pool.
Class Method Details
.intern_string(str) ⇒ String
Intern a string using the string pool
If the string is in the pool, returns the pooled instance. Otherwise, freezes and returns the original string.
153 154 155 |
# File 'lib/fontisan/constants.rb', line 153 def self.intern_string(str) STRING_POOL[str] || str.freeze end |