fontisan 0.4.49-java
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +141 -0
- data/.rubocop_todo.yml +433 -0
- data/BENCHMARKS.md +56 -0
- data/BUG-stitcher-drops-isolated-cps.md +58 -0
- data/BUG-stitcher-drops-plane1-codepoints.md +310 -0
- data/BUG-stitcher-gid-cap-65535.md +110 -0
- data/CHANGELOG.md +293 -0
- data/Cargo.lock +550 -0
- data/Cargo.toml +12 -0
- data/Gemfile +40 -0
- data/LICENSE +28 -0
- data/README.adoc +2811 -0
- data/Rakefile +156 -0
- data/TODO.bug-fixes/01-cff-expert-charsets.md +27 -0
- data/TODO.bug-fixes/02-cff2-subroutine-stubs.md +32 -0
- data/TODO.bug-fixes/03-variation-subsetter-placeholders.md +42 -0
- data/TODO.bug-fixes/04-ufo-image-compile-roundtrip.md +28 -0
- data/TODO.bug-fixes/05-stale-cff-comment.md +18 -0
- data/TODO.bug-fixes/06-instance-woff2-output.md +24 -0
- data/TODO.bug-fixes/07-encapsulation-violations.md +38 -0
- data/TODO.bug-fixes/08-respond-to-violations.md +25 -0
- data/TODO.bug-fixes/09-type1-cff-seac-expansion.md +22 -0
- data/TODO.bug-fixes/10-ttf-type1-composite-glyphs.md +23 -0
- data/TODO.bug-fixes/11-remaining-respond-to.md +25 -0
- data/TODO.bug-fixes/12-type1-generators-duck-typing.md +80 -0
- data/TODO.bug-fixes/13-hint-extractor-duck-typing.md +30 -0
- data/TODO.bug-fixes/14-font-interface-type-checks.md +82 -0
- data/TODO.bug-fixes/15-glyph-type-checks-and-simple-glyph-points-bug.md +49 -0
- data/TODO.bug-fixes/16-variation-table-checks.md +31 -0
- data/TODO.bug-fixes/17-ufo-and-stitcher-cleanup.md +32 -0
- data/TODO.bug-fixes/18-generic-value-and-io-checks.md +56 -0
- data/TODO.bug-fixes/19-serialization-migration.md +52 -0
- data/TODO.bug-fixes/20-variation-validator-type-checks.md +29 -0
- data/TODO.bug-fixes/21-xml-builder-send.md +24 -0
- data/TODO.bug-fixes/22-type1-converter-font-info.md +25 -0
- data/TODO.bug-fixes/23-boundary-type-checks.md +31 -0
- data/TODO.bug-fixes/24-validator-dynamic-field-key.md +25 -0
- data/TODO.bug-fixes/25-serialization-migration.md +49 -0
- data/TODO.bug-fixes/26-variation-preserver-spec-migration.md +25 -0
- data/TODO.bug-fixes/27-table-class-registry.md +50 -0
- data/TODO.bug-fixes/28-spec-doubles-cleanup.md +40 -0
- data/TODO.bug-fixes/29-strategy-registries.md +30 -0
- data/TODO.bug-fixes/30-eliminate-send-in-specs.md +36 -0
- data/TODO.bug-fixes/README.md +52 -0
- data/TODO.improvements/01-cbdt-cblc-gid-stable-propagation.md +73 -0
- data/TODO.improvements/02-collection-outline-priority.md +48 -0
- data/TODO.improvements/03-fontisan-audit-command.md +219 -0
- data/TODO.improvements/04-ufo-composite-glyph-encoding.md +46 -0
- data/TODO.improvements/05-otf-compiler-real-cff.md +63 -0
- data/TODO.improvements/06-cff2-blend-vsindex-operators.md +51 -0
- data/TODO.improvements/07-cpal-v1-header-fields.md +71 -0
- data/TODO.improvements/08-cff-standard-string-table.md +52 -0
- data/TODO.improvements/09-type1-seac-expansion.md +57 -0
- data/TODO.improvements/10-ufo-image-set-feature-writers.md +71 -0
- data/TODO.improvements/11-kern-groups-plist.md +49 -0
- data/TODO.improvements/12-cbdt-fixture-bindata-conversion.md +68 -0
- data/TODO.improvements/13-split-octokit-fetcher.md +45 -0
- data/TODO.improvements/14-rubocop-baseline-chip.md +62 -0
- data/TODO.improvements/15-cff-cff2-subsetter-strategy.md +78 -0
- data/TODO.improvements/README.md +58 -0
- data/benchmark/baseline.json +5 -0
- data/benchmark/ci_gate.rb +217 -0
- data/benchmark/compile_benchmark.rb +78 -0
- data/benchmark/corpus/harness.rb +175 -0
- data/benchmark/corpus/ops.rb +150 -0
- data/benchmark/corpus/run.rb +182 -0
- data/benchmark/corpus/scan_child.rb +8 -0
- data/benchmark/corpus/tiers.rb +176 -0
- data/benchmark/tier_baseline.json +12 -0
- data/benchmark/variation_quick_bench.rb +47 -0
- data/build_mingw32_stub.rb +15 -0
- data/docs/.gitignore +17 -0
- data/docs/.vitepress/config.ts +373 -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 +628 -0
- data/docs/AFDKO_MIGRATION.adoc +175 -0
- data/docs/APPLE_LEGACY_FONTS.adoc +173 -0
- data/docs/CFF2_SUPPORT.adoc +184 -0
- data/docs/COLLECTION_VALIDATION.adoc +204 -0
- data/docs/COLOR_FONTS.adoc +127 -0
- data/docs/CONVERSION_GUIDE.adoc +656 -0
- data/docs/EXTRACT_TTC_MIGRATION.md +549 -0
- data/docs/FEATURE_PARITY.adoc +263 -0
- data/docs/FONT_HINTING.adoc +570 -0
- data/docs/STITCHER_GUIDE.adoc +436 -0
- data/docs/SVG_TO_GLYF.adoc +118 -0
- data/docs/TTX.adoc +176 -0
- data/docs/TYPE1_FONTS.adoc +445 -0
- data/docs/UFO_COMPILATION.adoc +397 -0
- data/docs/VALIDATION.adoc +254 -0
- data/docs/VARIABLE_FONT_OPERATIONS.adoc +599 -0
- data/docs/WOFF_WOFF2_FORMATS.adoc +220 -0
- data/docs/api/conversion-options.md +164 -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 +117 -0
- data/docs/api/font-writer.md +103 -0
- data/docs/api/index.md +79 -0
- data/docs/api/layer.md +89 -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 +148 -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 +232 -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 +58 -0
- data/docs/cli/tables.md +84 -0
- data/docs/cli/unicode.md +101 -0
- data/docs/cli/validate-collection.md +95 -0
- data/docs/cli/validate.md +56 -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 +149 -0
- data/docs/guide/cli/validate.md +139 -0
- data/docs/guide/color-fonts/bitmaps.md +194 -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 +280 -0
- data/docs/guide/conversion/ttf-otf.md +184 -0
- data/docs/guide/conversion/type1.md +208 -0
- data/docs/guide/conversion/web.md +299 -0
- data/docs/guide/conversion.md +40 -0
- data/docs/guide/engines.md +117 -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 +139 -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 +61 -0
- data/docs/index.md +136 -0
- data/docs/lychee.toml +41 -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/robots.txt +4 -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/docs/reference-facade.md +130 -0
- data/docs/scripts/post-build.mjs +81 -0
- data/exe/fontisan +7 -0
- data/lib/fontisan/audit/check.rb +47 -0
- data/lib/fontisan/audit/check_registry.rb +77 -0
- data/lib/fontisan/audit/checks/cff_table_check.rb +87 -0
- data/lib/fontisan/audit/checks/cmap_check.rb +256 -0
- data/lib/fontisan/audit/checks/collection_integrity_check.rb +102 -0
- data/lib/fontisan/audit/checks/format_round_trip_check.rb +150 -0
- data/lib/fontisan/audit/checks/glyf_table_check.rb +115 -0
- data/lib/fontisan/audit/checks/glyph_name_check.rb +107 -0
- data/lib/fontisan/audit/checks/head_check.rb +96 -0
- data/lib/fontisan/audit/checks/hhea_check.rb +68 -0
- data/lib/fontisan/audit/checks/hinting_check.rb +163 -0
- data/lib/fontisan/audit/checks/kern_check.rb +47 -0
- data/lib/fontisan/audit/checks/layout_table_check.rb +70 -0
- data/lib/fontisan/audit/checks/maxp_check.rb +85 -0
- data/lib/fontisan/audit/checks/name_table_check.rb +78 -0
- data/lib/fontisan/audit/checks/naming_consistency_check.rb +102 -0
- data/lib/fontisan/audit/checks/opentype_conformance_check.rb +108 -0
- data/lib/fontisan/audit/checks/os2_check.rb +117 -0
- data/lib/fontisan/audit/checks/ots_compatibility_check.rb +191 -0
- data/lib/fontisan/audit/checks/post_check.rb +75 -0
- data/lib/fontisan/audit/checks/table_directory_check.rb +157 -0
- data/lib/fontisan/audit/checks/variable_font_check.rb +151 -0
- data/lib/fontisan/audit/checks/woff2_validation_check.rb +140 -0
- data/lib/fontisan/audit/checks.rb +42 -0
- data/lib/fontisan/audit.rb +20 -0
- data/lib/fontisan/base_collection.rb +312 -0
- data/lib/fontisan/binary/base_record.rb +82 -0
- data/lib/fontisan/binary/structures.rb +82 -0
- data/lib/fontisan/binary.rb +11 -0
- data/lib/fontisan/byte_ops.rb +314 -0
- data/lib/fontisan/cli.rb +1111 -0
- data/lib/fontisan/collection/builder.rb +336 -0
- data/lib/fontisan/collection/dfont_builder.rb +305 -0
- data/lib/fontisan/collection/offset_calculator.rb +229 -0
- data/lib/fontisan/collection/reader/stats.rb +23 -0
- data/lib/fontisan/collection/reader.rb +90 -0
- data/lib/fontisan/collection/shared_logic.rb +52 -0
- data/lib/fontisan/collection/table_analyzer.rb +289 -0
- data/lib/fontisan/collection/table_deduplicator.rb +317 -0
- data/lib/fontisan/collection/writer.rb +289 -0
- data/lib/fontisan/collection.rb +16 -0
- data/lib/fontisan/commands/audit_command.rb +288 -0
- data/lib/fontisan/commands/base_command.rb +88 -0
- data/lib/fontisan/commands/convert_command.rb +506 -0
- data/lib/fontisan/commands/dump_table_command.rb +68 -0
- data/lib/fontisan/commands/export_command.rb +157 -0
- data/lib/fontisan/commands/features_command.rb +90 -0
- data/lib/fontisan/commands/glyphs_command.rb +50 -0
- data/lib/fontisan/commands/info_command.rb +447 -0
- data/lib/fontisan/commands/instance_command.rb +357 -0
- data/lib/fontisan/commands/ls_command.rb +107 -0
- data/lib/fontisan/commands/multi_format_output.rb +64 -0
- data/lib/fontisan/commands/optical_size_command.rb +38 -0
- data/lib/fontisan/commands/pack_command.rb +344 -0
- data/lib/fontisan/commands/scripts_command.rb +56 -0
- data/lib/fontisan/commands/subset_command.rb +285 -0
- data/lib/fontisan/commands/tables_command.rb +52 -0
- data/lib/fontisan/commands/unicode_command.rb +73 -0
- data/lib/fontisan/commands/unpack_command.rb +387 -0
- data/lib/fontisan/commands/validate_collection_command.rb +127 -0
- data/lib/fontisan/commands/validate_command.rb +305 -0
- data/lib/fontisan/commands/variable_command.rb +87 -0
- data/lib/fontisan/commands.rb +30 -0
- data/lib/fontisan/config/collection_settings.yml +56 -0
- data/lib/fontisan/config/conversion_matrix.yml +626 -0
- data/lib/fontisan/config/export_settings.yml +66 -0
- data/lib/fontisan/config/features.yml +143 -0
- data/lib/fontisan/config/scripts.yml +42 -0
- data/lib/fontisan/config/subset_profiles.yml +106 -0
- data/lib/fontisan/config/svg_settings.yml +60 -0
- data/lib/fontisan/config/variable_settings.yml +99 -0
- data/lib/fontisan/config/woff2_settings.yml +77 -0
- data/lib/fontisan/constants.rb +219 -0
- data/lib/fontisan/conversion_options.rb +389 -0
- data/lib/fontisan/converters/cff_table_builder.rb +195 -0
- data/lib/fontisan/converters/collection_converter.rb +520 -0
- data/lib/fontisan/converters/conversion_strategy.rb +211 -0
- data/lib/fontisan/converters/format_converter.rb +536 -0
- data/lib/fontisan/converters/glyf_table_builder.rb +61 -0
- data/lib/fontisan/converters/outline_converter.rb +720 -0
- data/lib/fontisan/converters/outline_extraction.rb +88 -0
- data/lib/fontisan/converters/outline_optimizer.rb +84 -0
- data/lib/fontisan/converters/svg_generator.rb +236 -0
- data/lib/fontisan/converters/table_copier.rb +107 -0
- data/lib/fontisan/converters/type1_converter.rb +1201 -0
- data/lib/fontisan/converters/woff2_encoder.rb +520 -0
- data/lib/fontisan/converters/woff_writer.rb +358 -0
- data/lib/fontisan/converters.rb +21 -0
- data/lib/fontisan/dfont_collection.rb +288 -0
- data/lib/fontisan/engine.rb +393 -0
- data/lib/fontisan/error.rb +281 -0
- data/lib/fontisan/export/exporter.rb +255 -0
- data/lib/fontisan/export/table_serializer.rb +140 -0
- data/lib/fontisan/export/transformers/font_to_ttx.rb +163 -0
- data/lib/fontisan/export/transformers/head_transformer.rb +94 -0
- data/lib/fontisan/export/transformers/hhea_transformer.rb +57 -0
- data/lib/fontisan/export/transformers/maxp_transformer.rb +61 -0
- data/lib/fontisan/export/transformers/name_transformer.rb +61 -0
- data/lib/fontisan/export/transformers/os2_transformer.rb +119 -0
- data/lib/fontisan/export/transformers/post_transformer.rb +49 -0
- data/lib/fontisan/export/transformers.rb +17 -0
- data/lib/fontisan/export/ttx_generator.rb +526 -0
- data/lib/fontisan/export/ttx_parser.rb +300 -0
- data/lib/fontisan/export.rb +13 -0
- data/lib/fontisan/ffi/client.rb +123 -0
- data/lib/fontisan/ffi/darwin-arm64/libfontisan_cdylib.dylib +0 -0
- data/lib/fontisan/ffi/darwin-x86_64/libfontisan_cdylib.dylib +0 -0
- data/lib/fontisan/ffi/linux-x86_64/libfontisan_cdylib.so +0 -0
- data/lib/fontisan/ffi/windows-x86_64/fontisan_cdylib.dll +0 -0
- data/lib/fontisan/ffi.rb +387 -0
- data/lib/fontisan/ffi_platform.rb +24 -0
- data/lib/fontisan/font_loader.rb +315 -0
- data/lib/fontisan/font_writer.rb +309 -0
- data/lib/fontisan/formatters/text_formatter.rb +517 -0
- data/lib/fontisan/formatters.rb +9 -0
- data/lib/fontisan/glyph_accessor.rb +525 -0
- data/lib/fontisan/hints/hint_converter.rb +309 -0
- data/lib/fontisan/hints/hint_validator.rb +287 -0
- data/lib/fontisan/hints/postscript_hint_applier.rb +255 -0
- data/lib/fontisan/hints/postscript_hint_extractor.rb +347 -0
- data/lib/fontisan/hints/truetype_hint_applier.rb +117 -0
- data/lib/fontisan/hints/truetype_hint_extractor.rb +283 -0
- data/lib/fontisan/hints/truetype_instruction_analyzer.rb +268 -0
- data/lib/fontisan/hints/truetype_instruction_generator.rb +266 -0
- data/lib/fontisan/hints.rb +19 -0
- data/lib/fontisan/loading_modes.rb +113 -0
- data/lib/fontisan/metrics_calculator.rb +275 -0
- data/lib/fontisan/models/all_scripts_features_info.rb +20 -0
- data/lib/fontisan/models/audit_report.rb +196 -0
- data/lib/fontisan/models/bitmap_glyph.rb +123 -0
- data/lib/fontisan/models/bitmap_strike.rb +94 -0
- data/lib/fontisan/models/collection_brief_info.rb +36 -0
- data/lib/fontisan/models/collection_font_summary.rb +52 -0
- data/lib/fontisan/models/collection_info.rb +79 -0
- data/lib/fontisan/models/collection_list_info.rb +36 -0
- data/lib/fontisan/models/collection_validation_report.rb +102 -0
- data/lib/fontisan/models/color_glyph.rb +56 -0
- data/lib/fontisan/models/color_layer.rb +53 -0
- data/lib/fontisan/models/color_palette.rb +60 -0
- data/lib/fontisan/models/features_info.rb +42 -0
- data/lib/fontisan/models/font_export.rb +158 -0
- data/lib/fontisan/models/font_info.rb +98 -0
- data/lib/fontisan/models/font_report.rb +23 -0
- data/lib/fontisan/models/font_summary.rb +48 -0
- data/lib/fontisan/models/glyph_info.rb +26 -0
- data/lib/fontisan/models/glyph_outline.rb +343 -0
- data/lib/fontisan/models/hint.rb +404 -0
- data/lib/fontisan/models/optical_size_info.rb +33 -0
- data/lib/fontisan/models/outline.rb +667 -0
- data/lib/fontisan/models/scripts_info.rb +39 -0
- data/lib/fontisan/models/svg_glyph.rb +89 -0
- data/lib/fontisan/models/table_info.rb +55 -0
- data/lib/fontisan/models/table_sharing_info.rb +40 -0
- data/lib/fontisan/models/ttx/glyph_order.rb +31 -0
- data/lib/fontisan/models/ttx/tables/binary_table.rb +67 -0
- data/lib/fontisan/models/ttx/tables/head_table.rb +74 -0
- data/lib/fontisan/models/ttx/tables/hhea_table.rb +74 -0
- data/lib/fontisan/models/ttx/tables/maxp_table.rb +55 -0
- data/lib/fontisan/models/ttx/tables/name_table.rb +45 -0
- data/lib/fontisan/models/ttx/tables/os2_table.rb +157 -0
- data/lib/fontisan/models/ttx/tables/post_table.rb +50 -0
- data/lib/fontisan/models/ttx/tables.rb +21 -0
- data/lib/fontisan/models/ttx/ttfont.rb +41 -0
- data/lib/fontisan/models/ttx.rb +14 -0
- data/lib/fontisan/models/unicode_mappings.rb +42 -0
- data/lib/fontisan/models/validation_report.rb +435 -0
- data/lib/fontisan/models/variable_font_info.rb +82 -0
- data/lib/fontisan/models.rb +49 -0
- data/lib/fontisan/native.rb +235 -0
- data/lib/fontisan/open_type_collection.rb +49 -0
- data/lib/fontisan/open_type_font.rb +161 -0
- data/lib/fontisan/open_type_font_extensions.rb +54 -0
- data/lib/fontisan/optimizers/charstring_rewriter.rb +172 -0
- data/lib/fontisan/optimizers/pattern_analyzer.rb +310 -0
- data/lib/fontisan/optimizers/stack_tracker.rb +246 -0
- data/lib/fontisan/optimizers/subroutine_builder.rb +135 -0
- data/lib/fontisan/optimizers/subroutine_generator.rb +207 -0
- data/lib/fontisan/optimizers/subroutine_optimizer.rb +114 -0
- data/lib/fontisan/optimizers.rb +14 -0
- data/lib/fontisan/outline_extractor.rb +417 -0
- data/lib/fontisan/output_guard.rb +40 -0
- data/lib/fontisan/parsers/dfont_parser.rb +191 -0
- data/lib/fontisan/parsers/tag.rb +77 -0
- data/lib/fontisan/parsers.rb +10 -0
- data/lib/fontisan/pipeline/format_detector.rb +176 -0
- data/lib/fontisan/pipeline/output_writer.rb +161 -0
- data/lib/fontisan/pipeline/strategies/base_strategy.rb +75 -0
- data/lib/fontisan/pipeline/strategies/instance_strategy.rb +89 -0
- data/lib/fontisan/pipeline/strategies/named_strategy.rb +114 -0
- data/lib/fontisan/pipeline/strategies/preserve_strategy.rb +54 -0
- data/lib/fontisan/pipeline/strategies.rb +16 -0
- data/lib/fontisan/pipeline/transformation_pipeline.rb +407 -0
- data/lib/fontisan/pipeline/variation_resolver.rb +158 -0
- data/lib/fontisan/pipeline.rb +14 -0
- data/lib/fontisan/reference/table_digests.rb +251 -0
- data/lib/fontisan/reference.rb +663 -0
- data/lib/fontisan/scan.rb +372 -0
- data/lib/fontisan/sfnt_builder.rb +66 -0
- data/lib/fontisan/sfnt_directory.rb +41 -0
- data/lib/fontisan/sfnt_font.rb +749 -0
- data/lib/fontisan/sfnt_source.rb +28 -0
- data/lib/fontisan/sfnt_table.rb +260 -0
- data/lib/fontisan/stitcher/cbdt_propagator.rb +212 -0
- data/lib/fontisan/stitcher/collection_result.rb +19 -0
- data/lib/fontisan/stitcher/deduplicator.rb +47 -0
- data/lib/fontisan/stitcher/format_metadata.rb +51 -0
- data/lib/fontisan/stitcher/glyph_cloner.rb +41 -0
- data/lib/fontisan/stitcher/glyph_copier.rb +110 -0
- data/lib/fontisan/stitcher/glyph_limit.rb +53 -0
- data/lib/fontisan/stitcher/glyph_signature.rb +51 -0
- data/lib/fontisan/stitcher/partition_strategy/base.rb +52 -0
- data/lib/fontisan/stitcher/partition_strategy/blueprint.rb +24 -0
- data/lib/fontisan/stitcher/partition_strategy/by_block.rb +430 -0
- data/lib/fontisan/stitcher/partition_strategy/by_plane.rb +161 -0
- data/lib/fontisan/stitcher/partition_strategy/by_script.rb +309 -0
- data/lib/fontisan/stitcher/partition_strategy/partition.rb +24 -0
- data/lib/fontisan/stitcher/partition_strategy.rb +24 -0
- data/lib/fontisan/stitcher/selector/codepoints.rb +29 -0
- data/lib/fontisan/stitcher/selector/gid.rb +25 -0
- data/lib/fontisan/stitcher/selector/range.rb +30 -0
- data/lib/fontisan/stitcher/selector.rb +26 -0
- data/lib/fontisan/stitcher/source.rb +459 -0
- data/lib/fontisan/stitcher/unique_glyph_name.rb +46 -0
- data/lib/fontisan/stitcher.rb +185 -0
- data/lib/fontisan/stitcher_cli.rb +69 -0
- data/lib/fontisan/subset/builder.rb +263 -0
- data/lib/fontisan/subset/glyph_mapping.rb +222 -0
- data/lib/fontisan/subset/options.rb +142 -0
- data/lib/fontisan/subset/profile.rb +152 -0
- data/lib/fontisan/subset/shared_state.rb +42 -0
- data/lib/fontisan/subset/subset_context.rb +20 -0
- data/lib/fontisan/subset/table_strategy/cbdt.rb +30 -0
- data/lib/fontisan/subset/table_strategy/cblc.rb +27 -0
- data/lib/fontisan/subset/table_strategy/cff.rb +92 -0
- data/lib/fontisan/subset/table_strategy/cff2.rb +391 -0
- data/lib/fontisan/subset/table_strategy/cmap.rb +146 -0
- data/lib/fontisan/subset/table_strategy/color_bitmap_placement.rb +20 -0
- data/lib/fontisan/subset/table_strategy/color_bitmap_strike_plan.rb +45 -0
- data/lib/fontisan/subset/table_strategy/color_bitmap_subset_plan.rb +62 -0
- data/lib/fontisan/subset/table_strategy/color_bitmap_subsetter.rb +182 -0
- data/lib/fontisan/subset/table_strategy/color_bitmap_subtable_plan.rb +59 -0
- data/lib/fontisan/subset/table_strategy/glyf.rb +29 -0
- data/lib/fontisan/subset/table_strategy/glyf_loca_builder.rb +146 -0
- data/lib/fontisan/subset/table_strategy/head.rb +43 -0
- data/lib/fontisan/subset/table_strategy/hhea.rb +67 -0
- data/lib/fontisan/subset/table_strategy/hmtx.rb +52 -0
- data/lib/fontisan/subset/table_strategy/loca.rb +41 -0
- data/lib/fontisan/subset/table_strategy/maxp.rb +23 -0
- data/lib/fontisan/subset/table_strategy/name.rb +19 -0
- data/lib/fontisan/subset/table_strategy/os2.rb +21 -0
- data/lib/fontisan/subset/table_strategy/pass_through.rb +20 -0
- data/lib/fontisan/subset/table_strategy/post.rb +37 -0
- data/lib/fontisan/subset/table_strategy.rb +79 -0
- data/lib/fontisan/subset/table_subsetter.rb +110 -0
- data/lib/fontisan/subset.rb +16 -0
- data/lib/fontisan/svg/font_face_generator.rb +274 -0
- data/lib/fontisan/svg/font_generator.rb +256 -0
- data/lib/fontisan/svg/glyph_generator.rb +201 -0
- data/lib/fontisan/svg/standalone_glyph.rb +132 -0
- data/lib/fontisan/svg/view_box_calculator.rb +137 -0
- data/lib/fontisan/svg.rb +13 -0
- data/lib/fontisan/svg_to_glyf/assembler.rb +174 -0
- data/lib/fontisan/svg_to_glyf/document.rb +102 -0
- data/lib/fontisan/svg_to_glyf/geometry/affine_transform.rb +112 -0
- data/lib/fontisan/svg_to_glyf/geometry/normalizer.rb +62 -0
- data/lib/fontisan/svg_to_glyf/geometry/transform_parser.rb +98 -0
- data/lib/fontisan/svg_to_glyf/geometry.rb +15 -0
- data/lib/fontisan/svg_to_glyf/path/command.rb +18 -0
- data/lib/fontisan/svg_to_glyf/path/contour_builder.rb +140 -0
- data/lib/fontisan/svg_to_glyf/path/parser.rb +98 -0
- data/lib/fontisan/svg_to_glyf/path/state.rb +79 -0
- data/lib/fontisan/svg_to_glyf/path.rb +14 -0
- data/lib/fontisan/svg_to_glyf.rb +62 -0
- data/lib/fontisan/tables/cbdt.rb +113 -0
- data/lib/fontisan/tables/cblc.rb +172 -0
- data/lib/fontisan/tables/cblc_big_glyph_metrics.rb +28 -0
- data/lib/fontisan/tables/cblc_bitmap_size.rb +67 -0
- data/lib/fontisan/tables/cblc_glyph_bitmap_location.rb +28 -0
- data/lib/fontisan/tables/cblc_index_subtable.rb +104 -0
- data/lib/fontisan/tables/cblc_index_subtable_array_entry.rb +20 -0
- data/lib/fontisan/tables/cblc_index_subtable_format_parser.rb +150 -0
- data/lib/fontisan/tables/cblc_index_subtable_header.rb +18 -0
- data/lib/fontisan/tables/cblc_sbit_line_metrics.rb +28 -0
- data/lib/fontisan/tables/cff/cff2_charstring_builder.rb +225 -0
- data/lib/fontisan/tables/cff/cff_glyph.rb +176 -0
- data/lib/fontisan/tables/cff/charset.rb +276 -0
- data/lib/fontisan/tables/cff/charstring.rb +978 -0
- data/lib/fontisan/tables/cff/charstring_builder.rb +356 -0
- data/lib/fontisan/tables/cff/charstring_parser.rb +249 -0
- data/lib/fontisan/tables/cff/charstring_rebuilder.rb +168 -0
- data/lib/fontisan/tables/cff/charstrings_index.rb +159 -0
- data/lib/fontisan/tables/cff/dict.rb +353 -0
- data/lib/fontisan/tables/cff/dict_builder.rb +260 -0
- data/lib/fontisan/tables/cff/encoding.rb +273 -0
- data/lib/fontisan/tables/cff/expert_charsets.rb +85 -0
- data/lib/fontisan/tables/cff/header.rb +100 -0
- data/lib/fontisan/tables/cff/hint_operation_injector.rb +207 -0
- data/lib/fontisan/tables/cff/index.rb +241 -0
- data/lib/fontisan/tables/cff/index_builder.rb +170 -0
- data/lib/fontisan/tables/cff/offset_recalculator.rb +70 -0
- data/lib/fontisan/tables/cff/private_dict.rb +282 -0
- data/lib/fontisan/tables/cff/private_dict_writer.rb +129 -0
- data/lib/fontisan/tables/cff/standard_strings_data.rb +83 -0
- data/lib/fontisan/tables/cff/table_builder.rb +215 -0
- data/lib/fontisan/tables/cff/top_dict.rb +234 -0
- data/lib/fontisan/tables/cff.rb +497 -0
- data/lib/fontisan/tables/cff2/blend_operator.rb +240 -0
- data/lib/fontisan/tables/cff2/charstring_parser.rb +624 -0
- data/lib/fontisan/tables/cff2/dict_encoder.rb +94 -0
- data/lib/fontisan/tables/cff2/fd_select.rb +142 -0
- data/lib/fontisan/tables/cff2/header.rb +34 -0
- data/lib/fontisan/tables/cff2/index.rb +155 -0
- data/lib/fontisan/tables/cff2/index_builder.rb +80 -0
- data/lib/fontisan/tables/cff2/operand_stack.rb +232 -0
- data/lib/fontisan/tables/cff2/private_dict_blend_handler.rb +247 -0
- data/lib/fontisan/tables/cff2/region_matcher.rb +200 -0
- data/lib/fontisan/tables/cff2/table_builder.rb +567 -0
- data/lib/fontisan/tables/cff2/table_reader.rb +418 -0
- data/lib/fontisan/tables/cff2/variation_data_extractor.rb +212 -0
- data/lib/fontisan/tables/cff2.rb +353 -0
- data/lib/fontisan/tables/cmap.rb +399 -0
- data/lib/fontisan/tables/cmap_table.rb +228 -0
- data/lib/fontisan/tables/colr.rb +290 -0
- data/lib/fontisan/tables/cpal.rb +381 -0
- data/lib/fontisan/tables/cvar.rb +204 -0
- data/lib/fontisan/tables/fvar.rb +159 -0
- data/lib/fontisan/tables/glyf/compound_glyph.rb +482 -0
- data/lib/fontisan/tables/glyf/compound_glyph_resolver.rb +135 -0
- data/lib/fontisan/tables/glyf/curve_converter.rb +349 -0
- data/lib/fontisan/tables/glyf/glyph_builder.rb +468 -0
- data/lib/fontisan/tables/glyf/simple_glyph.rb +391 -0
- data/lib/fontisan/tables/glyf.rb +347 -0
- data/lib/fontisan/tables/glyf_table.rb +252 -0
- data/lib/fontisan/tables/gpos/glyph_filter.rb +87 -0
- data/lib/fontisan/tables/gpos/kerning_pairs.rb +215 -0
- data/lib/fontisan/tables/gpos/pair_position.rb +274 -0
- data/lib/fontisan/tables/gpos.rb +139 -0
- data/lib/fontisan/tables/gsub.rb +116 -0
- data/lib/fontisan/tables/gvar.rb +232 -0
- data/lib/fontisan/tables/head.rb +208 -0
- data/lib/fontisan/tables/head_table.rb +108 -0
- data/lib/fontisan/tables/hhea.rb +199 -0
- data/lib/fontisan/tables/hhea_table.rb +252 -0
- data/lib/fontisan/tables/hmtx.rb +281 -0
- data/lib/fontisan/tables/hmtx_table.rb +188 -0
- data/lib/fontisan/tables/hvar.rb +192 -0
- data/lib/fontisan/tables/layout_common.rb +245 -0
- data/lib/fontisan/tables/loca.rb +323 -0
- data/lib/fontisan/tables/loca_table.rb +209 -0
- data/lib/fontisan/tables/maxp.rb +253 -0
- data/lib/fontisan/tables/maxp_table.rb +255 -0
- data/lib/fontisan/tables/mvar.rb +185 -0
- data/lib/fontisan/tables/name.rb +340 -0
- data/lib/fontisan/tables/name_table.rb +173 -0
- data/lib/fontisan/tables/os2.rb +291 -0
- data/lib/fontisan/tables/os2_table.rb +326 -0
- data/lib/fontisan/tables/post.rb +206 -0
- data/lib/fontisan/tables/post_table.rb +180 -0
- data/lib/fontisan/tables/registry.rb +71 -0
- data/lib/fontisan/tables/sbix.rb +379 -0
- data/lib/fontisan/tables/svg.rb +300 -0
- data/lib/fontisan/tables/variation_common.rb +345 -0
- data/lib/fontisan/tables/vvar.rb +234 -0
- data/lib/fontisan/tables.rb +69 -0
- data/lib/fontisan/true_type_collection.rb +160 -0
- data/lib/fontisan/true_type_font.rb +80 -0
- data/lib/fontisan/true_type_font_extensions.rb +54 -0
- data/lib/fontisan/type1/afm_generator.rb +379 -0
- data/lib/fontisan/type1/afm_parser.rb +299 -0
- data/lib/fontisan/type1/agl.rb +456 -0
- data/lib/fontisan/type1/cff_to_type1_converter.rb +307 -0
- data/lib/fontisan/type1/charstring_converter.rb +238 -0
- data/lib/fontisan/type1/charstrings.rb +441 -0
- data/lib/fontisan/type1/conversion_options.rb +242 -0
- data/lib/fontisan/type1/decryptor.rb +183 -0
- data/lib/fontisan/type1/encodings.rb +695 -0
- data/lib/fontisan/type1/font_dictionary.rb +576 -0
- data/lib/fontisan/type1/generator.rb +217 -0
- data/lib/fontisan/type1/inf_generator.rb +307 -0
- data/lib/fontisan/type1/pfa_generator.rb +376 -0
- data/lib/fontisan/type1/pfa_parser.rb +159 -0
- data/lib/fontisan/type1/pfb_generator.rb +321 -0
- data/lib/fontisan/type1/pfb_parser.rb +166 -0
- data/lib/fontisan/type1/pfm_generator.rb +589 -0
- data/lib/fontisan/type1/pfm_parser.rb +433 -0
- data/lib/fontisan/type1/private_dict.rb +363 -0
- data/lib/fontisan/type1/seac_expander.rb +517 -0
- data/lib/fontisan/type1/ttf_to_type1_converter.rb +389 -0
- data/lib/fontisan/type1/upm_scaler.rb +118 -0
- data/lib/fontisan/type1.rb +48 -0
- data/lib/fontisan/type1_font.rb +347 -0
- data/lib/fontisan/ufo/anchor.rb +17 -0
- data/lib/fontisan/ufo/bounds.rb +91 -0
- data/lib/fontisan/ufo/cli.rb +105 -0
- data/lib/fontisan/ufo/compile/avar.rb +46 -0
- data/lib/fontisan/ufo/compile/base_compiler.rb +162 -0
- data/lib/fontisan/ufo/compile/cbdt_cblc.rb +104 -0
- data/lib/fontisan/ufo/compile/cff.rb +229 -0
- data/lib/fontisan/ufo/compile/cff2.rb +323 -0
- data/lib/fontisan/ufo/compile/cff2_subroutines.rb +39 -0
- data/lib/fontisan/ufo/compile/cmap.rb +143 -0
- data/lib/fontisan/ufo/compile/colr.rb +80 -0
- data/lib/fontisan/ufo/compile/cpal.rb +62 -0
- data/lib/fontisan/ufo/compile/feature_compiler.rb +161 -0
- data/lib/fontisan/ufo/compile/feature_writers/base.rb +56 -0
- data/lib/fontisan/ufo/compile/feature_writers/curs.rb +72 -0
- data/lib/fontisan/ufo/compile/feature_writers/gdef.rb +92 -0
- data/lib/fontisan/ufo/compile/feature_writers/kern.rb +50 -0
- data/lib/fontisan/ufo/compile/feature_writers/kern2.rb +57 -0
- data/lib/fontisan/ufo/compile/feature_writers/mark.rb +45 -0
- data/lib/fontisan/ufo/compile/feature_writers/mark_family_base.rb +124 -0
- data/lib/fontisan/ufo/compile/feature_writers/mkmk.rb +53 -0
- data/lib/fontisan/ufo/compile/feature_writers.rb +38 -0
- data/lib/fontisan/ufo/compile/filters/cubic_to_quadratic.rb +176 -0
- data/lib/fontisan/ufo/compile/filters/decompose_components.rb +33 -0
- data/lib/fontisan/ufo/compile/filters/flatten_components.rb +22 -0
- data/lib/fontisan/ufo/compile/filters/propagate_anchors.rb +102 -0
- data/lib/fontisan/ufo/compile/filters/remove_overlaps.rb +95 -0
- data/lib/fontisan/ufo/compile/filters/reverse_contour_direction.rb +27 -0
- data/lib/fontisan/ufo/compile/filters/sort_contours.rb +69 -0
- data/lib/fontisan/ufo/compile/filters/transformations.rb +113 -0
- data/lib/fontisan/ufo/compile/filters.rb +69 -0
- data/lib/fontisan/ufo/compile/fvar.rb +113 -0
- data/lib/fontisan/ufo/compile/glyf_loca.rb +206 -0
- data/lib/fontisan/ufo/compile/gpos.rb +248 -0
- data/lib/fontisan/ufo/compile/gsub.rb +267 -0
- data/lib/fontisan/ufo/compile/gvar.rb +225 -0
- data/lib/fontisan/ufo/compile/head.rb +97 -0
- data/lib/fontisan/ufo/compile/hhea.rb +57 -0
- data/lib/fontisan/ufo/compile/hmtx.rb +38 -0
- data/lib/fontisan/ufo/compile/hvar.rb +42 -0
- data/lib/fontisan/ufo/compile/item_variation_store.rb +100 -0
- data/lib/fontisan/ufo/compile/math.rb +143 -0
- data/lib/fontisan/ufo/compile/maxp.rb +57 -0
- data/lib/fontisan/ufo/compile/meta.rb +51 -0
- data/lib/fontisan/ufo/compile/mvar.rb +59 -0
- data/lib/fontisan/ufo/compile/name.rb +81 -0
- data/lib/fontisan/ufo/compile/os2.rb +81 -0
- data/lib/fontisan/ufo/compile/otf2_compiler.rb +40 -0
- data/lib/fontisan/ufo/compile/otf_compiler.rb +34 -0
- data/lib/fontisan/ufo/compile/post.rb +32 -0
- data/lib/fontisan/ufo/compile/sbix.rb +100 -0
- data/lib/fontisan/ufo/compile/stat.rb +106 -0
- data/lib/fontisan/ufo/compile/svg_table.rb +60 -0
- data/lib/fontisan/ufo/compile/ttf_compiler.rb +75 -0
- data/lib/fontisan/ufo/compile/variable_otf.rb +84 -0
- data/lib/fontisan/ufo/compile/variable_ttf.rb +161 -0
- data/lib/fontisan/ufo/compile.rb +72 -0
- data/lib/fontisan/ufo/component.rb +18 -0
- data/lib/fontisan/ufo/contour.rb +34 -0
- data/lib/fontisan/ufo/convert/from_bin_data.rb +366 -0
- data/lib/fontisan/ufo/convert/to_dfont.rb +45 -0
- data/lib/fontisan/ufo/convert/to_otc.rb +40 -0
- data/lib/fontisan/ufo/convert/to_otf.rb +18 -0
- data/lib/fontisan/ufo/convert/to_otf2.rb +20 -0
- data/lib/fontisan/ufo/convert/to_postscript.rb +64 -0
- data/lib/fontisan/ufo/convert/to_ttc.rb +35 -0
- data/lib/fontisan/ufo/convert/to_ttf.rb +21 -0
- data/lib/fontisan/ufo/convert/to_woff.rb +61 -0
- data/lib/fontisan/ufo/convert/to_woff2.rb +50 -0
- data/lib/fontisan/ufo/convert.rb +84 -0
- data/lib/fontisan/ufo/data_set.rb +21 -0
- data/lib/fontisan/ufo/features.rb +17 -0
- data/lib/fontisan/ufo/font.rb +63 -0
- data/lib/fontisan/ufo/glyph.rb +445 -0
- data/lib/fontisan/ufo/glyph_exists_error.rb +23 -0
- data/lib/fontisan/ufo/groups.rb +45 -0
- data/lib/fontisan/ufo/guideline.rb +19 -0
- data/lib/fontisan/ufo/image.rb +29 -0
- data/lib/fontisan/ufo/image_set.rb +99 -0
- data/lib/fontisan/ufo/info.rb +133 -0
- data/lib/fontisan/ufo/kerning.rb +32 -0
- data/lib/fontisan/ufo/layer.rb +78 -0
- data/lib/fontisan/ufo/layer_set.rb +37 -0
- data/lib/fontisan/ufo/lib.rb +24 -0
- data/lib/fontisan/ufo/plist.rb +123 -0
- data/lib/fontisan/ufo/point.rb +32 -0
- data/lib/fontisan/ufo/reader.rb +163 -0
- data/lib/fontisan/ufo/transformation.rb +50 -0
- data/lib/fontisan/ufo/writer.rb +123 -0
- data/lib/fontisan/ufo.rb +47 -0
- data/lib/fontisan/unicode/plane.rb +44 -0
- data/lib/fontisan/unicode.rb +17 -0
- data/lib/fontisan/utilities/brotli_wrapper.rb +177 -0
- data/lib/fontisan/utilities/checksum_calculator.rb +104 -0
- data/lib/fontisan/utilities/padding.rb +61 -0
- data/lib/fontisan/utilities.rb +11 -0
- data/lib/fontisan/utils/thread_pool.rb +134 -0
- data/lib/fontisan/utils.rb +10 -0
- data/lib/fontisan/validation/collection_validator.rb +265 -0
- data/lib/fontisan/validation.rb +9 -0
- data/lib/fontisan/validators/basic_validator.rb +73 -0
- data/lib/fontisan/validators/font_book_validator.rb +107 -0
- data/lib/fontisan/validators/opentype_validator.rb +118 -0
- data/lib/fontisan/validators/profile_loader.rb +134 -0
- data/lib/fontisan/validators/validator.rb +494 -0
- data/lib/fontisan/validators/web_font_validator.rb +95 -0
- data/lib/fontisan/validators.rb +14 -0
- data/lib/fontisan/variable/axis_normalizer.rb +215 -0
- data/lib/fontisan/variable/delta_applicator.rb +302 -0
- data/lib/fontisan/variable/glyph_delta_processor.rb +218 -0
- data/lib/fontisan/variable/instancer.rb +172 -0
- data/lib/fontisan/variable/metric_delta_processor.rb +282 -0
- data/lib/fontisan/variable/region_matcher.rb +208 -0
- data/lib/fontisan/variable/static_font_builder.rb +209 -0
- data/lib/fontisan/variable/table_updater.rb +219 -0
- data/lib/fontisan/variable.rb +16 -0
- data/lib/fontisan/variation/blend_applier.rb +197 -0
- data/lib/fontisan/variation/cache.rb +299 -0
- data/lib/fontisan/variation/cache_key_builder.rb +162 -0
- data/lib/fontisan/variation/converter.rb +373 -0
- data/lib/fontisan/variation/data_extractor.rb +84 -0
- data/lib/fontisan/variation/delta_applier.rb +262 -0
- data/lib/fontisan/variation/delta_parser.rb +228 -0
- data/lib/fontisan/variation/inspector.rb +275 -0
- data/lib/fontisan/variation/instance_font_wrapper.rb +41 -0
- data/lib/fontisan/variation/instance_generator.rb +122 -0
- data/lib/fontisan/variation/instance_writer.rb +360 -0
- data/lib/fontisan/variation/instancing/axis_space.rb +136 -0
- data/lib/fontisan/variation/instancing/glyph_outline.rb +204 -0
- data/lib/fontisan/variation/instancing/gvar_reader.rb +146 -0
- data/lib/fontisan/variation/instancing/item_variation_store.rb +92 -0
- data/lib/fontisan/variation/instancing/name_rewriter.rb +90 -0
- data/lib/fontisan/variation/instancing/true_type_instancer.rb +326 -0
- data/lib/fontisan/variation/instancing.rb +20 -0
- data/lib/fontisan/variation/interpolator.rb +231 -0
- data/lib/fontisan/variation/metrics_adjuster.rb +309 -0
- data/lib/fontisan/variation/optimizer.rb +417 -0
- data/lib/fontisan/variation/parallel_generator.rb +147 -0
- data/lib/fontisan/variation/region_matcher.rb +221 -0
- data/lib/fontisan/variation/subsetter.rb +400 -0
- data/lib/fontisan/variation/table_accessor.rb +105 -0
- data/lib/fontisan/variation/tuple_variation_header.rb +49 -0
- data/lib/fontisan/variation/validator.rb +336 -0
- data/lib/fontisan/variation/variable_svg_generator.rb +235 -0
- data/lib/fontisan/variation/variation_context.rb +208 -0
- data/lib/fontisan/variation/variation_preserver.rb +287 -0
- data/lib/fontisan/variation.rb +33 -0
- data/lib/fontisan/version.rb +5 -0
- data/lib/fontisan/version.rb.orig +9 -0
- data/lib/fontisan/woff2/collection_decoder.rb +223 -0
- data/lib/fontisan/woff2/collection_encoder.rb +302 -0
- data/lib/fontisan/woff2/directory.rb +255 -0
- data/lib/fontisan/woff2/encoder_rules.rb +114 -0
- data/lib/fontisan/woff2/glyf_canonicalizer.rb +90 -0
- data/lib/fontisan/woff2/glyf_loca_reconstruct.rb +401 -0
- data/lib/fontisan/woff2/glyf_loca_transform.rb +319 -0
- data/lib/fontisan/woff2/header.rb +101 -0
- data/lib/fontisan/woff2/hmtx_transformer.rb +140 -0
- data/lib/fontisan/woff2/sfnt_checksum.rb +107 -0
- data/lib/fontisan/woff2/table_transformer.rb +575 -0
- data/lib/fontisan/woff2/triplet_codec.rb +181 -0
- data/lib/fontisan/woff2/uint255.rb +101 -0
- data/lib/fontisan/woff2.rb +21 -0
- data/lib/fontisan/woff2_collection.rb +127 -0
- data/lib/fontisan/woff2_font.rb +754 -0
- data/lib/fontisan/woff_container.rb +83 -0
- data/lib/fontisan/woff_font.rb +554 -0
- data/lib/fontisan.rb +299 -0
- data/rakelib/bench.rake +9 -0
- data/rakelib/cdylib.rake +39 -0
- data/rakelib/corpus.rake +272 -0
- data/rakelib/corpus_convert.rake +43 -0
- data/rakelib/corpus_goldens.rake +22 -0
- data/rakelib/corpus_malformed.rake +20 -0
- data/rakelib/corpus_scan.rake +24 -0
- data/rakelib/java.rake +61 -0
- data/rakelib/native.rake +43 -0
- data/scripts/build-woff2.sh +57 -0
- data/scripts/compare_stack_aware.rb +187 -0
- data/scripts/corpus/generate_convert_goldens.rb +478 -0
- data/scripts/corpus/generate_goldens.rb +282 -0
- data/scripts/corpus/generate_malformed_goldens.rb +254 -0
- data/scripts/corpus/generate_scan_goldens.rb +98 -0
- data/scripts/measure_optimization.rb +148 -0
- data/scripts/tier_fallback.rb +228 -0
- data/scripts/tier_smoke.rb +72 -0
- metadata +940 -0
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Fontisan
|
|
4
|
+
module Converters
|
|
5
|
+
# Strategy for converting between TTF and OTF outline formats
|
|
6
|
+
#
|
|
7
|
+
# [`OutlineConverter`](lib/fontisan/converters/outline_converter.rb)
|
|
8
|
+
# handles conversion between TrueType (glyf/loca) and CFF outline formats.
|
|
9
|
+
# This involves:
|
|
10
|
+
# - Extracting glyph outlines from source format
|
|
11
|
+
# - Converting to universal [`Outline`](lib/fontisan/models/outline.rb) model
|
|
12
|
+
# - Building target format tables using specialized builders
|
|
13
|
+
# - Updating related tables (maxp, head)
|
|
14
|
+
# - Preserving all other font tables
|
|
15
|
+
# - Optionally preserving rendering hints
|
|
16
|
+
#
|
|
17
|
+
# **Conversion Details:**
|
|
18
|
+
#
|
|
19
|
+
# TTF → OTF:
|
|
20
|
+
# - Extract glyphs from glyf/loca tables
|
|
21
|
+
# - Convert TrueType quadratic curves to universal format
|
|
22
|
+
# - Build complete CFF table with CharStrings INDEX
|
|
23
|
+
# - Remove glyf/loca tables
|
|
24
|
+
# - Update maxp to version 0.5 (CFF format)
|
|
25
|
+
# - Update head table (clear indexToLocFormat)
|
|
26
|
+
#
|
|
27
|
+
# OTF → TTF:
|
|
28
|
+
# - Extract CharStrings from CFF table
|
|
29
|
+
# - Convert CFF cubic curves to universal format
|
|
30
|
+
# - Build glyf and loca tables
|
|
31
|
+
# - Remove CFF table
|
|
32
|
+
# - Update maxp to version 1.0 (TrueType format)
|
|
33
|
+
# - Update head table (set indexToLocFormat)
|
|
34
|
+
#
|
|
35
|
+
# @example Converting TTF to OTF
|
|
36
|
+
# converter = Fontisan::Converters::OutlineConverter.new
|
|
37
|
+
# otf_font = converter.convert(ttf_font, target_format: :otf)
|
|
38
|
+
#
|
|
39
|
+
# @example Converting with ConversionOptions
|
|
40
|
+
# options = ConversionOptions.recommended(from: :ttf, to: :otf)
|
|
41
|
+
# converter = Fontisan::Converters::OutlineConverter.new
|
|
42
|
+
# otf_font = converter.convert(ttf_font, options: options)
|
|
43
|
+
#
|
|
44
|
+
# @example Converting with hint preservation
|
|
45
|
+
# converter = Fontisan::Converters::OutlineConverter.new
|
|
46
|
+
# otf_font = converter.convert(ttf_font, target_format: :otf, preserve_hints: true)
|
|
47
|
+
class OutlineConverter
|
|
48
|
+
include ConversionStrategy
|
|
49
|
+
include OutlineExtraction
|
|
50
|
+
include CffTableBuilder
|
|
51
|
+
include GlyfTableBuilder
|
|
52
|
+
include OutlineOptimizer
|
|
53
|
+
|
|
54
|
+
# Supported outline formats
|
|
55
|
+
SUPPORTED_FORMATS = %i[ttf otf cff2].freeze
|
|
56
|
+
|
|
57
|
+
# @return [TrueTypeFont, OpenTypeFont] Source font
|
|
58
|
+
attr_reader :font
|
|
59
|
+
|
|
60
|
+
# Initialize converter
|
|
61
|
+
def initialize
|
|
62
|
+
@font = nil
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Convert font between TTF and OTF formats
|
|
66
|
+
#
|
|
67
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
68
|
+
# @param options [Hash] Conversion options
|
|
69
|
+
# @option options [Symbol] :target_format Target format (:ttf or :otf)
|
|
70
|
+
# @option options [Boolean] :optimize_cff Enable CFF subroutine optimization (default: false)
|
|
71
|
+
# @option options [Boolean] :preserve_hints Preserve rendering hints (default: false)
|
|
72
|
+
# @option options [Boolean] :preserve_variations Keep variation data during conversion (default: true)
|
|
73
|
+
# @option options [Boolean] :generate_instance Generate static instance instead of variable font (default: false)
|
|
74
|
+
# @option options [Hash] :instance_coordinates Axis coordinates for instance generation (default: {})
|
|
75
|
+
# @option options [ConversionOptions] :options ConversionOptions object
|
|
76
|
+
# @return [Hash<String, String>] Map of table tags to binary data
|
|
77
|
+
def convert(font, options = {})
|
|
78
|
+
@font = font
|
|
79
|
+
@options = options
|
|
80
|
+
|
|
81
|
+
# Extract ConversionOptions if provided
|
|
82
|
+
conv_options = extract_conversion_options(options)
|
|
83
|
+
|
|
84
|
+
@optimize_cff = options.fetch(:optimize_cff, false)
|
|
85
|
+
@preserve_hints = options.fetch(:preserve_hints,
|
|
86
|
+
conv_options&.generating_option?(
|
|
87
|
+
:hinting_mode, "preserve"
|
|
88
|
+
) || false)
|
|
89
|
+
@preserve_variations = options.fetch(:preserve_variations, true)
|
|
90
|
+
@generate_instance = options.fetch(:generate_instance, false)
|
|
91
|
+
@instance_coordinates = options.fetch(:instance_coordinates, {})
|
|
92
|
+
|
|
93
|
+
target_format = options[:target_format] || conv_options&.to ||
|
|
94
|
+
detect_target_format(font)
|
|
95
|
+
validate(font, target_format)
|
|
96
|
+
|
|
97
|
+
# Apply opening options to source font
|
|
98
|
+
apply_opening_options(font, conv_options) if conv_options
|
|
99
|
+
|
|
100
|
+
source_format = detect_format(font)
|
|
101
|
+
|
|
102
|
+
# Check if we should generate a static instance instead
|
|
103
|
+
if @generate_instance && variable_font?(font)
|
|
104
|
+
return generate_static_instance(font, source_format, target_format)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
case [source_format, target_format]
|
|
108
|
+
when %i[ttf otf]
|
|
109
|
+
convert_ttf_to_otf(font, options)
|
|
110
|
+
when %i[otf ttf]
|
|
111
|
+
convert_otf_to_ttf(font)
|
|
112
|
+
when %i[cff2 ttf]
|
|
113
|
+
# CFF2 to TTF - treat CFF2 similar to OTF for now
|
|
114
|
+
convert_otf_to_ttf(font)
|
|
115
|
+
when %i[ttf cff2]
|
|
116
|
+
# TTF to CFF2 - for variable fonts
|
|
117
|
+
convert_ttf_to_otf(font, options)
|
|
118
|
+
else
|
|
119
|
+
raise Fontisan::Error,
|
|
120
|
+
"Unsupported conversion: #{source_format} → #{target_format}"
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Convert TrueType font to OpenType/CFF
|
|
125
|
+
#
|
|
126
|
+
# @param font [TrueTypeFont] Source font
|
|
127
|
+
# @param options [Hash] Conversion options (currently unused)
|
|
128
|
+
# @return [Hash<String, String>] Target tables
|
|
129
|
+
def convert_ttf_to_otf(font, _options = {})
|
|
130
|
+
# Extract all glyphs from glyf table
|
|
131
|
+
outlines = extract_ttf_outlines(font)
|
|
132
|
+
|
|
133
|
+
# Extract hints if preservation is enabled
|
|
134
|
+
hints_per_glyph = @preserve_hints ? extract_ttf_hints(font) : {}
|
|
135
|
+
|
|
136
|
+
# Build CharStrings from outlines
|
|
137
|
+
charstrings = outlines.map do |outline|
|
|
138
|
+
builder = Tables::Cff::CharStringBuilder.new
|
|
139
|
+
if outline.empty?
|
|
140
|
+
builder.build_empty
|
|
141
|
+
else
|
|
142
|
+
builder.build(outline)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Apply subroutine optimization if enabled
|
|
147
|
+
local_subrs = []
|
|
148
|
+
if @optimize_cff
|
|
149
|
+
begin
|
|
150
|
+
charstrings, local_subrs = optimize_charstrings(charstrings)
|
|
151
|
+
rescue StandardError => e
|
|
152
|
+
# If optimization fails, fall back to unoptimized CharStrings
|
|
153
|
+
warn "CFF optimization failed: #{e.message}, using unoptimized CharStrings"
|
|
154
|
+
local_subrs = []
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Build CFF table from charstrings and local subrs
|
|
159
|
+
cff_data = build_cff_table(charstrings, local_subrs, font)
|
|
160
|
+
|
|
161
|
+
# Copy all tables except glyf/loca
|
|
162
|
+
tables = copy_tables(font, %w[glyf loca])
|
|
163
|
+
|
|
164
|
+
# Add CFF table
|
|
165
|
+
tables["CFF "] = cff_data
|
|
166
|
+
|
|
167
|
+
# Update maxp table for CFF
|
|
168
|
+
tables["maxp"] = update_maxp_for_cff(font, outlines.length)
|
|
169
|
+
|
|
170
|
+
# Update head table for CFF
|
|
171
|
+
tables["head"] = update_head_for_cff(font)
|
|
172
|
+
|
|
173
|
+
# Convert and apply hints if preservation is enabled
|
|
174
|
+
if @preserve_hints && hints_per_glyph.any?
|
|
175
|
+
# Extract font-level hints separately
|
|
176
|
+
hint_set = extract_ttf_hint_set(font)
|
|
177
|
+
|
|
178
|
+
unless hint_set.empty?
|
|
179
|
+
# Convert TrueType hints to PostScript format
|
|
180
|
+
converter = Hints::HintConverter.new
|
|
181
|
+
ps_hint_set = converter.convert_hint_set(hint_set, :postscript)
|
|
182
|
+
|
|
183
|
+
# Apply PostScript hints (validation mode - CFF modification pending)
|
|
184
|
+
applier = Hints::PostScriptHintApplier.new
|
|
185
|
+
tables = applier.apply(ps_hint_set, tables)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
tables
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Convert OpenType/CFF font to TrueType
|
|
193
|
+
#
|
|
194
|
+
# @param font [OpenTypeFont] Source font
|
|
195
|
+
# @return [Hash<String, String>] Target tables
|
|
196
|
+
def convert_otf_to_ttf(font)
|
|
197
|
+
# Extract all glyphs from CFF table
|
|
198
|
+
outlines = extract_cff_outlines(font)
|
|
199
|
+
|
|
200
|
+
# Extract hints if preservation is enabled
|
|
201
|
+
hints_per_glyph = @preserve_hints ? extract_cff_hints(font) : {}
|
|
202
|
+
|
|
203
|
+
# Build glyf and loca tables
|
|
204
|
+
glyf_data, loca_data, loca_format = build_glyf_loca_tables(outlines)
|
|
205
|
+
|
|
206
|
+
# Copy all tables except CFF
|
|
207
|
+
tables = copy_tables(font, ["CFF ", "CFF2"])
|
|
208
|
+
|
|
209
|
+
# Add glyf and loca tables
|
|
210
|
+
tables["glyf"] = glyf_data
|
|
211
|
+
tables["loca"] = loca_data
|
|
212
|
+
|
|
213
|
+
# Update maxp table for TrueType
|
|
214
|
+
tables["maxp"] = update_maxp_for_truetype(font, outlines, loca_format)
|
|
215
|
+
|
|
216
|
+
# Update head table for TrueType
|
|
217
|
+
tables["head"] = update_head_for_truetype(font, loca_format)
|
|
218
|
+
|
|
219
|
+
# Convert and apply hints if preservation is enabled
|
|
220
|
+
if @preserve_hints && hints_per_glyph.any?
|
|
221
|
+
# Extract font-level hints separately
|
|
222
|
+
hint_set = extract_cff_hint_set(font)
|
|
223
|
+
|
|
224
|
+
unless hint_set.empty?
|
|
225
|
+
# Convert PostScript hints to TrueType format
|
|
226
|
+
converter = Hints::HintConverter.new
|
|
227
|
+
tt_hint_set = converter.convert_hint_set(hint_set, :truetype)
|
|
228
|
+
|
|
229
|
+
# Apply TrueType hints (writes fpgm/prep/cvt tables)
|
|
230
|
+
applier = Hints::TrueTypeHintApplier.new
|
|
231
|
+
tables = applier.apply(tt_hint_set, tables)
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
tables
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Convert TrueType font to OpenType/CFF
|
|
239
|
+
#
|
|
240
|
+
# @return [Hash<String, String>] Target tables
|
|
241
|
+
def ttf_to_otf
|
|
242
|
+
raise Fontisan::Error, "No font loaded" unless @font
|
|
243
|
+
|
|
244
|
+
convert_ttf_to_otf(@font)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Convert OpenType/CFF font to TrueType
|
|
248
|
+
#
|
|
249
|
+
# @return [Hash<String, String>] Target tables
|
|
250
|
+
def otf_to_ttf
|
|
251
|
+
raise Fontisan::Error, "No font loaded" unless @font
|
|
252
|
+
|
|
253
|
+
convert_otf_to_ttf(@font)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Get supported conversions
|
|
257
|
+
#
|
|
258
|
+
# @return [Array<Array<Symbol>>] Supported conversion pairs
|
|
259
|
+
def supported_conversions
|
|
260
|
+
[
|
|
261
|
+
%i[ttf otf],
|
|
262
|
+
%i[otf ttf],
|
|
263
|
+
%i[cff2 ttf],
|
|
264
|
+
%i[ttf cff2],
|
|
265
|
+
]
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Validate font for conversion
|
|
269
|
+
#
|
|
270
|
+
# @param font [TrueTypeFont, OpenTypeFont] Font to validate
|
|
271
|
+
# @param target_format [Symbol] Target format
|
|
272
|
+
# @return [Boolean] True if valid
|
|
273
|
+
# @raise [ArgumentError] If font is invalid
|
|
274
|
+
# @raise [Error] If conversion is not supported
|
|
275
|
+
def validate(font, target_format)
|
|
276
|
+
raise ArgumentError, "Font cannot be nil" if font.nil?
|
|
277
|
+
|
|
278
|
+
unless font.is_a?(SfntSource)
|
|
279
|
+
raise ArgumentError, "Font must be an SfntSource instance"
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
source_format = detect_format(font)
|
|
283
|
+
unless supports?(source_format, target_format)
|
|
284
|
+
raise Fontisan::Error,
|
|
285
|
+
"Conversion #{source_format} → #{target_format} not supported"
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
# Check that source font has required tables
|
|
289
|
+
validate_source_tables(font, source_format)
|
|
290
|
+
|
|
291
|
+
true
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Copy non-outline tables from source to target
|
|
295
|
+
#
|
|
296
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
297
|
+
# @param exclude_tags [Array<String>] Tags to exclude
|
|
298
|
+
# @return [Hash<String, String>] Copied tables
|
|
299
|
+
def copy_tables(font, exclude_tags = [])
|
|
300
|
+
tables = {}
|
|
301
|
+
|
|
302
|
+
font.table_data.each do |tag, data|
|
|
303
|
+
next if exclude_tags.include?(tag)
|
|
304
|
+
|
|
305
|
+
tables[tag] = data if data
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
tables
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# Update maxp table for CFF format
|
|
312
|
+
#
|
|
313
|
+
# @param font [TrueTypeFont] Source font
|
|
314
|
+
# @param num_glyphs [Integer] Number of glyphs
|
|
315
|
+
# @return [String] Updated maxp table binary data
|
|
316
|
+
def update_maxp_for_cff(_font, num_glyphs)
|
|
317
|
+
# CFF uses maxp version 0.5 (0x00005000)
|
|
318
|
+
# Structure: version (4 bytes) + numGlyphs (2 bytes)
|
|
319
|
+
[Tables::Maxp::VERSION_0_5, num_glyphs].pack("Nn")
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# Update maxp table for TrueType format
|
|
323
|
+
#
|
|
324
|
+
# @param font [OpenTypeFont] Source font
|
|
325
|
+
# @param outlines [Array<Outline>] Glyph outlines
|
|
326
|
+
# @param loca_format [Integer] Loca format (0 or 1)
|
|
327
|
+
# @return [String] Updated maxp table binary data
|
|
328
|
+
def update_maxp_for_truetype(font, outlines, _loca_format)
|
|
329
|
+
# Get source maxp
|
|
330
|
+
font.table("maxp")
|
|
331
|
+
num_glyphs = outlines.length
|
|
332
|
+
|
|
333
|
+
# Calculate statistics from outlines
|
|
334
|
+
max_points = 0
|
|
335
|
+
max_contours = 0
|
|
336
|
+
|
|
337
|
+
outlines.each do |outline|
|
|
338
|
+
next if outline.empty?
|
|
339
|
+
|
|
340
|
+
contours = outline.to_truetype_contours
|
|
341
|
+
max_contours = [max_contours, contours.length].max
|
|
342
|
+
|
|
343
|
+
contours.each do |contour|
|
|
344
|
+
max_points = [max_points, contour.length].max
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
# Build maxp v1.0 table
|
|
349
|
+
# We'll use conservative defaults for instruction-related fields
|
|
350
|
+
[
|
|
351
|
+
Tables::Maxp::VERSION_1_0, # version
|
|
352
|
+
num_glyphs, # numGlyphs
|
|
353
|
+
max_points, # maxPoints
|
|
354
|
+
max_contours, # maxContours
|
|
355
|
+
0, # maxCompositePoints
|
|
356
|
+
0, # maxCompositeContours
|
|
357
|
+
2, # maxZones
|
|
358
|
+
0, # maxTwilightPoints
|
|
359
|
+
0, # maxStorage
|
|
360
|
+
0, # maxFunctionDefs
|
|
361
|
+
0, # maxInstructionDefs
|
|
362
|
+
0, # maxStackElements
|
|
363
|
+
0, # maxSizeOfInstructions
|
|
364
|
+
0, # maxComponentElements
|
|
365
|
+
0, # maxComponentDepth
|
|
366
|
+
].pack("Nnnnnnnnnnnnnnn")
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# Update head table for CFF format
|
|
370
|
+
#
|
|
371
|
+
# @param font [TrueTypeFont] Source font
|
|
372
|
+
# @return [String] Updated head table binary data
|
|
373
|
+
def update_head_for_cff(font)
|
|
374
|
+
font.table("head")
|
|
375
|
+
head_data = font.table_data["head"].dup
|
|
376
|
+
|
|
377
|
+
# For CFF fonts, indexToLocFormat is not relevant
|
|
378
|
+
# but we'll set it to 0 for consistency
|
|
379
|
+
# indexToLocFormat is at offset 50 (2 bytes)
|
|
380
|
+
head_data[50, 2] = [0].pack("n")
|
|
381
|
+
|
|
382
|
+
head_data
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# Update head table for TrueType format
|
|
386
|
+
#
|
|
387
|
+
# @param font [OpenTypeFont] Source font
|
|
388
|
+
# @param loca_format [Integer] Loca format (0=short, 1=long)
|
|
389
|
+
# @return [String] Updated head table binary data
|
|
390
|
+
def update_head_for_truetype(font, loca_format)
|
|
391
|
+
font.table("head")
|
|
392
|
+
head_data = font.table_data["head"].dup
|
|
393
|
+
|
|
394
|
+
# Set indexToLocFormat at offset 50 (2 bytes)
|
|
395
|
+
head_data[50, 2] = [loca_format].pack("n")
|
|
396
|
+
|
|
397
|
+
head_data
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
# Generate static instance from variable font
|
|
401
|
+
#
|
|
402
|
+
# @param font [TrueTypeFont, OpenTypeFont] Variable font
|
|
403
|
+
# @param source_format [Symbol] Source format
|
|
404
|
+
# @param target_format [Symbol] Target format
|
|
405
|
+
# @return [Hash<String, String>] Static font tables
|
|
406
|
+
def generate_static_instance(font, source_format, target_format)
|
|
407
|
+
# Generate instance at specified coordinates
|
|
408
|
+
fvar = font.table("fvar")
|
|
409
|
+
fvar ? fvar.axes : []
|
|
410
|
+
|
|
411
|
+
generator = Variation::InstanceGenerator.new(font,
|
|
412
|
+
@instance_coordinates)
|
|
413
|
+
instance_tables = generator.generate
|
|
414
|
+
|
|
415
|
+
# If target format differs from source, convert outlines
|
|
416
|
+
if source_format == target_format
|
|
417
|
+
instance_tables
|
|
418
|
+
else
|
|
419
|
+
# Create temporary font with instance tables
|
|
420
|
+
temp_font = font.class.new
|
|
421
|
+
temp_font.table_data = instance_tables
|
|
422
|
+
|
|
423
|
+
# Convert outline format
|
|
424
|
+
case [source_format, target_format]
|
|
425
|
+
when %i[ttf otf]
|
|
426
|
+
convert_ttf_to_otf(temp_font, @options)
|
|
427
|
+
when %i[otf ttf], %i[cff2 ttf]
|
|
428
|
+
convert_otf_to_ttf(temp_font)
|
|
429
|
+
else
|
|
430
|
+
instance_tables
|
|
431
|
+
end
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
# Convert variation data during outline conversion
|
|
436
|
+
#
|
|
437
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
438
|
+
# @param target_format [Symbol] Target format
|
|
439
|
+
# @return [Hash, nil] Converted variation data or nil
|
|
440
|
+
def convert_variations(font, target_format)
|
|
441
|
+
return nil unless @preserve_variations
|
|
442
|
+
return nil unless variable_font?(font)
|
|
443
|
+
|
|
444
|
+
fvar = font.table("fvar")
|
|
445
|
+
return nil unless fvar
|
|
446
|
+
|
|
447
|
+
axes = fvar.axes
|
|
448
|
+
converter = Variation::Converter.new(font, axes)
|
|
449
|
+
|
|
450
|
+
# Get glyph count
|
|
451
|
+
maxp = font.table("maxp")
|
|
452
|
+
return nil unless maxp
|
|
453
|
+
|
|
454
|
+
glyph_count = maxp.num_glyphs
|
|
455
|
+
|
|
456
|
+
# Convert variation data for each glyph
|
|
457
|
+
variation_data = {}
|
|
458
|
+
glyph_count.times do |glyph_id|
|
|
459
|
+
source_format = detect_format(font)
|
|
460
|
+
|
|
461
|
+
data = case [source_format, target_format]
|
|
462
|
+
when %i[ttf otf], %i[ttf cff2]
|
|
463
|
+
# gvar → blend
|
|
464
|
+
converter.gvar_to_blend(glyph_id)
|
|
465
|
+
when %i[otf ttf], %i[cff2 ttf]
|
|
466
|
+
# blend → gvar
|
|
467
|
+
converter.blend_to_gvar(glyph_id)
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
variation_data[glyph_id] = data if data
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
variation_data.empty? ? nil : variation_data
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
# Detect font format from tables
|
|
477
|
+
#
|
|
478
|
+
# @param font [TrueTypeFont, OpenTypeFont] Font to detect
|
|
479
|
+
# @return [Symbol] Format (:ttf, :otf, or :cff2)
|
|
480
|
+
# @raise [Error] If format cannot be detected
|
|
481
|
+
def detect_format(font)
|
|
482
|
+
# Check for CFF2 table first (OpenType variable fonts with CFF2 outlines)
|
|
483
|
+
if font.has_table?("CFF2")
|
|
484
|
+
:cff2
|
|
485
|
+
# Check for CFF table (OpenType/CFF)
|
|
486
|
+
elsif font.has_table?("CFF ")
|
|
487
|
+
:otf
|
|
488
|
+
# Check for glyf table (TrueType)
|
|
489
|
+
elsif font.has_table?("glyf")
|
|
490
|
+
:ttf
|
|
491
|
+
else
|
|
492
|
+
raise Fontisan::Error,
|
|
493
|
+
"Cannot detect font format: missing outline tables (CFF2, CFF, or glyf)"
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
# Detect target format as opposite of source
|
|
498
|
+
#
|
|
499
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
500
|
+
# @return [Symbol] Target format
|
|
501
|
+
def detect_target_format(font)
|
|
502
|
+
source = detect_format(font)
|
|
503
|
+
case source
|
|
504
|
+
when :ttf
|
|
505
|
+
:otf
|
|
506
|
+
when :cff2
|
|
507
|
+
:ttf
|
|
508
|
+
else
|
|
509
|
+
:ttf
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
# Validate source font has required tables
|
|
514
|
+
#
|
|
515
|
+
# @param font [TrueTypeFont, OpenTypeFont] Font to validate
|
|
516
|
+
# @param format [Symbol] Font format
|
|
517
|
+
# @raise [Error] If required tables are missing
|
|
518
|
+
def validate_source_tables(font, format)
|
|
519
|
+
case format
|
|
520
|
+
when :ttf
|
|
521
|
+
unless font.has_table?("glyf") && font.has_table?("loca")
|
|
522
|
+
raise Fontisan::MissingTableError,
|
|
523
|
+
"TrueType font missing required glyf or loca table"
|
|
524
|
+
end
|
|
525
|
+
# Also verify tables can actually be loaded
|
|
526
|
+
unless font.table("glyf") && font.table("loca")
|
|
527
|
+
raise Fontisan::MissingTableError,
|
|
528
|
+
"TrueType font missing required glyf or loca table"
|
|
529
|
+
end
|
|
530
|
+
when :cff2
|
|
531
|
+
unless font.has_table?("CFF2")
|
|
532
|
+
raise Fontisan::MissingTableError,
|
|
533
|
+
"CFF2 font missing required CFF2 table"
|
|
534
|
+
end
|
|
535
|
+
unless font.table("CFF2")
|
|
536
|
+
raise Fontisan::MissingTableError,
|
|
537
|
+
"CFF2 font missing required CFF2 table"
|
|
538
|
+
end
|
|
539
|
+
when :otf
|
|
540
|
+
unless font.has_table?("CFF ") || font.has_table?("CFF2")
|
|
541
|
+
raise Fontisan::MissingTableError,
|
|
542
|
+
"OpenType font missing required CFF or CFF2 table"
|
|
543
|
+
end
|
|
544
|
+
# Verify at least one can be loaded
|
|
545
|
+
unless font.table("CFF ") || font.table("CFF2")
|
|
546
|
+
raise Fontisan::MissingTableError,
|
|
547
|
+
"OpenType font missing required CFF or CFF2 table"
|
|
548
|
+
end
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
# Common required tables
|
|
552
|
+
%w[head hhea maxp].each do |tag|
|
|
553
|
+
unless font.has_table?(tag)
|
|
554
|
+
raise Fontisan::MissingTableError,
|
|
555
|
+
"Font missing required #{tag} table"
|
|
556
|
+
end
|
|
557
|
+
# Verify table can actually be loaded
|
|
558
|
+
unless font.table(tag)
|
|
559
|
+
raise Fontisan::MissingTableError,
|
|
560
|
+
"Font missing required #{tag} table"
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
# Extract hints from TrueType font
|
|
566
|
+
#
|
|
567
|
+
# @param font [TrueTypeFont] Source font
|
|
568
|
+
# @return [Hash<Integer, Array<Hint>>] Map of glyph ID to hints
|
|
569
|
+
def extract_ttf_hints(font)
|
|
570
|
+
hints_per_glyph = {}
|
|
571
|
+
extractor = Hints::TrueTypeHintExtractor.new
|
|
572
|
+
|
|
573
|
+
# Get required tables
|
|
574
|
+
head = font.table("head")
|
|
575
|
+
maxp = font.table("maxp")
|
|
576
|
+
loca = font.table("loca")
|
|
577
|
+
glyf = font.table("glyf")
|
|
578
|
+
|
|
579
|
+
# Parse loca with context
|
|
580
|
+
loca.parse_with_context(head.index_to_loc_format, maxp.num_glyphs)
|
|
581
|
+
|
|
582
|
+
# Extract hints from each glyph
|
|
583
|
+
maxp.num_glyphs.times do |glyph_id|
|
|
584
|
+
glyph = glyf.glyph_for(glyph_id, loca, head)
|
|
585
|
+
next if glyph.nil? || glyph.empty?
|
|
586
|
+
|
|
587
|
+
hints = extractor.extract(glyph)
|
|
588
|
+
hints_per_glyph[glyph_id] = hints if hints.any?
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
hints_per_glyph
|
|
592
|
+
rescue StandardError => e
|
|
593
|
+
warn "Failed to extract TrueType hints: #{e.message}"
|
|
594
|
+
{}
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
# Extract hints from CFF font
|
|
598
|
+
#
|
|
599
|
+
# @param font [OpenTypeFont] Source font
|
|
600
|
+
# @return [Hash<Integer, Array<Hint>>] Map of glyph ID to hints
|
|
601
|
+
def extract_cff_hints(font)
|
|
602
|
+
hints_per_glyph = {}
|
|
603
|
+
extractor = Hints::PostScriptHintExtractor.new
|
|
604
|
+
|
|
605
|
+
# Get CFF table
|
|
606
|
+
cff = font.table("CFF ")
|
|
607
|
+
return {} unless cff
|
|
608
|
+
|
|
609
|
+
# Get number of glyphs
|
|
610
|
+
num_glyphs = cff.glyph_count
|
|
611
|
+
|
|
612
|
+
# Extract hints from each CharString
|
|
613
|
+
num_glyphs.times do |glyph_id|
|
|
614
|
+
charstring = cff.charstring_for_glyph(glyph_id)
|
|
615
|
+
next if charstring.nil?
|
|
616
|
+
|
|
617
|
+
hints = extractor.extract(charstring)
|
|
618
|
+
hints_per_glyph[glyph_id] = hints if hints.any?
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
hints_per_glyph
|
|
622
|
+
rescue StandardError => e
|
|
623
|
+
warn "Failed to extract CFF hints: #{e.message}"
|
|
624
|
+
{}
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
# Extract complete TrueType hint set from font
|
|
628
|
+
#
|
|
629
|
+
# @param font [TrueTypeFont] Source font
|
|
630
|
+
# @return [HintSet] Complete hint set
|
|
631
|
+
def extract_ttf_hint_set(font)
|
|
632
|
+
extractor = Hints::TrueTypeHintExtractor.new
|
|
633
|
+
extractor.extract_from_font(font)
|
|
634
|
+
rescue StandardError => e
|
|
635
|
+
warn "Failed to extract TrueType hint set: #{e.message}"
|
|
636
|
+
Models::HintSet.new(format: :truetype)
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
# Extract complete PostScript hint set from font
|
|
640
|
+
#
|
|
641
|
+
# @param font [OpenTypeFont] Source font
|
|
642
|
+
# @return [HintSet] Complete hint set
|
|
643
|
+
def extract_cff_hint_set(font)
|
|
644
|
+
extractor = Hints::PostScriptHintExtractor.new
|
|
645
|
+
extractor.extract_from_font(font)
|
|
646
|
+
rescue StandardError => e
|
|
647
|
+
warn "Failed to extract PostScript hint set: #{e.message}"
|
|
648
|
+
Models::HintSet.new(format: :postscript)
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
# Check if font is a variable font
|
|
652
|
+
#
|
|
653
|
+
# @param font [TrueTypeFont, OpenTypeFont] Font to check
|
|
654
|
+
# @return [Boolean] True if font has variation tables
|
|
655
|
+
def variable_font?(font)
|
|
656
|
+
font.has_table?("fvar")
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
# Extract ConversionOptions from options hash
|
|
660
|
+
#
|
|
661
|
+
# @param options [Hash, ConversionOptions] Options or hash containing :options key
|
|
662
|
+
# @return [ConversionOptions, nil] Extracted ConversionOptions or nil
|
|
663
|
+
def extract_conversion_options(options)
|
|
664
|
+
return options if options.is_a?(ConversionOptions)
|
|
665
|
+
|
|
666
|
+
options[:options] if options.is_a?(Hash)
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
# Apply opening options to source font
|
|
670
|
+
#
|
|
671
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
672
|
+
# @param conv_options [ConversionOptions] Conversion options with opening options
|
|
673
|
+
def apply_opening_options(font, conv_options)
|
|
674
|
+
return unless conv_options
|
|
675
|
+
|
|
676
|
+
# Decompose composites if requested
|
|
677
|
+
if conv_options.opening_option?(:decompose_composites)
|
|
678
|
+
decompose_composite_glyphs(font)
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# Interpret OpenType tables if requested
|
|
682
|
+
if conv_options.opening_option?(:interpret_ot)
|
|
683
|
+
# Ensure GSUB/GPOS tables are fully loaded
|
|
684
|
+
interpret_opentype_features(font)
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
# Note: scale_to_1000 and convert_curves are handled during conversion
|
|
688
|
+
# These options affect the conversion process itself
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
# Decompose composite glyphs in font
|
|
692
|
+
#
|
|
693
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
694
|
+
def decompose_composite_glyphs(_font)
|
|
695
|
+
# Placeholder: Decompose composite glyphs
|
|
696
|
+
# A full implementation would:
|
|
697
|
+
# 1. Identify composite glyphs (TrueType: flags & 0x0020, CFF: seac operator)
|
|
698
|
+
# 2. Extract component outlines
|
|
699
|
+
# 3. Merge into single glyph
|
|
700
|
+
#
|
|
701
|
+
# For now, this is a no-op placeholder
|
|
702
|
+
nil
|
|
703
|
+
end
|
|
704
|
+
|
|
705
|
+
# Interpret OpenType layout features
|
|
706
|
+
#
|
|
707
|
+
# @param font [TrueTypeFont, OpenTypeFont] Source font
|
|
708
|
+
def interpret_opentype_features(_font)
|
|
709
|
+
# Placeholder: Interpret GSUB/GPOS tables
|
|
710
|
+
# A full implementation would:
|
|
711
|
+
# 1. Parse GSUB table for substitution rules
|
|
712
|
+
# 2. Parse GPOS table for positioning rules
|
|
713
|
+
# 3. Store interpreted features for later use
|
|
714
|
+
#
|
|
715
|
+
# For now, this is a no-op placeholder
|
|
716
|
+
nil
|
|
717
|
+
end
|
|
718
|
+
end
|
|
719
|
+
end
|
|
720
|
+
end
|