-
Notifications
You must be signed in to change notification settings - Fork 3
Sketch #243
Sketch #243
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,19 @@ | |
use std::collections::{BTreeMap, HashMap}; | ||
|
||
use smol_str::SmolStr; | ||
use write_fonts::tables::{ | ||
gpos::AnchorTable, | ||
layout::{LookupFlag, PendingVariationIndex}, | ||
variations::VariationRegion, | ||
use write_fonts::{ | ||
tables::{ | ||
gpos::AnchorTable, | ||
layout::{LookupFlag, PendingVariationIndex}, | ||
variations::VariationRegion, | ||
}, | ||
types::GlyphId, | ||
}; | ||
|
||
use crate::common::{GlyphClass, MarkClass}; | ||
use crate::{ | ||
common::{GlyphClass, MarkClass}, | ||
compile::variations::Location, | ||
}; | ||
|
||
use super::{ | ||
features::FeatureLookups, | ||
|
@@ -93,10 +99,62 @@ | |
.insert(class_name.into(), MarkClass { members }); | ||
} | ||
|
||
/// Define a mark class with a variable anchor. | ||
/// | ||
/// Roughly equivalent to `markClass glyph|class <anchor x y> @name{};` | ||
/// [markClass](https://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileSpecification.html#4.f) | ||
/// with a variable anchor record. | ||
pub fn add_mark_class_for_glyph( | ||
&mut self, | ||
gid: GlyphId, | ||
default_anchor: (i16, i16), | ||
class_name: impl Into<SmolStr>, | ||
_anchor_variations: HashMap<Location, (i16, i16)>, | ||
) { | ||
// TODO: an error type | ||
eprintln!( | ||
"TODO: {}", | ||
format!( | ||
"markClass {} <anchor {} {}> @{}; # TODO variable anchor", | ||
gid, | ||
default_anchor.0, | ||
default_anchor.1, | ||
class_name.into() | ||
) | ||
); | ||
} | ||
|
||
/// Setup a mark to base. | ||
/// | ||
/// Pseudo-fea: | ||
/// | ||
/// ```text | ||
/// lookup name { | ||
/// pos base base_name <anchor x y> @markclass; | ||
/// // plus variations of anchor pos | ||
/// } | ||
/// | ||
/// <https://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileSpecification.html#6.d> | ||
/// ``` | ||
pub fn add_mark_base_pos( | ||
&mut self, | ||
lookup_name: impl Into<SmolStr>, | ||
base_name: impl Into<SmolStr>, | ||
class_name: impl Into<SmolStr>, | ||
default_anchor: (i16, i16), | ||
_anchor_variations: HashMap<Location, (i16, i16)>, | ||
Comment on lines
+139
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm a bit more sanguine. Using lookup names adds another layer of misdirection; I would prefer to have the caller construct lookups directly and then use the provided Something I'm taking away from this, though, is that I think overall it would be nice if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No objection to passing ids rather than names as long as we make acquiring an id easy. For example, perhaps here there need not be anything at all for lookup, I want a mark base, and the builder will generate a lookup to hold it. |
||
) { | ||
// TODO: an error type | ||
let lookup_name = lookup_name.into(); | ||
let base_name = base_name.into(); | ||
let class_name = class_name.into(); | ||
eprintln!(" lookup {lookup_name} {{\n pos base {base_name} <anchor {} {}> @{class_name}; # TODO variable anchor;\n }} {lookup_name};", default_anchor.0, default_anchor.1); | ||
} | ||
|
||
/// Create a new lookup. | ||
/// | ||
/// The `LookupId` that is returned can then be included in features via | ||
/// the [`add_feature`] method. | ||
pub fn add_lookup<T: GposSubtableBuilder>( | ||
&mut self, | ||
flags: LookupFlag, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function above is an attempt to provide this same functionality. And I agree there's room for improvement.
I find the relationship between FEA text and the actual GPOS/GSUB/GDEF tables eternally confusing. With that in mind, I'm just going to think through the differences out loud: