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.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +56 -196
- data/Gemfile +1 -1
- data/docs/.gitignore +17 -0
- data/docs/.vitepress/config.ts +317 -0
- data/docs/.vitepress/theme/components/ApiMethod.vue +127 -0
- data/docs/.vitepress/theme/components/Badge.vue +51 -0
- data/docs/.vitepress/theme/components/FeatureComparison.vue +87 -0
- data/docs/.vitepress/theme/components/HeroCodeBlock.vue +98 -0
- data/docs/.vitepress/theme/components/WithinHero.vue +30 -0
- data/docs/.vitepress/theme/index.ts +22 -0
- data/docs/.vitepress/theme/style.css +330 -0
- data/docs/api/conversion-options.md +141 -0
- data/docs/api/converters/curve-converter.md +34 -0
- data/docs/api/converters/hint-converter.md +34 -0
- data/docs/api/converters/outline-converter.md +27 -0
- data/docs/api/font-loader.md +111 -0
- data/docs/api/font-writer.md +103 -0
- data/docs/api/index.md +79 -0
- data/docs/api/models/glyph-accessor.md +43 -0
- data/docs/api/models/glyph.md +40 -0
- data/docs/api/models/table-analyzer.md +35 -0
- data/docs/api/sfnt-font.md +53 -0
- data/docs/api/type1-font.md +43 -0
- data/docs/api/validators/font-validator.md +31 -0
- data/docs/api/validators/helper.md +36 -0
- data/docs/api/validators/profile.md +39 -0
- data/docs/cli/convert.md +87 -0
- data/docs/cli/dump-table.md +110 -0
- data/docs/cli/export.md +176 -0
- data/docs/cli/features.md +124 -0
- data/docs/cli/glyphs.md +90 -0
- data/docs/cli/index.md +208 -0
- data/docs/cli/info.md +254 -0
- data/docs/cli/instance.md +122 -0
- data/docs/cli/ls.md +95 -0
- data/docs/cli/optical-size.md +94 -0
- data/docs/cli/pack.md +125 -0
- data/docs/cli/scripts.md +105 -0
- data/docs/cli/subset.md +39 -0
- data/docs/cli/tables.md +84 -0
- data/docs/cli/unicode.md +101 -0
- data/docs/cli/validate.md +48 -0
- data/docs/cli/variable.md +126 -0
- data/docs/cli/version.md +46 -0
- data/docs/guide/cli/convert.md +108 -0
- data/docs/guide/cli/export.md +138 -0
- data/docs/guide/cli/index.md +99 -0
- data/docs/guide/cli/info.md +144 -0
- data/docs/guide/cli/pack.md +155 -0
- data/docs/guide/cli/subset.md +118 -0
- data/docs/guide/cli/validate.md +139 -0
- data/docs/guide/color-fonts/bitmaps.md +177 -0
- data/docs/guide/color-fonts/colr-cpal.md +175 -0
- data/docs/guide/color-fonts/index.md +140 -0
- data/docs/guide/color-fonts/svg.md +154 -0
- data/docs/guide/color.md +51 -0
- data/docs/guide/comparisons/font-validator.md +222 -0
- data/docs/guide/comparisons/fonttools.md +200 -0
- data/docs/guide/comparisons/index.md +83 -0
- data/docs/guide/comparisons/lcdf-typetools.md +205 -0
- data/docs/guide/contributing.md +279 -0
- data/docs/guide/conversion/collections.md +251 -0
- data/docs/guide/conversion/curves.md +246 -0
- data/docs/guide/conversion/index.md +157 -0
- data/docs/guide/conversion/options.md +251 -0
- data/docs/guide/conversion/ttf-otf.md +184 -0
- data/docs/guide/conversion/type1.md +208 -0
- data/docs/guide/conversion/web.md +240 -0
- data/docs/guide/conversion.md +39 -0
- data/docs/guide/formats/collections.md +147 -0
- data/docs/guide/formats/dfont.md +99 -0
- data/docs/guide/formats/index.md +65 -0
- data/docs/guide/formats/otf.md +103 -0
- data/docs/guide/formats/svg.md +97 -0
- data/docs/guide/formats/ttf.md +105 -0
- data/docs/guide/formats/type1.md +118 -0
- data/docs/guide/formats/woff.md +115 -0
- data/docs/guide/hinting/autohint.md +141 -0
- data/docs/guide/hinting/conversion.md +161 -0
- data/docs/guide/hinting/index.md +86 -0
- data/docs/guide/hinting/postscript.md +149 -0
- data/docs/guide/hinting/truetype.md +135 -0
- data/docs/guide/hinting.md +44 -0
- data/docs/guide/index.md +152 -0
- data/docs/guide/installation.md +116 -0
- data/docs/guide/migrations/extract-ttc.md +549 -0
- data/docs/guide/migrations/font-validator.md +260 -0
- data/docs/guide/migrations/fonttools.md +208 -0
- data/docs/guide/migrations/index.md +64 -0
- data/docs/guide/migrations/otfinfo.md +197 -0
- data/docs/guide/quick-start.md +204 -0
- data/docs/guide/type1.md +58 -0
- data/docs/guide/universal-outline.md +151 -0
- data/docs/guide/validation/custom.md +195 -0
- data/docs/guide/validation/helpers.md +188 -0
- data/docs/guide/validation/index.md +132 -0
- data/docs/guide/validation/profiles.md +156 -0
- data/docs/guide/validation.md +47 -0
- data/docs/guide/variable-fonts/advanced.md +231 -0
- data/docs/guide/variable-fonts/axes.md +209 -0
- data/docs/guide/variable-fonts/conversion.md +197 -0
- data/docs/guide/variable-fonts/index.md +84 -0
- data/docs/guide/variable-fonts/instances.md +187 -0
- data/docs/guide/variable-fonts/named-instances.md +194 -0
- data/docs/guide/variable-fonts/static.md +168 -0
- data/docs/guide/variable.md +58 -0
- data/docs/guide/woff.md +59 -0
- data/docs/index.md +136 -0
- data/docs/lychee.toml +37 -0
- data/docs/package-lock.json +2560 -0
- data/docs/package.json +15 -0
- data/docs/public/apple-touch-icon.png +0 -0
- data/docs/public/favicon-96x96.png +0 -0
- data/docs/public/favicon.ico +0 -0
- data/docs/public/favicon.svg +1 -0
- data/docs/public/logo-full.svg +1 -0
- data/docs/public/logo.svg +1 -0
- data/docs/public/site.webmanifest +21 -0
- data/docs/public/web-app-manifest-192x192.png +0 -0
- data/docs/public/web-app-manifest-512x512.png +0 -0
- data/fontisan.gemspec +1 -1
- data/lib/fontisan/commands/features_command.rb +0 -1
- data/lib/fontisan/commands/info_command.rb +5 -5
- data/lib/fontisan/commands/scripts_command.rb +0 -1
- data/lib/fontisan/converters/format_converter.rb +2 -1
- data/lib/fontisan/converters/type1_converter.rb +65 -60
- data/lib/fontisan/hints/hint_converter.rb +2 -1
- data/lib/fontisan/loading_modes.rb +0 -2
- data/lib/fontisan/open_type_font.rb +0 -40
- data/lib/fontisan/sfnt_font.rb +41 -22
- data/lib/fontisan/tables/glyf/compound_glyph.rb +0 -1
- data/lib/fontisan/true_type_collection.rb +8 -8
- data/lib/fontisan/true_type_font.rb +1 -59
- data/lib/fontisan/type1/afm_parser.rb +2 -1
- data/lib/fontisan/type1/cff_to_type1_converter.rb +24 -19
- data/lib/fontisan/type1/private_dict.rb +28 -7
- data/lib/fontisan/type1/seac_expander.rb +22 -17
- data/lib/fontisan/variable/delta_applicator.rb +3 -3
- data/lib/fontisan/variation/optimizer.rb +0 -1
- data/lib/fontisan/version.rb +1 -1
- data/lib/fontisan/woff2_font.rb +2 -2
- data/lib/fontisan/woff_font.rb +3 -3
- data/lib/fontisan.rb +3 -2
- metadata +122 -4
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Curve Conversion
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Curve Conversion
|
|
6
|
+
|
|
7
|
+
Fontisan handles conversion between TrueType's quadratic Bézier curves and OpenType/CFF's cubic Bézier curves.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
| Format | Curve Type | Math |
|
|
12
|
+
|--------|------------|------|
|
|
13
|
+
| TrueType (TTF) | Quadratic Bézier | 1 control point |
|
|
14
|
+
| OpenType/CFF (OTF) | Cubic Bézier | 2 control points |
|
|
15
|
+
|
|
16
|
+
## Quadratic Bézier Curves (TrueType)
|
|
17
|
+
|
|
18
|
+
Quadratic curves have one control point between two on-curve points:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
P0 ---- Q1 ---- P2
|
|
22
|
+
|
|
23
|
+
Where:
|
|
24
|
+
- P0, P2 are on-curve points
|
|
25
|
+
- Q1 is the control point
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Formula
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
B(t) = (1-t)²·P0 + 2(1-t)t·Q1 + t²·P2
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Cubic Bézier Curves (OpenType/CFF)
|
|
35
|
+
|
|
36
|
+
Cubic curves have two control points:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
P0 -- C1 -- C2 -- P3
|
|
40
|
+
|
|
41
|
+
Where:
|
|
42
|
+
- P0, P3 are on-curve points
|
|
43
|
+
- C1, C2 are control points
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Formula
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
B(t) = (1-t)³·P0 + 3(1-t)²t·C1 + 3(1-t)t²·C2 + t³·P3
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Quadratic → Cubic (TTF → OTF)
|
|
53
|
+
|
|
54
|
+
This conversion is mathematically exact.
|
|
55
|
+
|
|
56
|
+
### Conversion Process
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
# TrueType quadratic: P0, Q1, P2
|
|
60
|
+
# Converts to cubic: P0, C1, C2, P2
|
|
61
|
+
#
|
|
62
|
+
# C1 = P0 + (2/3)(Q1 - P0)
|
|
63
|
+
# C2 = P2 + (2/3)(Q1 - P2)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Example
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
# Source: TrueType quadratic curve
|
|
70
|
+
p0 = [100, 100]
|
|
71
|
+
q1 = [150, 200] # control point
|
|
72
|
+
p2 = [200, 100]
|
|
73
|
+
|
|
74
|
+
# Convert to cubic
|
|
75
|
+
c1 = [
|
|
76
|
+
p0[0] + (2.0/3) * (q1[0] - p0[0]), # 133.33
|
|
77
|
+
p0[1] + (2.0/3) * (q1[1] - p0[1]) # 166.67
|
|
78
|
+
]
|
|
79
|
+
c2 = [
|
|
80
|
+
p2[0] + (2.0/3) * (q1[0] - p2[0]), # 166.67
|
|
81
|
+
p2[1] + (2.0/3) * (q1[1] - p2[1]) # 166.67
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
# Result: [100, 100] -> [133.33, 166.67] -> [166.67, 166.67] -> [200, 100]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Characteristics
|
|
88
|
+
|
|
89
|
+
- **Exact** — No approximation needed
|
|
90
|
+
- **Point count may increase** — Due to implicit on-curve points in TrueType
|
|
91
|
+
|
|
92
|
+
## Cubic → Quadratic (OTF → TTF)
|
|
93
|
+
|
|
94
|
+
This conversion requires approximation since cubic curves cannot be exactly represented as quadratic.
|
|
95
|
+
|
|
96
|
+
### Approximation Methods
|
|
97
|
+
|
|
98
|
+
Fontisan uses the midpoint approximation method:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
# Cubic: P0, C1, C2, P3
|
|
102
|
+
# Approximate with multiple quadratic curves
|
|
103
|
+
#
|
|
104
|
+
# Method: Subdivide until quadratic fits within tolerance
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Tolerance Setting
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
options = Fontisan::ConversionOptions.new(
|
|
111
|
+
curve_tolerance: 0.5 # Lower = more accurate, more points
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
| Tolerance | Accuracy | Point Count |
|
|
116
|
+
|-----------|----------|-------------|
|
|
117
|
+
| 1.0 | Lower | Fewer |
|
|
118
|
+
| 0.5 | Medium | Medium |
|
|
119
|
+
| 0.1 | Higher | More |
|
|
120
|
+
|
|
121
|
+
### Example
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
# Source: Cubic curve
|
|
125
|
+
p0 = [100, 100]
|
|
126
|
+
c1 = [120, 200]
|
|
127
|
+
c2 = [180, 200]
|
|
128
|
+
p3 = [200, 100]
|
|
129
|
+
|
|
130
|
+
# May require 2+ quadratic curves:
|
|
131
|
+
# Quad 1: P0 -> Q1 -> P_mid
|
|
132
|
+
# Quad 2: P_mid -> Q2 -> P3
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Characteristics
|
|
136
|
+
|
|
137
|
+
- **Approximate** — Some precision loss unavoidable
|
|
138
|
+
- **Point count increases** — Multiple quadratic curves per cubic
|
|
139
|
+
- **Tolerance affects quality** — Lower tolerance = more accurate
|
|
140
|
+
|
|
141
|
+
## Implicit On-Curve Points
|
|
142
|
+
|
|
143
|
+
TrueType uses an optimization where on-curve points can be implicit:
|
|
144
|
+
|
|
145
|
+
```ruby
|
|
146
|
+
# If two consecutive off-curve points exist,
|
|
147
|
+
# the midpoint is an implicit on-curve point
|
|
148
|
+
#
|
|
149
|
+
# Q1 ---- (implicit P) ---- Q2
|
|
150
|
+
#
|
|
151
|
+
# P = (Q1 + Q2) / 2
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This can reduce point count but must be expanded for conversion.
|
|
155
|
+
|
|
156
|
+
## Curve Conversion Options
|
|
157
|
+
|
|
158
|
+
### CLI
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Enable curve conversion
|
|
162
|
+
fontisan convert font.ttf --to otf --convert-curves
|
|
163
|
+
|
|
164
|
+
# With tolerance (OTF → TTF only)
|
|
165
|
+
fontisan convert font.otf --to ttf --curve-tolerance 0.5
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### API
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
options = Fontisan::ConversionOptions.new(
|
|
172
|
+
from: :ttf,
|
|
173
|
+
to: :otf,
|
|
174
|
+
opening: {
|
|
175
|
+
convert_curves: true
|
|
176
|
+
},
|
|
177
|
+
curve_tolerance: 0.5 # For OTF → TTF
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Preserving Curves
|
|
182
|
+
|
|
183
|
+
To skip curve conversion (same-format operations):
|
|
184
|
+
|
|
185
|
+
```ruby
|
|
186
|
+
options = Fontisan::ConversionOptions.new(
|
|
187
|
+
opening: { convert_curves: false }
|
|
188
|
+
)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Quality vs Size Trade-off
|
|
192
|
+
|
|
193
|
+
### TTF → OTF
|
|
194
|
+
|
|
195
|
+
- **No trade-off** — Exact conversion
|
|
196
|
+
- File size may increase due to explicit points
|
|
197
|
+
|
|
198
|
+
### OTF → TTF
|
|
199
|
+
|
|
200
|
+
- **Trade-off exists** — Approximation required
|
|
201
|
+
- Lower tolerance = better quality, larger files
|
|
202
|
+
- Higher tolerance = lower quality, smaller files
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# High quality
|
|
206
|
+
fontisan convert font.otf --to ttf --curve-tolerance 0.1
|
|
207
|
+
|
|
208
|
+
# Smaller file
|
|
209
|
+
fontisan convert font.otf --to ttf --curve-tolerance 1.0
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Technical Details
|
|
213
|
+
|
|
214
|
+
### Checking Curve Types
|
|
215
|
+
|
|
216
|
+
```ruby
|
|
217
|
+
font = Fontisan::FontLoader.load('font.ttf')
|
|
218
|
+
|
|
219
|
+
# Check glyph format
|
|
220
|
+
glyph = font.glyphs[0]
|
|
221
|
+
puts glyph.curve_type # :quadratic or :cubic
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Counting Points
|
|
225
|
+
|
|
226
|
+
```ruby
|
|
227
|
+
font = Fontisan::FontLoader.load('font.ttf')
|
|
228
|
+
|
|
229
|
+
total_on_curve = 0
|
|
230
|
+
total_off_curve = 0
|
|
231
|
+
|
|
232
|
+
font.glyphs.each do |glyph|
|
|
233
|
+
glyph.contours.each do |contour|
|
|
234
|
+
contour.points.each do |point|
|
|
235
|
+
if point.on_curve?
|
|
236
|
+
total_on_curve += 1
|
|
237
|
+
else
|
|
238
|
+
total_off_curve += 1
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
puts "On-curve: #{total_on_curve}"
|
|
245
|
+
puts "Off-curve: #{total_off_curve}"
|
|
246
|
+
```
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Conversion Overview
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Conversion Overview
|
|
6
|
+
|
|
7
|
+
Fontisan's conversion system is based on the TypeTool 3 manual's recommended options for different font format conversions. The system provides:
|
|
8
|
+
|
|
9
|
+
- **Type-safe option validation** — Catch errors before conversion
|
|
10
|
+
- **Format-specific defaults** — Recommended options per conversion type
|
|
11
|
+
- **Named presets** — Common workflows pre-configured
|
|
12
|
+
- **Fine-grained control** — Override any option when needed
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Using the CLI
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Basic conversion
|
|
20
|
+
fontisan convert input.ttf --to otf --output output.otf
|
|
21
|
+
|
|
22
|
+
# Show recommended options
|
|
23
|
+
fontisan convert input.ttf --to otf --show-options
|
|
24
|
+
|
|
25
|
+
# Use a preset
|
|
26
|
+
fontisan convert font.pfb --to otf --preset type1_to_modern --output output.otf
|
|
27
|
+
|
|
28
|
+
# Custom options
|
|
29
|
+
fontisan convert input.ttf --to otf --autohint --hinting-mode auto --output output.otf
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using the API
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
require 'fontisan'
|
|
36
|
+
|
|
37
|
+
# Get recommended options
|
|
38
|
+
options = Fontisan::ConversionOptions.recommended(from: :ttf, to: :otf)
|
|
39
|
+
|
|
40
|
+
# Use a preset
|
|
41
|
+
options = Fontisan::ConversionOptions.from_preset(:web_optimized)
|
|
42
|
+
|
|
43
|
+
# Build custom options
|
|
44
|
+
options = Fontisan::ConversionOptions.new(
|
|
45
|
+
from: :ttf,
|
|
46
|
+
to: :otf,
|
|
47
|
+
opening: { autohint: true, convert_curves: true },
|
|
48
|
+
generating: { hinting_mode: "auto" }
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Convert with options
|
|
52
|
+
converter = Fontisan::Converters::OutlineConverter.new
|
|
53
|
+
tables = converter.convert(font, options: options)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Supported Formats
|
|
57
|
+
|
|
58
|
+
### Input Formats
|
|
59
|
+
|
|
60
|
+
| Format | Description | Extensions |
|
|
61
|
+
|--------|-------------|------------|
|
|
62
|
+
| TTF | TrueType Font | .ttf |
|
|
63
|
+
| OTF | OpenType/CFF Font | .otf |
|
|
64
|
+
| Type 1 | Adobe Type 1 Font | .pfb, .pfa |
|
|
65
|
+
| TTC | TrueType Collection | .ttc |
|
|
66
|
+
| OTC | OpenType Collection | .otc |
|
|
67
|
+
| dfont | Apple Data Fork Font | .dfont |
|
|
68
|
+
| WOFF | Web Open Font Format | .woff |
|
|
69
|
+
| WOFF2 | Web Open Font Format 2 | .woff2 |
|
|
70
|
+
| SVG | SVG Font | .svg |
|
|
71
|
+
|
|
72
|
+
### Output Formats
|
|
73
|
+
|
|
74
|
+
All input formats can be converted to: **TTF, OTF, WOFF, WOFF2**
|
|
75
|
+
|
|
76
|
+
Collections (TTC, OTC, dfont) can be converted between each other.
|
|
77
|
+
|
|
78
|
+
## Conversion Guides
|
|
79
|
+
|
|
80
|
+
- [TTF ↔ OTF](/guide/conversion/ttf-otf) — TrueType and OpenType conversion
|
|
81
|
+
- [Type 1 → Modern](/guide/conversion/type1) — Converting legacy Type 1 fonts
|
|
82
|
+
- [Web Formats](/guide/conversion/web) — WOFF and WOFF2 optimization
|
|
83
|
+
- [Collections](/guide/conversion/collections) — TTC, OTC, and dfont handling
|
|
84
|
+
- [Curve Conversion](/guide/conversion/curves) — Quadratic ↔ Cubic curves
|
|
85
|
+
- [Options Reference](/guide/conversion/options) — Complete option documentation
|
|
86
|
+
|
|
87
|
+
## Presets
|
|
88
|
+
|
|
89
|
+
Fontisan includes presets for common workflows:
|
|
90
|
+
|
|
91
|
+
| Preset | Description |
|
|
92
|
+
|--------|-------------|
|
|
93
|
+
| `type1_to_modern` | Type 1 → OpenType for modern use |
|
|
94
|
+
| `modern_to_type1` | OpenType → Type 1 for legacy systems |
|
|
95
|
+
| `web_optimized` | Any → WOFF2 for web delivery |
|
|
96
|
+
| `archive_to_modern` | Collection → Individual OTF files |
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
# Using presets
|
|
100
|
+
options = Fontisan::ConversionOptions.from_preset(:web_optimized)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Hinting Modes
|
|
104
|
+
|
|
105
|
+
Control hinting behavior with `--hinting-mode`:
|
|
106
|
+
|
|
107
|
+
| Mode | Description | Use Case |
|
|
108
|
+
|------|-------------|----------|
|
|
109
|
+
| `preserve` | Keep original hints | Same-format conversions |
|
|
110
|
+
| `auto` | Apply automatic hinting | Cross-format conversions |
|
|
111
|
+
| `none` | Remove all hints | Maximum file size reduction |
|
|
112
|
+
| `full` | Full hint conversion | Print applications |
|
|
113
|
+
|
|
114
|
+
## Best Practices
|
|
115
|
+
|
|
116
|
+
1. **Use presets when possible** — Presets are optimized for common workflows
|
|
117
|
+
2. **Show options first** — Use `--show-options` to understand what will be applied
|
|
118
|
+
3. **Test conversions** — Always verify output fonts in target applications
|
|
119
|
+
4. **Preserve metadata** — Keep copyright and license information intact
|
|
120
|
+
|
|
121
|
+
## Troubleshooting
|
|
122
|
+
|
|
123
|
+
### Conversion Fails
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Check if source file is valid
|
|
127
|
+
fontisan info font.ttf
|
|
128
|
+
|
|
129
|
+
# Validate source font
|
|
130
|
+
fontisan validate font.ttf
|
|
131
|
+
|
|
132
|
+
# Try with verbose flag
|
|
133
|
+
fontisan convert font.ttf --to otf --verbose
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Output Font Too Large
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Enable optimization
|
|
140
|
+
fontisan convert font.ttf --to otf --optimize-tables
|
|
141
|
+
|
|
142
|
+
# Remove hinting
|
|
143
|
+
fontisan convert font.ttf --to otf --hinting-mode none
|
|
144
|
+
|
|
145
|
+
# Use web font format
|
|
146
|
+
fontisan convert font.ttf --to woff2
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Poor Rendering Quality
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Use autohinting
|
|
153
|
+
fontisan convert font.ttf --to otf --autohint --hinting-mode auto
|
|
154
|
+
|
|
155
|
+
# Preserve original hints
|
|
156
|
+
fontisan convert font.ttf --to otf --hinting-mode preserve
|
|
157
|
+
```
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Options Reference
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Options Reference
|
|
6
|
+
|
|
7
|
+
Complete reference for Fontisan's conversion options.
|
|
8
|
+
|
|
9
|
+
## Opening Options
|
|
10
|
+
|
|
11
|
+
Opening options control how the source font is read and processed.
|
|
12
|
+
|
|
13
|
+
| Option | Type | Description | Use Case |
|
|
14
|
+
|--------|------|-------------|----------|
|
|
15
|
+
| `decompose_composites` | Boolean | Decompose composite glyphs into simple glyphs | Target format doesn't support composites |
|
|
16
|
+
| `convert_curves` | Boolean | Convert curve types during conversion | Quadratic ↔ Cubic conversion |
|
|
17
|
+
| `scale_to_1000` | Boolean | Scale UPM to 1000 | Type 1 → OTF conversions |
|
|
18
|
+
| `scale_from_1000` | Boolean | Scale from 1000 UPM | OTF → TTF conversions |
|
|
19
|
+
| `autohint` | Boolean | Auto-hint the font | Source lacks hints or incompatible |
|
|
20
|
+
| `generate_unicode` | Boolean | Generate Unicode from glyph names | Type 1 conversions |
|
|
21
|
+
| `store_custom_tables` | Boolean | Preserve non-standard tables | Custom tables need preservation |
|
|
22
|
+
| `store_native_hinting` | Boolean | Preserve native hinting data | Hints for source format |
|
|
23
|
+
| `interpret_ot` | Boolean | Interpret OpenType layout features | GSUB/GPOS processing needed |
|
|
24
|
+
| `read_all_records` | Boolean | Load all font dictionary records | Type 1 with custom data |
|
|
25
|
+
| `preserve_encoding` | String | Preserve character encoding | Custom encoding required |
|
|
26
|
+
|
|
27
|
+
## Generating Options
|
|
28
|
+
|
|
29
|
+
Generating options control how the output font is written.
|
|
30
|
+
|
|
31
|
+
| Option | Type | Description | Use Case |
|
|
32
|
+
|--------|------|-------------|----------|
|
|
33
|
+
| `write_pfm` | Boolean | Write PFM file | Type 1 output |
|
|
34
|
+
| `write_afm` | Boolean | Write AFM file | Type 1 output |
|
|
35
|
+
| `write_inf` | Boolean | Write INF file | Type 1 output |
|
|
36
|
+
| `select_encoding_automatically` | Boolean | Auto-select encoding | Type 1 output |
|
|
37
|
+
| `hinting_mode` | String | Hint mode: preserve, auto, none, full | Control hinting |
|
|
38
|
+
| `decompose_on_output` | Boolean | Decompose composites in output | Target doesn't support composites |
|
|
39
|
+
| `write_custom_tables` | Boolean | Write custom tables | Preserve non-standard tables |
|
|
40
|
+
| `optimize_tables` | Boolean | Enable table optimization | Reduce file size |
|
|
41
|
+
| `reencode_first_256` | Boolean | Reencode first 256 glyphs | Type 1 output |
|
|
42
|
+
| `encoding_vector` | String | Custom encoding vector | Type 1 output |
|
|
43
|
+
| `compression` | String | Compression: zlib, brotli, none | Web font output |
|
|
44
|
+
| `transform_tables` | Boolean | Transform tables for output | Format-specific |
|
|
45
|
+
| `preserve_metadata` | Boolean | Preserve copyright/license metadata | Maintain metadata |
|
|
46
|
+
| `strip_metadata` | Boolean | Remove metadata | Reduce file size |
|
|
47
|
+
| `target_format` | String | Collection target format | Collection conversions |
|
|
48
|
+
| `curve_tolerance` | Float | Curve approximation tolerance | OTF → TTF |
|
|
49
|
+
|
|
50
|
+
## CLI Option Mapping
|
|
51
|
+
|
|
52
|
+
### Opening Options
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Decompose composite glyphs
|
|
56
|
+
--decompose # Enable decomposition
|
|
57
|
+
--no-decompose # Preserve composite glyphs
|
|
58
|
+
|
|
59
|
+
# Curve conversion
|
|
60
|
+
--convert-curves # Convert quadratic ↔ cubic
|
|
61
|
+
|
|
62
|
+
# UPM scaling
|
|
63
|
+
--scale-to-1000 # Scale to 1000 UPM
|
|
64
|
+
--scale-from-1000 # Scale from 1000 UPM
|
|
65
|
+
|
|
66
|
+
# Hinting
|
|
67
|
+
--autohint # Apply automatic hinting
|
|
68
|
+
|
|
69
|
+
# Unicode and encoding
|
|
70
|
+
--generate-unicode # Generate Unicode from glyph names
|
|
71
|
+
--preserve-encoding # Preserve character encoding
|
|
72
|
+
|
|
73
|
+
# Table handling
|
|
74
|
+
--preserve-custom-tables # Preserve non-standard tables
|
|
75
|
+
--interpret-ot # Interpret OpenType tables
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Generating Options
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Type 1 metrics files
|
|
82
|
+
--write-pfm # Generate PFM file
|
|
83
|
+
--write-afm # Generate AFM file
|
|
84
|
+
--write-inf # Generate INF file
|
|
85
|
+
|
|
86
|
+
# Encoding
|
|
87
|
+
--auto-encoding # Auto-detect encoding
|
|
88
|
+
--encoding VECTOR # Use specific encoding vector
|
|
89
|
+
|
|
90
|
+
# Hinting
|
|
91
|
+
--hinting-mode MODE # preserve|auto|none|full
|
|
92
|
+
|
|
93
|
+
# Optimization
|
|
94
|
+
--optimize-tables # Enable optimization
|
|
95
|
+
--no-optimization # Disable optimization
|
|
96
|
+
|
|
97
|
+
# Metadata
|
|
98
|
+
--preserve-metadata # Preserve copyright/license
|
|
99
|
+
--strip-metadata # Remove metadata
|
|
100
|
+
|
|
101
|
+
# Collections
|
|
102
|
+
--target-format FORMAT # ttf|otf|preserve
|
|
103
|
+
|
|
104
|
+
# Curves
|
|
105
|
+
--curve-tolerance N # Approximation tolerance (0.1-2.0)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Preset Option
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
--preset NAME # type1_to_modern, web_optimized, etc.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Hinting Modes
|
|
115
|
+
|
|
116
|
+
| Mode | Description | Best For |
|
|
117
|
+
|------|-------------|----------|
|
|
118
|
+
| `preserve` | Keep original hints | Same-format, compatible hints |
|
|
119
|
+
| `auto` | Apply automatic hinting | Cross-format, missing hints |
|
|
120
|
+
| `none` | Remove all hints | Web fonts, smallest size |
|
|
121
|
+
| `full` | Full hint conversion | Print, maximum quality |
|
|
122
|
+
|
|
123
|
+
### preserve
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
generating: { hinting_mode: "preserve" }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- Works best when source and target formats share hinting systems
|
|
130
|
+
- TTF → TTF: TrueType instructions preserved
|
|
131
|
+
- OTF → OTF: PostScript hints preserved
|
|
132
|
+
- Cross-format: May result in lost hints
|
|
133
|
+
|
|
134
|
+
### auto
|
|
135
|
+
|
|
136
|
+
```ruby
|
|
137
|
+
generating: { hinting_mode: "auto" }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- TTF → OTF: Autohinting applied to CFF output
|
|
141
|
+
- OTF → TTF: Autohinting applied to TrueType output
|
|
142
|
+
- Type 1 → Modern: Autohinting based on outlines
|
|
143
|
+
|
|
144
|
+
### none
|
|
145
|
+
|
|
146
|
+
```ruby
|
|
147
|
+
generating: { hinting_mode: "none" }
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- Smallest file size
|
|
151
|
+
- No rendering optimizations
|
|
152
|
+
- Useful when file size matters more than rendering
|
|
153
|
+
|
|
154
|
+
### full
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
generating: { hinting_mode: "full" }
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
- Attempts to preserve all hint information
|
|
161
|
+
- May generate larger files
|
|
162
|
+
- Best quality for print applications
|
|
163
|
+
|
|
164
|
+
## Presets
|
|
165
|
+
|
|
166
|
+
### type1_to_modern
|
|
167
|
+
|
|
168
|
+
Type 1 fonts to modern OpenType format.
|
|
169
|
+
|
|
170
|
+
```ruby
|
|
171
|
+
Fontisan::ConversionOptions.from_preset(:type1_to_modern)
|
|
172
|
+
# From: :type1, To: :otf
|
|
173
|
+
# opening: { generate_unicode: true, decompose_composites: false }
|
|
174
|
+
# generating: { hinting_mode: "preserve", decompose_on_output: true }
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### modern_to_type1
|
|
178
|
+
|
|
179
|
+
Modern fonts to Type 1 format.
|
|
180
|
+
|
|
181
|
+
```ruby
|
|
182
|
+
Fontisan::ConversionOptions.from_preset(:modern_to_type1)
|
|
183
|
+
# From: :otf, To: :type1
|
|
184
|
+
# opening: { convert_curves: true, scale_to_1000: true,
|
|
185
|
+
# autohint: true }
|
|
186
|
+
# generating: { write_pfm: true, write_afm: true, write_inf: true }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### web_optimized
|
|
190
|
+
|
|
191
|
+
Fonts optimized for web delivery.
|
|
192
|
+
|
|
193
|
+
```ruby
|
|
194
|
+
Fontisan::ConversionOptions.from_preset(:web_optimized)
|
|
195
|
+
# From: :otf, To: :woff2
|
|
196
|
+
# opening: {}
|
|
197
|
+
# generating: { compression: "brotli", transform_tables: true,
|
|
198
|
+
# optimize_tables: true, preserve_metadata: true }
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### archive_to_modern
|
|
202
|
+
|
|
203
|
+
Collection extraction and modernization.
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
Fontisan::ConversionOptions.from_preset(:archive_to_modern)
|
|
207
|
+
# From: :ttc, To: :otf
|
|
208
|
+
# opening: { convert_curves: true, decompose_composites: false }
|
|
209
|
+
# generating: { target_format: "otf", hinting_mode: "preserve" }
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Using Options
|
|
213
|
+
|
|
214
|
+
### CLI
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Show options before conversion
|
|
218
|
+
fontisan convert font.ttf --to otf --show-options
|
|
219
|
+
|
|
220
|
+
# Use preset
|
|
221
|
+
fontisan convert font.pfb --to otf --preset type1_to_modern
|
|
222
|
+
|
|
223
|
+
# Custom options
|
|
224
|
+
fontisan convert font.ttf --to otf \
|
|
225
|
+
--autohint \
|
|
226
|
+
--hinting-mode auto \
|
|
227
|
+
--optimize-tables \
|
|
228
|
+
--output font.otf
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### API
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
# Get recommended options
|
|
235
|
+
options = Fontisan::ConversionOptions.recommended(from: :ttf, to: :otf)
|
|
236
|
+
|
|
237
|
+
# Use preset
|
|
238
|
+
options = Fontisan::ConversionOptions.from_preset(:web_optimized)
|
|
239
|
+
|
|
240
|
+
# Build custom options
|
|
241
|
+
options = Fontisan::ConversionOptions.new(
|
|
242
|
+
from: :ttf,
|
|
243
|
+
to: :otf,
|
|
244
|
+
opening: { autohint: true, convert_curves: true },
|
|
245
|
+
generating: { hinting_mode: "auto", optimize_tables: true }
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
# Convert with options
|
|
249
|
+
converter = Fontisan::Converters::OutlineConverter.new
|
|
250
|
+
tables = converter.convert(font, options: options)
|
|
251
|
+
```
|