Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opentype ItemVariationStore implementation #232

Draft
wants to merge 51 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
586a78b
Test-fonts folder and Cargo.lock checkin
archaephyrryx Oct 10, 2024
d8cc5f5
Add prep, gasp to OpenType def and extend API-helper accordingly
archaephyrryx Oct 14, 2024
2dcfa5e
Update HELPERS.md
archaephyrryx Oct 17, 2024
85e880d
GDEF spec (ItemVariationStore unimplemented), no API helper support
archaephyrryx Oct 17, 2024
82b87f0
Extract oft_metrics to own file, define and generate Gdef table metri…
archaephyrryx Oct 23, 2024
9fc43f2
Finish printing of GDEF metrics
archaephyrryx Oct 27, 2024
6b628e3
Implement majority of GPOS and display API
archaephyrryx Nov 13, 2024
abd9ddb
Display fixes for GPOS
archaephyrryx Nov 13, 2024
e7e6f61
Tweaks to output
archaephyrryx Nov 14, 2024
166247e
SinglePos subtable in format def and API, add test-font
archaephyrryx Nov 15, 2024
ac606fa
Add rustfmt::skip attr to generated module, fmt everything else
archaephyrryx Nov 15, 2024
317e5c3
Adds PairPos subtable in def and otf_metrics, cleanup, new test-font
archaephyrryx Nov 19, 2024
4483978
CursivePos implementation and API support, new test-font
archaephyrryx Nov 20, 2024
b870ff8
Implement GSUB, scaffolding for lookup subtables
archaephyrryx Nov 20, 2024
ab76d45
Avoid printing default-valued LookupFlag
archaephyrryx Nov 20, 2024
e568f7a
Partial implementation of SequenceContext subtable
archaephyrryx Nov 21, 2024
dd4ae42
Add type-unification tricks to explicate transitive error-chain
archaephyrryx Nov 25, 2024
81e885d
Fix SOF shift bug in SequenceContext definition
archaephyrryx Nov 25, 2024
bc061e9
ChainedSequenceContexts support, otf_metrics tweaks
archaephyrryx Nov 27, 2024
580478f
Add SingleSubst, refine offset16, refactor helpers and usage patterns
archaephyrryx Nov 28, 2024
020e27b
partial fixes for oft_metrics based on revamped format implementation
archaephyrryx Nov 28, 2024
45cd668
Fixes overloaded typename for LookupFlag format definition
archaephyrryx Nov 29, 2024
4ce9e1b
Minor refactor of prepend_field_flags_bits8 in opentype
archaephyrryx Nov 29, 2024
0e0c5e2
Miscellaneous renamings, refactorings, and doc-changes (spellcheck)
archaephyrryx Dec 2, 2024
f0f1faa
Redesign of otf-metrics to handle semi-nullable offset links
archaephyrryx Dec 3, 2024
142d97f
Fixes missing offset-linkage in rule_set.chained_seq_rules
archaephyrryx Dec 4, 2024
e09dca5
AlternateSubst, add guard to avoid underflow for bad offsets
archaephyrryx Dec 5, 2024
279131d
Add --fast flag for fontinfo
archaephyrryx Dec 5, 2024
cb3e7c6
Fix for cmap_subtable_format6 length>65535, minor cleanup
archaephyrryx Dec 9, 2024
61840eb
Fix bad SOF-offset for table-dirs in TTC, rename sample_codegen
archaephyrryx Dec 9, 2024
739fd16
Fix otf_metrics based on breaking changes to opentype.rs
archaephyrryx Dec 9, 2024
aae5df6
Add quick comment to explain TraitSet::Copy
archaephyrryx Dec 10, 2024
98c2b5a
fontinfo verbosity, derive builder, doodle --as-format flag
archaephyrryx Dec 10, 2024
423178b
Reverts red-herring anti-fix to 'start of font' offset interpretation
archaephyrryx Dec 10, 2024
4816aec
Adds base address parameter to WithRelativeOffset, -q flag in fontinfo
archaephyrryx Dec 11, 2024
9ce9e4f
Adds frankenpax TTC font to test-fonts directory
archaephyrryx Dec 11, 2024
a05547d
Relax assertion that MultipleSubst glyphCount != 0
archaephyrryx Dec 11, 2024
a2adb31
Handle non-standard delta-values, refactor UintSet
archaephyrryx Dec 12, 2024
7e7dcbb
Allow OpenType fonts to have TrueType-specific "true" sfntVersion
archaephyrryx Dec 12, 2024
854a0f0
LigatureSubst support, CoverageTable iteration
archaephyrryx Dec 15, 2024
ae955e6
ReverseChainContextSingleSubst support
archaephyrryx Dec 16, 2024
57cba4c
Groundwork FormatRefs to facilitate writing Pos/Subst Extension
archaephyrryx Dec 19, 2024
5c24d7d
Implementation of MarkBase and MarkLig Pos subtables (broken on one f…
archaephyrryx Jan 6, 2025
e22d14c
Fixed MarkLigPos, partial impl (Format layer only) for MarkMarkPos
archaephyrryx Jan 7, 2025
d75ed2c
Full implementation of MarkMarkPos
archaephyrryx Jan 7, 2025
1888a1f
Support for layout extension subtables
archaephyrryx Jan 8, 2025
a1f9827
Inherit extension lookup type for LookupTable lookup_type field value
archaephyrryx Jan 8, 2025
753e79a
Add Format layer for v1.1 layout table fields, test font for FeatureV…
archaephyrryx Jan 8, 2025
010a886
Implementation and partial API for Base table
archaephyrryx Jan 12, 2025
e5b5a31
ItemVariationStore stub implementation
archaephyrryx Jan 12, 2025
71df976
Prototype implementation for ItemVariationStore
archaephyrryx Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Redesign of otf-metrics to handle semi-nullable offset links
archaephyrryx committed Dec 3, 2024
commit f0f1faa81d99d6358a68d11d6ab853f66d831802
71 changes: 64 additions & 7 deletions doodle-formats/src/format/opentype.rs
Original file line number Diff line number Diff line change
@@ -362,22 +362,35 @@ fn link(abs_offset: Expr, format: Format) -> Format {
/// parses a u16be as a positive delta from `base_offset` and returns the linked content parsed according
/// to `format` at that location.
///
/// Returns a record `{ offset: u16, link := format }`
/// Returns a record `{ offset: u16, link := (offset > 0) ?Some(format) : None }`
///
/// Additionally takes argument `base` of type `BaseModule` to parse u16be values without code duplication.
///
/// Only to be used when an `offset` value of `0` (which normally results in `link: None`) is
/// not considered legal, in which case the local parse will produce an error.
/// # Note
///
/// If this guarantee cannot be made, use [`offset_nullable`] instead to allow Null offsets.
/// Despite a valid offset being 'mandatory', there is no practical way to avoid constructing
/// some form of `Option`-like container to reluctantly avoid erroring out; the OpenType specification
/// itself says that parsers of OpenType data should "anticipate non-conformant font data that has a
/// NULL subtable offset where only a non-NULL value is expected."
///
/// Thus, we have to be prepared to parse a zero-length offset and return an empty format of some kind.
///
/// In future iterations, a distinct option-like type may be constructed to distinguish nullable offset-links
/// from non-nullable offset-links, but for now, behavior is identical to [`offset16_nullable`].
///
/// See [https://learn.microsoft.com/en-us/typography/opentype/spec/otff#data-types] for more info.
fn offset16_mandatory(base_offset: Expr, format: Format, base: &BaseModule) -> Format {
shadow_check(&base_offset, "offset");
// REVIEW - there is an argument to be made that we should use `chain` instead of `record` to elide the offset and flatten the link
record([
("offset", where_nonzero(base.u16be())),
("offset", base.u16be()),
(
"link",
link(pos_add_u16(base_offset, var("offset")), format),
if_then_else(
is_nonzero(var("offset")),
link(pos_add_u16(base_offset, var("offset")), format_some(format)),
format_none(),
),
),
])
}
@@ -2821,7 +2834,51 @@ pub fn main(module: &mut FormatModule, base: &BaseModule) -> FormatRef {
),
])
};
let multiple_subst = /* STUB */ Format::EMPTY;
let multiple_subst = {
let sequence_table = record([
("glyph_count", where_nonzero(base.u16be())),
(
"substitute_glyph_ids",
repeat_count(var("glyph_count"), base.u16be()),
),
]);

record([
("table_start", pos32()),
("subst_format", base.u16be()),
(
"coverage",
offset16_mandatory(var("table_start"), coverage_table.call(), base),
),
(
"subst",
match_variant(
var("subst_format"),
[
(
Pattern::U16(1),
"Format1",
record([
("sequence_count", base.u16be()),
(
"sequences",
repeat_count(
var("sequence_count"),
offset16_mandatory(
var("table_start"),
sequence_table,
base,
),
),
),
]),
),
(Pattern::Wildcard, "BadFormat", Format::Fail),
],
),
),
])
};
let alternate_subst = /* STUB */ Format::EMPTY;
let ligature_subst = /* STUB */ Format::EMPTY;
let subst_extension = /* STUB */ Format::EMPTY;
Loading