fontisan 0.2.13 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +56 -196
  3. data/Gemfile +1 -1
  4. data/docs/.gitignore +17 -0
  5. data/docs/.vitepress/config.ts +317 -0
  6. data/docs/.vitepress/theme/components/ApiMethod.vue +127 -0
  7. data/docs/.vitepress/theme/components/Badge.vue +51 -0
  8. data/docs/.vitepress/theme/components/FeatureComparison.vue +87 -0
  9. data/docs/.vitepress/theme/components/HeroCodeBlock.vue +98 -0
  10. data/docs/.vitepress/theme/components/WithinHero.vue +30 -0
  11. data/docs/.vitepress/theme/index.ts +22 -0
  12. data/docs/.vitepress/theme/style.css +330 -0
  13. data/docs/api/conversion-options.md +141 -0
  14. data/docs/api/converters/curve-converter.md +34 -0
  15. data/docs/api/converters/hint-converter.md +34 -0
  16. data/docs/api/converters/outline-converter.md +27 -0
  17. data/docs/api/font-loader.md +111 -0
  18. data/docs/api/font-writer.md +103 -0
  19. data/docs/api/index.md +79 -0
  20. data/docs/api/models/glyph-accessor.md +43 -0
  21. data/docs/api/models/glyph.md +40 -0
  22. data/docs/api/models/table-analyzer.md +35 -0
  23. data/docs/api/sfnt-font.md +53 -0
  24. data/docs/api/type1-font.md +43 -0
  25. data/docs/api/validators/font-validator.md +31 -0
  26. data/docs/api/validators/helper.md +36 -0
  27. data/docs/api/validators/profile.md +39 -0
  28. data/docs/cli/convert.md +87 -0
  29. data/docs/cli/dump-table.md +110 -0
  30. data/docs/cli/export.md +176 -0
  31. data/docs/cli/features.md +124 -0
  32. data/docs/cli/glyphs.md +90 -0
  33. data/docs/cli/index.md +208 -0
  34. data/docs/cli/info.md +254 -0
  35. data/docs/cli/instance.md +122 -0
  36. data/docs/cli/ls.md +95 -0
  37. data/docs/cli/optical-size.md +94 -0
  38. data/docs/cli/pack.md +125 -0
  39. data/docs/cli/scripts.md +105 -0
  40. data/docs/cli/subset.md +39 -0
  41. data/docs/cli/tables.md +84 -0
  42. data/docs/cli/unicode.md +101 -0
  43. data/docs/cli/validate.md +48 -0
  44. data/docs/cli/variable.md +126 -0
  45. data/docs/cli/version.md +46 -0
  46. data/docs/guide/cli/convert.md +108 -0
  47. data/docs/guide/cli/export.md +138 -0
  48. data/docs/guide/cli/index.md +99 -0
  49. data/docs/guide/cli/info.md +144 -0
  50. data/docs/guide/cli/pack.md +155 -0
  51. data/docs/guide/cli/subset.md +118 -0
  52. data/docs/guide/cli/validate.md +139 -0
  53. data/docs/guide/color-fonts/bitmaps.md +177 -0
  54. data/docs/guide/color-fonts/colr-cpal.md +175 -0
  55. data/docs/guide/color-fonts/index.md +140 -0
  56. data/docs/guide/color-fonts/svg.md +154 -0
  57. data/docs/guide/color.md +51 -0
  58. data/docs/guide/comparisons/font-validator.md +222 -0
  59. data/docs/guide/comparisons/fonttools.md +200 -0
  60. data/docs/guide/comparisons/index.md +83 -0
  61. data/docs/guide/comparisons/lcdf-typetools.md +205 -0
  62. data/docs/guide/contributing.md +279 -0
  63. data/docs/guide/conversion/collections.md +251 -0
  64. data/docs/guide/conversion/curves.md +246 -0
  65. data/docs/guide/conversion/index.md +157 -0
  66. data/docs/guide/conversion/options.md +251 -0
  67. data/docs/guide/conversion/ttf-otf.md +184 -0
  68. data/docs/guide/conversion/type1.md +208 -0
  69. data/docs/guide/conversion/web.md +240 -0
  70. data/docs/guide/conversion.md +39 -0
  71. data/docs/guide/formats/collections.md +147 -0
  72. data/docs/guide/formats/dfont.md +99 -0
  73. data/docs/guide/formats/index.md +65 -0
  74. data/docs/guide/formats/otf.md +103 -0
  75. data/docs/guide/formats/svg.md +97 -0
  76. data/docs/guide/formats/ttf.md +105 -0
  77. data/docs/guide/formats/type1.md +118 -0
  78. data/docs/guide/formats/woff.md +115 -0
  79. data/docs/guide/hinting/autohint.md +141 -0
  80. data/docs/guide/hinting/conversion.md +161 -0
  81. data/docs/guide/hinting/index.md +86 -0
  82. data/docs/guide/hinting/postscript.md +149 -0
  83. data/docs/guide/hinting/truetype.md +135 -0
  84. data/docs/guide/hinting.md +44 -0
  85. data/docs/guide/index.md +152 -0
  86. data/docs/guide/installation.md +116 -0
  87. data/docs/guide/migrations/extract-ttc.md +549 -0
  88. data/docs/guide/migrations/font-validator.md +260 -0
  89. data/docs/guide/migrations/fonttools.md +208 -0
  90. data/docs/guide/migrations/index.md +64 -0
  91. data/docs/guide/migrations/otfinfo.md +197 -0
  92. data/docs/guide/quick-start.md +204 -0
  93. data/docs/guide/type1.md +58 -0
  94. data/docs/guide/universal-outline.md +151 -0
  95. data/docs/guide/validation/custom.md +195 -0
  96. data/docs/guide/validation/helpers.md +188 -0
  97. data/docs/guide/validation/index.md +132 -0
  98. data/docs/guide/validation/profiles.md +156 -0
  99. data/docs/guide/validation.md +47 -0
  100. data/docs/guide/variable-fonts/advanced.md +231 -0
  101. data/docs/guide/variable-fonts/axes.md +209 -0
  102. data/docs/guide/variable-fonts/conversion.md +197 -0
  103. data/docs/guide/variable-fonts/index.md +84 -0
  104. data/docs/guide/variable-fonts/instances.md +187 -0
  105. data/docs/guide/variable-fonts/named-instances.md +194 -0
  106. data/docs/guide/variable-fonts/static.md +168 -0
  107. data/docs/guide/variable.md +58 -0
  108. data/docs/guide/woff.md +59 -0
  109. data/docs/index.md +136 -0
  110. data/docs/lychee.toml +37 -0
  111. data/docs/package-lock.json +2560 -0
  112. data/docs/package.json +15 -0
  113. data/docs/public/apple-touch-icon.png +0 -0
  114. data/docs/public/favicon-96x96.png +0 -0
  115. data/docs/public/favicon.ico +0 -0
  116. data/docs/public/favicon.svg +1 -0
  117. data/docs/public/logo-full.svg +1 -0
  118. data/docs/public/logo.svg +1 -0
  119. data/docs/public/site.webmanifest +21 -0
  120. data/docs/public/web-app-manifest-192x192.png +0 -0
  121. data/docs/public/web-app-manifest-512x512.png +0 -0
  122. data/fontisan.gemspec +1 -1
  123. data/lib/fontisan/commands/features_command.rb +0 -1
  124. data/lib/fontisan/commands/info_command.rb +5 -5
  125. data/lib/fontisan/commands/scripts_command.rb +0 -1
  126. data/lib/fontisan/converters/format_converter.rb +2 -1
  127. data/lib/fontisan/converters/type1_converter.rb +65 -60
  128. data/lib/fontisan/hints/hint_converter.rb +2 -1
  129. data/lib/fontisan/loading_modes.rb +0 -2
  130. data/lib/fontisan/open_type_font.rb +0 -40
  131. data/lib/fontisan/sfnt_font.rb +41 -22
  132. data/lib/fontisan/tables/glyf/compound_glyph.rb +0 -1
  133. data/lib/fontisan/true_type_collection.rb +8 -8
  134. data/lib/fontisan/true_type_font.rb +1 -59
  135. data/lib/fontisan/type1/afm_parser.rb +2 -1
  136. data/lib/fontisan/type1/cff_to_type1_converter.rb +24 -19
  137. data/lib/fontisan/type1/private_dict.rb +28 -7
  138. data/lib/fontisan/type1/seac_expander.rb +22 -17
  139. data/lib/fontisan/variable/delta_applicator.rb +3 -3
  140. data/lib/fontisan/variation/optimizer.rb +0 -1
  141. data/lib/fontisan/version.rb +1 -1
  142. data/lib/fontisan/woff2_font.rb +2 -2
  143. data/lib/fontisan/woff_font.rb +3 -3
  144. data/lib/fontisan.rb +3 -2
  145. metadata +122 -4
@@ -0,0 +1,147 @@
1
+ ---
2
+ title: Font Collections
3
+ ---
4
+
5
+ # Font Collections (TTC/OTC)
6
+
7
+ Font collections pack multiple fonts into a single file with shared tables.
8
+
9
+ ## Overview
10
+
11
+ | Format | Description | Font Type |
12
+ |--------|-------------|-----------|
13
+ | TTC | TrueType Collection | TrueType fonts |
14
+ | OTC | OpenType Collection | CFF/OpenType fonts |
15
+
16
+ ## Benefits
17
+
18
+ - **Smaller total size** — Shared tables
19
+ - **Simpler distribution** — One file
20
+ - **Family organization** — Related fonts together
21
+
22
+ ## Shared Tables
23
+
24
+ Collections share common tables:
25
+
26
+ - `cmap` — Character mappings
27
+ - `loca` — Glyph locations
28
+ - `maxp` — Maximum profile
29
+ - `name` — Font names
30
+ - `post` — PostScript names
31
+
32
+ ## Listing Fonts
33
+
34
+ ### CLI
35
+
36
+ ```bash
37
+ fontisan ls family.ttc
38
+
39
+ # Collection: family.ttc
40
+ # Fonts: 4
41
+ #
42
+ # 0. Family Regular
43
+ # PostScript: Family-Regular
44
+ # Glyphs: 268, Tables: 14
45
+ #
46
+ # 1. Family Bold
47
+ # PostScript: Family-Bold
48
+ # Glyphs: 268, Tables: 14
49
+ ```
50
+
51
+ ### API
52
+
53
+ ```ruby
54
+ collection = Fontisan::FontLoader.load('family.ttc')
55
+
56
+ collection.each_with_index do |font, index|
57
+ puts "#{index}. #{font.family_name} #{font.style}"
58
+ end
59
+ ```
60
+
61
+ ## Extracting Fonts
62
+
63
+ ### CLI
64
+
65
+ ```bash
66
+ # Extract all fonts
67
+ fontisan unpack family.ttc --output-dir ./extracted
68
+
69
+ # Extract specific font
70
+ fontisan unpack family.ttc --index 0 --output regular.ttf
71
+
72
+ # Extract with conversion
73
+ fontisan unpack family.ttc --output-dir ./otf --format otf
74
+ ```
75
+
76
+ ### API
77
+
78
+ ```ruby
79
+ collection = Fontisan::FontLoader.load('family.ttc')
80
+
81
+ collection.each_with_index do |font, index|
82
+ output = "font-#{index}.ttf"
83
+ Fontisan::FontWriter.write(font, output)
84
+ end
85
+ ```
86
+
87
+ ## Creating Collections
88
+
89
+ ### CLI
90
+
91
+ ```bash
92
+ # Pack fonts into TTC
93
+ fontisan pack regular.ttf bold.ttf italic.ttf --output family.ttc
94
+
95
+ # Pack with deduplication
96
+ fontisan pack *.ttf --output family.ttc --deduplicate
97
+
98
+ # Pack as OTC
99
+ fontisan pack regular.otf bold.otf --output family.otc
100
+ ```
101
+
102
+ ### API
103
+
104
+ ```ruby
105
+ fonts = [
106
+ Fontisan::FontLoader.load('regular.ttf'),
107
+ Fontisan::FontLoader.load('bold.ttf'),
108
+ Fontisan::FontLoader.load('italic.ttf')
109
+ ]
110
+
111
+ Fontisan::CollectionWriter.pack(fonts, 'family.ttc')
112
+ ```
113
+
114
+ ## Table Deduplication
115
+
116
+ ```bash
117
+ # Deduplicate tables when packing
118
+ fontisan pack *.ttf --output family.ttc --deduplicate
119
+ ```
120
+
121
+ Benefits:
122
+ - Smaller file size
123
+ - Identical tables shared
124
+ - Optimized storage
125
+
126
+ ## Converting Collections
127
+
128
+ ### TTC to OTC
129
+
130
+ ```bash
131
+ fontisan convert family.ttc --to otc --output family.otc
132
+ ```
133
+
134
+ ### OTC to TTC
135
+
136
+ ```bash
137
+ fontisan convert family.otc --to ttc --output family.ttc
138
+ ```
139
+
140
+ ## Apple dfont
141
+
142
+ dfont supports mixed font types:
143
+
144
+ ```bash
145
+ # Convert TTC to dfont
146
+ fontisan convert family.ttc --to dfont --output family.dfont
147
+ ```
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: Apple dfont
3
+ ---
4
+
5
+ # Apple dfont
6
+
7
+ Apple Data Fork Font (dfont) is a legacy Mac OS X format.
8
+
9
+ ## Overview
10
+
11
+ - **Container**: Resource fork format in data fork
12
+ - **Font Types**: TrueType, OpenType, or mixed
13
+ - **Platform**: macOS specific
14
+
15
+ ## Structure
16
+
17
+ dfont uses resource fork structure:
18
+ - Resource map
19
+ - Resource data
20
+ - Multiple font resources
21
+
22
+ ## Loading
23
+
24
+ ```ruby
25
+ font = Fontisan::FontLoader.load('font.dfont')
26
+
27
+ # Access as collection
28
+ if font.respond_to?(:each)
29
+ font.each do |f|
30
+ puts "#{f.family_name} #{f.style}"
31
+ end
32
+ end
33
+ ```
34
+
35
+ ## Extracting
36
+
37
+ ### CLI
38
+
39
+ ```bash
40
+ # List fonts in dfont
41
+ fontisan ls font.dfont
42
+
43
+ # Extract all
44
+ fontisan unpack font.dfont --output-dir ./extracted
45
+ ```
46
+
47
+ ### API
48
+
49
+ ```ruby
50
+ dfont = Fontisan::FontLoader.load('font.dfont')
51
+
52
+ dfont.each_with_index do |font, index|
53
+ output = "font-#{index}.ttf"
54
+ Fontisan::FontWriter.write(font, output)
55
+ end
56
+ ```
57
+
58
+ ## Converting
59
+
60
+ ### dfont to TTF
61
+
62
+ ```bash
63
+ fontisan convert font.dfont --to ttf --output font.ttf
64
+ ```
65
+
66
+ ### dfont to OTF
67
+
68
+ ```bash
69
+ fontisan convert font.dfont --to otf --output font.otf
70
+ ```
71
+
72
+ ### To dfont
73
+
74
+ ```bash
75
+ # From TTC
76
+ fontisan convert family.ttc --to dfont --output family.dfont
77
+
78
+ # From individual fonts
79
+ fontisan pack regular.ttf bold.ttf --output family.dfont
80
+ ```
81
+
82
+ ## Limitations
83
+
84
+ - **macOS only** — Not cross-platform
85
+ - **Legacy format** — Modern formats preferred
86
+ - **Limited support** — Some tools don't read dfont
87
+
88
+ ## When to Use
89
+
90
+ - **Legacy Mac fonts** — Converting old resources
91
+ - **Resource fork recovery** — Extracting embedded fonts
92
+ - **macOS compatibility** — When required
93
+
94
+ ## Modern Alternatives
95
+
96
+ For new fonts, prefer:
97
+ - **TTC** — TrueType Collection
98
+ - **OTC** — OpenType Collection
99
+ - **WOFF2** — Web delivery
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: Font Formats Overview
3
+ ---
4
+
5
+ # Font Formats Overview
6
+
7
+ Fontisan supports a wide range of font formats.
8
+
9
+ ## Supported Formats
10
+
11
+ ### Modern Formats
12
+
13
+ | Format | Extension | Description |
14
+ |--------|-----------|-------------|
15
+ | TrueType | .ttf | Standard TrueType font |
16
+ | OpenType | .otf | CFF-based OpenType font |
17
+ | WOFF | .woff | Web Open Font Format |
18
+ | WOFF2 | .woff2 | Web Open Font Format 2 |
19
+
20
+ ### Legacy Formats
21
+
22
+ | Format | Extension | Description |
23
+ |--------|-----------|-------------|
24
+ | Type 1 | .pfb, .pfa | Adobe Type 1 font |
25
+ | dfont | .dfont | Apple Data Fork font |
26
+ | TTC | .ttc | TrueType Collection |
27
+ | OTC | .otc | OpenType Collection |
28
+
29
+ ### Other Formats
30
+
31
+ | Format | Extension | Description |
32
+ |--------|-----------|-------------|
33
+ | SVG | .svg | SVG font |
34
+
35
+ ## Guides
36
+
37
+ - [TrueType (TTF)](/guide/formats/ttf) — TrueType font format
38
+ - [OpenType (OTF)](/guide/formats/otf) — OpenType/CFF format
39
+ - [Type 1 (PFB/PFA)](/guide/formats/type1) — Adobe Type 1 fonts
40
+ - [WOFF & WOFF2](/guide/formats/woff) — Web font formats
41
+ - [Collections](/guide/formats/collections) — TTC and OTC collections
42
+ - [Apple dfont](/guide/formats/dfont) — Apple legacy format
43
+ - [SVG Fonts](/guide/formats/svg) — SVG-based fonts
44
+
45
+ ## Format Detection
46
+
47
+ Fontisan automatically detects font format:
48
+
49
+ ```ruby
50
+ # Works with any format
51
+ font = Fontisan::FontLoader.load('font.ttf')
52
+ font = Fontisan::FontLoader.load('font.otf')
53
+ font = Fontisan::FontLoader.load('font.pfb')
54
+ font = Fontisan::FontLoader.load('font.woff2')
55
+ ```
56
+
57
+ ## Conversion Matrix
58
+
59
+ | From | To TTF | To OTF | To WOFF | To WOFF2 |
60
+ |------|--------|--------|---------|----------|
61
+ | TTF | ✓ | ✓ | ✓ | ✓ |
62
+ | OTF | ✓ | ✓ | ✓ | ✓ |
63
+ | Type 1 | ✓ | ✓ | ✓ | ✓ |
64
+ | WOFF | ✓ | ✓ | ✓ | ✓ |
65
+ | WOFF2 | ✓ | ✓ | ✓ | ✓ |
@@ -0,0 +1,103 @@
1
+ ---
2
+ title: OpenType (OTF)
3
+ ---
4
+
5
+ # OpenType (OTF)
6
+
7
+ OpenType/CFF uses cubic Bézier curves in a Compact Font Format.
8
+
9
+ ## Overview
10
+
11
+ - **Curve Type**: Cubic Bézier
12
+ - **Hinting**: PostScript hints
13
+ - **Storage**: CFF table
14
+
15
+ ## Key Tables
16
+
17
+ | Table | Purpose |
18
+ |-------|---------|
19
+ | head | Font header |
20
+ | hhea | Horizontal header |
21
+ | maxp | Maximum profile |
22
+ | name | Name records |
23
+ | cmap | Character mapping |
24
+ | CFF | Compact Font Format |
25
+ | hmtx | Horizontal metrics |
26
+ | post | PostScript names |
27
+ | OS/2 | OS/2 metrics |
28
+ | GSUB | Glyph substitution |
29
+ | GPOS | Glyph positioning |
30
+
31
+ ## CFF Table Structure
32
+
33
+ ```ruby
34
+ cff = font.tables['CFF']
35
+
36
+ # Top DICT
37
+ top_dict = cff.top_dicts.first
38
+
39
+ # Name
40
+ puts "Font name: #{cff.names.first}"
41
+
42
+ # Private DICT
43
+ private = top_dict[:private]
44
+ puts "Blue values: #{private[:blue_values]}"
45
+ puts "Std HW: #{private[:std_hw]}"
46
+ ```
47
+
48
+ ## CharStrings
49
+
50
+ ```ruby
51
+ cff = font.tables['CFF']
52
+
53
+ # Access CharStrings
54
+ charstrings = cff.charstrings
55
+
56
+ charstrings.each_with_index do |charstring, glyph_id|
57
+ puts "Glyph #{glyph_id}: #{charstring.length} operators"
58
+ end
59
+ ```
60
+
61
+ ## Hinting
62
+
63
+ OpenType fonts use PostScript hints:
64
+
65
+ ```ruby
66
+ private = font.tables['CFF'].top_dicts.first[:private]
67
+
68
+ # Blue zones
69
+ puts "Blue values: #{private[:blue_values]}"
70
+ puts "Other blues: #{private[:other_blues]}"
71
+
72
+ # Stem widths
73
+ puts "Std HW: #{private[:std_hw]}"
74
+ puts "Std VW: #{private[:std_vw]}"
75
+ puts "Stem snap H: #{private[:stem_snap_h]}"
76
+ ```
77
+
78
+ ## Converting
79
+
80
+ ### OTF to TTF
81
+
82
+ ```bash
83
+ fontisan convert font.otf --to ttf --output font.ttf
84
+ ```
85
+
86
+ ### OTF to WOFF2
87
+
88
+ ```bash
89
+ fontisan convert font.otf --to woff2 --output font.woff2
90
+ ```
91
+
92
+ ## Characteristics
93
+
94
+ ### Advantages
95
+
96
+ - **Smaller file size** — CFF compression
97
+ - **Cubic curves** — Fewer points needed
98
+ - **PostScript heritage** — Print workflows
99
+
100
+ ### Limitations
101
+
102
+ - **Limited hinting** — PostScript hints vs TrueType
103
+ - **Variable support** — CFF2 required
@@ -0,0 +1,97 @@
1
+ ---
2
+ title: SVG Fonts
3
+ ---
4
+
5
+ # SVG Fonts
6
+
7
+ SVG fonts define glyphs using SVG graphics.
8
+
9
+ ## Overview
10
+
11
+ - **Format**: SVG document
12
+ - **Features**: Full SVG capabilities
13
+ - **Use Case**: Specialized applications
14
+
15
+ ## Structure
16
+
17
+ SVG fonts are SVG documents with font definitions:
18
+
19
+ ```xml
20
+ <svg>
21
+ <font>
22
+ <font-face font-family="MyFont"/>
23
+ <glyph unicode="A" d="M0 0 L100 0..."/>
24
+ </font>
25
+ </svg>
26
+ ```
27
+
28
+ ## Loading
29
+
30
+ ```ruby
31
+ font = Fontisan::FontLoader.load('font.svg')
32
+
33
+ # Access glyphs
34
+ font.glyphs.each do |glyph|
35
+ puts glyph.unicode
36
+ puts glyph.path_data
37
+ end
38
+ ```
39
+
40
+ ## Creating
41
+
42
+ SVG fonts can be created manually or with tools:
43
+
44
+ ```ruby
45
+ # Export to SVG
46
+ Fontisan::FontWriter.write(font, 'output.svg', format: :svg)
47
+ ```
48
+
49
+ ## Converting
50
+
51
+ ### SVG to TTF
52
+
53
+ ```bash
54
+ fontisan convert font.svg --to ttf --output font.ttf
55
+ ```
56
+
57
+ ### SVG to OTF
58
+
59
+ ```bash
60
+ fontisan convert font.svg --to otf --output font.otf
61
+ ```
62
+
63
+ ### From other formats
64
+
65
+ ```bash
66
+ fontisan convert font.ttf --to svg --output font.svg
67
+ ```
68
+
69
+ ## Limitations
70
+
71
+ - **No hinting** — SVG has no hint support
72
+ - **Large files** — XML overhead
73
+ - **Limited layout** — No GSUB/GPOS
74
+ - **Variable support** — No variable fonts
75
+
76
+ ## SVG vs COLR/CPAL
77
+
78
+ | Feature | SVG Font | COLR/CPAL |
79
+ |---------|----------|-----------|
80
+ | File size | Large | Small |
81
+ | Effects | Full | Limited |
82
+ | Browser support | Good | Good |
83
+ | Variable fonts | No | Yes |
84
+ | Performance | Slow | Fast |
85
+
86
+ ## When to Use
87
+
88
+ - **SVG workflows** — Integration with SVG graphics
89
+ - **Special effects** — Complex visual effects
90
+ - **Legacy content** — Existing SVG fonts
91
+
92
+ ## Modern Alternatives
93
+
94
+ For most uses, prefer:
95
+ - **COLR/CPAL** — Color fonts
96
+ - **WOFF2** — Web delivery
97
+ - **OTF/TTF** — General use
@@ -0,0 +1,105 @@
1
+ ---
2
+ title: TrueType (TTF)
3
+ ---
4
+
5
+ # TrueType (TTF)
6
+
7
+ TrueType is a standard font format using quadratic Bézier curves.
8
+
9
+ ## Overview
10
+
11
+ - **Curve Type**: Quadratic Bézier
12
+ - **Hinting**: TrueType instructions
13
+ - **Storage**: glyf + loca tables
14
+
15
+ ## Key Tables
16
+
17
+ | Table | Purpose |
18
+ |-------|---------|
19
+ | head | Font header |
20
+ | hhea | Horizontal header |
21
+ | maxp | Maximum profile |
22
+ | name | Name records |
23
+ | cmap | Character mapping |
24
+ | glyf | Glyph outlines |
25
+ | loca | Glyph locations |
26
+ | hmtx | Horizontal metrics |
27
+ | post | PostScript names |
28
+ | prep | Control Value Program |
29
+ | fpgm | Font Program |
30
+ | cvt | Control Value Table |
31
+
32
+ ## Loading
33
+
34
+ ```ruby
35
+ font = Fontisan::FontLoader.load('font.ttf')
36
+
37
+ # Access tables
38
+ head = font.tables['head']
39
+ glyf = font.tables['glyf']
40
+
41
+ puts "Units per Em: #{head.units_per_em}"
42
+ puts "Glyphs: #{font.tables['maxp'].num_glyphs}"
43
+ ```
44
+
45
+ ## Glyph Outlines
46
+
47
+ ```ruby
48
+ glyph = font.glyphs[42]
49
+
50
+ # Access outline
51
+ glyph.contours.each do |contour|
52
+ contour.points.each do |point|
53
+ if point.on_curve?
54
+ puts "Point at (#{point.x}, #{point.y})"
55
+ else
56
+ puts "Control at (#{point.x}, #{point.y})"
57
+ end
58
+ end
59
+ end
60
+ ```
61
+
62
+ ## Hinting
63
+
64
+ TrueType fonts use bytecode instructions:
65
+
66
+ ```ruby
67
+ prep = font.tables['prep']
68
+ fpgm = font.tables['fpgm']
69
+ cvt = font.tables['cvt']
70
+
71
+ if prep
72
+ puts "Prep program: #{prep.bytecode.length} bytes"
73
+ end
74
+
75
+ if cvt
76
+ puts "CVT entries: #{cvt.values.length}"
77
+ end
78
+ ```
79
+
80
+ ## Converting
81
+
82
+ ### TTF to OTF
83
+
84
+ ```bash
85
+ fontisan convert font.ttf --to otf --output font.otf
86
+ ```
87
+
88
+ ### TTF to WOFF2
89
+
90
+ ```bash
91
+ fontisan convert font.ttf --to woff2 --output font.woff2
92
+ ```
93
+
94
+ ## Characteristics
95
+
96
+ ### Advantages
97
+
98
+ - **Wide support** — All platforms
99
+ - **Excellent hinting** — TrueType instructions
100
+ - **Variable fonts** — gvar support
101
+
102
+ ### Limitations
103
+
104
+ - **Larger file size** — Compared to CFF
105
+ - **Quadratic curves** — More points for complex shapes