fontisan 0.2.11 → 0.2.13

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +294 -52
  3. data/Gemfile +5 -0
  4. data/README.adoc +163 -2
  5. data/docs/CONVERSION_GUIDE.adoc +633 -0
  6. data/docs/TYPE1_FONTS.adoc +445 -0
  7. data/lib/fontisan/cli.rb +177 -6
  8. data/lib/fontisan/commands/convert_command.rb +32 -1
  9. data/lib/fontisan/commands/info_command.rb +83 -2
  10. data/lib/fontisan/config/conversion_matrix.yml +132 -4
  11. data/lib/fontisan/constants.rb +12 -0
  12. data/lib/fontisan/conversion_options.rb +378 -0
  13. data/lib/fontisan/converters/collection_converter.rb +45 -10
  14. data/lib/fontisan/converters/format_converter.rb +17 -5
  15. data/lib/fontisan/converters/outline_converter.rb +78 -4
  16. data/lib/fontisan/converters/type1_converter.rb +1234 -0
  17. data/lib/fontisan/font_loader.rb +46 -3
  18. data/lib/fontisan/hints/hint_converter.rb +4 -1
  19. data/lib/fontisan/type1/afm_generator.rb +436 -0
  20. data/lib/fontisan/type1/afm_parser.rb +298 -0
  21. data/lib/fontisan/type1/agl.rb +456 -0
  22. data/lib/fontisan/type1/cff_to_type1_converter.rb +302 -0
  23. data/lib/fontisan/type1/charstring_converter.rb +240 -0
  24. data/lib/fontisan/type1/charstrings.rb +408 -0
  25. data/lib/fontisan/type1/conversion_options.rb +243 -0
  26. data/lib/fontisan/type1/decryptor.rb +183 -0
  27. data/lib/fontisan/type1/encodings.rb +697 -0
  28. data/lib/fontisan/type1/font_dictionary.rb +576 -0
  29. data/lib/fontisan/type1/generator.rb +220 -0
  30. data/lib/fontisan/type1/inf_generator.rb +332 -0
  31. data/lib/fontisan/type1/pfa_generator.rb +369 -0
  32. data/lib/fontisan/type1/pfa_parser.rb +159 -0
  33. data/lib/fontisan/type1/pfb_generator.rb +314 -0
  34. data/lib/fontisan/type1/pfb_parser.rb +166 -0
  35. data/lib/fontisan/type1/pfm_generator.rb +610 -0
  36. data/lib/fontisan/type1/pfm_parser.rb +433 -0
  37. data/lib/fontisan/type1/private_dict.rb +342 -0
  38. data/lib/fontisan/type1/seac_expander.rb +501 -0
  39. data/lib/fontisan/type1/ttf_to_type1_converter.rb +327 -0
  40. data/lib/fontisan/type1/upm_scaler.rb +118 -0
  41. data/lib/fontisan/type1.rb +75 -0
  42. data/lib/fontisan/type1_font.rb +318 -0
  43. data/lib/fontisan/version.rb +1 -1
  44. data/lib/fontisan.rb +2 -0
  45. metadata +30 -3
  46. data/docs/DOCUMENTATION_SUMMARY.md +0 -141
data/README.adoc CHANGED
@@ -9,8 +9,8 @@ image:https://github.com/fontist/fontisan/actions/workflows/test.yml/badge.svg[B
9
9
  Fontisan is a Ruby gem providing font analysis tools and utilities.
10
10
 
11
11
  It is designed as a pure Ruby implementation with full object-oriented
12
- architecture, supporting extraction of information from OpenType and TrueType
13
- fonts (OTF, TTF, OTC, TTC, dfont).
12
+ architecture, supporting extraction of information from OpenType, TrueType,
13
+ and Adobe Type 1 fonts (OTF, TTF, OTC, TTC, dfont, PFB, PFA).
14
14
 
15
15
  The gem provides both a Ruby library API and a command-line interface, with
16
16
  structured output formats (YAML, JSON, text) via lutaml-model.
@@ -81,6 +81,7 @@ Font operations::
81
81
 
82
82
  Font format support::
83
83
  * TTF, OTF, TTC, OTC font formats (production ready)
84
+ * Adobe Type 1 fonts (PFB/PFA) with bidirectional conversion (see link:docs/TYPE1_FONTS.adoc[Type 1 Fonts Guide])
84
85
  * WOFF/WOFF2 format support with reading, writing, and conversion (see link:docs/WOFF_WOFF2_FORMATS.adoc[WOFF/WOFF2 Guide])
85
86
  * Apple legacy font support: 'true' signature TrueType fonts and dfont format (see link:docs/APPLE_LEGACY_FONTS.adoc[Apple Legacy Fonts Guide])
86
87
  * SVG font generation (complete)
@@ -2045,6 +2046,166 @@ All TrueType fonts are converted to OpenType/CFF format.
2045
2046
  ====
2046
2047
 
2047
2048
 
2049
+ == Font conversion options
2050
+
2051
+ === General
2052
+
2053
+ Fontisan provides a comprehensive conversion options system based on the TypeTool 3
2054
+ manual's recommended options for different font format conversions. The system supports:
2055
+
2056
+ * Format-specific default options
2057
+ * Named presets for common workflows
2058
+ * Fine-grained control over conversion behavior
2059
+ * Type-safe option validation
2060
+
2061
+ The conversion options system gives you control over how fonts are converted between
2062
+ formats, with options for opening (reading) fonts and generating (writing) fonts.
2063
+
2064
+ For complete documentation, see link:docs/CONVERSION_GUIDE.adoc[Conversion Guide]
2065
+ and link:docs/TYPE1_FONTS.adoc[Type 1 Font Support].
2066
+
2067
+
2068
+ === Show recommended options
2069
+
2070
+ Use `--show-options` to display the recommended options for a conversion:
2071
+
2072
+ [source,shell]
2073
+ ----
2074
+ $ fontisan convert font.ttf --to otf --show-options
2075
+
2076
+ Recommended options for TTF → OTF conversion:
2077
+ ======================================================================
2078
+
2079
+ Opening options:
2080
+ --convert-curves: true
2081
+ --scale-to-1000: true
2082
+ --autohint: true
2083
+ --decompose-composites: false
2084
+ --store-custom-tables: true
2085
+
2086
+ Generating options:
2087
+ --hinting-mode: auto
2088
+ --decompose-on-output: true
2089
+
2090
+ Available presets:
2091
+ type1_to_modern
2092
+ modern_to_type1
2093
+ web_optimized
2094
+ archive_to_modern
2095
+
2096
+ To use preset:
2097
+ fontisan convert ttf --to otf --preset <name> --output output.ext
2098
+ ----
2099
+
2100
+
2101
+ === Using presets
2102
+
2103
+ Presets provide pre-configured options for common conversion scenarios:
2104
+
2105
+ [source,shell]
2106
+ ----
2107
+ # Convert Type 1 to modern OpenType
2108
+ fontisan convert font.pfb --to otf --preset type1_to_modern --output font.otf
2109
+
2110
+ # Convert to web-optimized WOFF2
2111
+ fontisan convert font.otf --to woff2 --preset web_optimized --output font.woff2
2112
+
2113
+ # Convert font archive to modern format
2114
+ fontisan convert family.ttc --to otc --preset archive_to_modern --output family.otc
2115
+ ----
2116
+
2117
+
2118
+ === Custom conversion options
2119
+
2120
+ Individual options can be specified for fine-grained control:
2121
+
2122
+ Opening options (control how the source font is read):
2123
+
2124
+ * `--decompose` - Decompose composite glyphs
2125
+ * `--convert-curves` - Convert curve types during conversion
2126
+ * `--scale-to-1000` - Scale units-per-em to 1000
2127
+ * `--autohint` - Auto-hint the font
2128
+ * `--generate-unicode` - Generate Unicode mappings (Type 1)
2129
+
2130
+ Generating options (control how the output font is written):
2131
+
2132
+ * `--hinting-mode` - Hint mode: preserve, auto, none, or full
2133
+ * `--optimize-tables` - Enable table optimization
2134
+ * `--decompose-on-output` - Decompose composites in output
2135
+
2136
+ [source,shell]
2137
+ ----
2138
+ # Convert with autohinting and optimization
2139
+ fontisan convert font.ttf --to otf --output font.otf \
2140
+ --autohint --hinting-mode auto --optimize-tables
2141
+ ----
2142
+
2143
+ For detailed information on all available options and conversion scenarios,
2144
+ see the link:docs/CONVERSION_GUIDE.adoc[Conversion Guide].
2145
+
2146
+
2147
+ === Ruby API usage
2148
+
2149
+ .Using recommended options
2150
+ [example]
2151
+ ====
2152
+ [source,ruby]
2153
+ ----
2154
+ require 'fontisan'
2155
+
2156
+ # Get recommended options for TTF → OTF conversion
2157
+ options = Fontisan::ConversionOptions.recommended(from: :ttf, to: :otf)
2158
+
2159
+ # Access opening and generating options
2160
+ options.opening # => { convert_curves: true, scale_to_1000: true, ... }
2161
+ options.generating # => { hinting_mode: "auto", decompose_on_output: true }
2162
+
2163
+ # Use with converter
2164
+ converter = Fontisan::Converters::OutlineConverter.new
2165
+ tables = converter.convert(font, options: options)
2166
+ ----
2167
+ ====
2168
+
2169
+
2170
+ .Using presets programmatically
2171
+ [example]
2172
+ ====
2173
+ [source,ruby]
2174
+ ----
2175
+ require 'fontisan'
2176
+
2177
+ # Load a preset
2178
+ options = Fontisan::ConversionOptions.from_preset(:type1_to_modern)
2179
+
2180
+ # Convert with preset
2181
+ converter = Fontisan::Converters::Type1Converter.new
2182
+ tables = converter.convert(font, options: options)
2183
+ ----
2184
+ ====
2185
+
2186
+
2187
+ .Building custom options
2188
+ [example]
2189
+ ====
2190
+ [source,ruby]
2191
+ ----
2192
+ require 'fontisan'
2193
+
2194
+ # Build custom conversion options
2195
+ options = Fontisan::ConversionOptions.new(
2196
+ from: :ttf,
2197
+ to: :otf,
2198
+ opening: { autohint: true, convert_curves: true },
2199
+ generating: { hinting_mode: "auto" }
2200
+ )
2201
+
2202
+ # Use with converter
2203
+ converter = Fontisan::Converters::OutlineConverter.new
2204
+ tables = converter.convert(font, options: options)
2205
+ ----
2206
+ ====
2207
+
2208
+
2048
2209
  == Round-Trip validation
2049
2210
 
2050
2211
  === General