-
Notifications
You must be signed in to change notification settings - Fork 21
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
How to interpret Placement and MarkPlacement? #37
Comments
I worked on an example that covered this yesterday. I'll have it ready soon. Currently the code that we have for this is part of the Prince codebase, implemented in Mercury, so I'm needing to understand and port that as part of the example. |
In case it's helpful in the meantime these are the docs I added to #[derive(Debug)]
pub enum Placement {
None,
/// Placement offset by distance delta.
///
/// Fields
/// (delta x, delta y)
Distance(i32, i32),
/// Cursive anchored placement.
///
/// Fields:
/// (entry anchor point, exit anchor point)
Anchor(Anchor, Anchor),
}
#[derive(Debug)]
pub enum MarkPlacement {
None,
/// An anchored mark.
///
/// This is a mark where its anchor is aligned with the base glyph anchor.
///
/// Fields:
/// (base glyph index, base glyph anchor, mark anchor)
MarkAnchor(usize, Anchor, Anchor),
/// An overprint mark.
///
/// This mark is shown at the same position as the base glyph.
///
/// Fields:
/// (base glyph index)
MarkOverprint(usize),
} Where the indexes are the index in the |
What does that mean? What is an "anchor"? What is a "cursive anchored placement", I can't find anything about that on Google. How do I calculate the final (x, y) position of the glyph from an "anchor"? Thanks. |
An anchor is a point that the designer puts on a glyph to allow other glyphs to be aligned to. These FontForge docs describe it from a designer perspective. http://designwithfontforge.com/en-US/Diacritics_and_Accents.html#using-anchor-points-to-place-diacritics
It is gpos lookup type 3: https://docs.microsoft.com/en-us/typography/opentype/spec/gpos#lookup-type-3-cursive-attachment-positioning-subtable
You can use my in-progress code at https://github.com/yeslogic/allsorts-tools/pull/14/files as a reference. If you're able to wait a few more days, I'm working in this area each day at work. I'm currently working on SVG output support in order to be able to test Allsorts against the unicode text-rendering-tests, which will:
The intention is for the contour decomposition and positioning code to make it back into Allsorts, so you won't need to tackle this yourself. You may be wondering why we don't already have code to do that. The reason is Allsorts was created and extracted from Prince. The non-Rust Prince code currently handles glyph positioning for us. Additionally, since our target medium is PDF, we never need to interpret the glyphs themselves. We are interested in building out the library to be more general though, which is what I'm working on now. |
The
Info
struct is not documented, so I sadly have to ask if I understand it correctly:MarkPlacement
(together withis_mark
) is necessary if the glyph is a diacritic mark (such as a´
for example)(usize, Anchor, Anchor)
on theMarkPlacement
represent? What are the anchors relative to and why are there two of them? I could guess that the usize represents the order of the mark, but that's just my guess.Distance(x, y)
, but what is theAnchor
field - what are theAnchor
s relative to?is_mark
is set?position
is aenum { Glyph(Placement), MarkGlyph(MarkPlacement) }
- can a glyph have aPlacement
andMarkPlacement
at the same time?Thanks.
The text was updated successfully, but these errors were encountered: