Skip to content

Guess glyph string for placeholder glyphs without code points - #2010

Merged
justvanrossum merged 7 commits into
fontra:mainfrom
aliftype:guess-placeholder-string
Apr 11, 2025
Merged

Guess glyph string for placeholder glyphs without code points#2010
justvanrossum merged 7 commits into
fontra:mainfrom
aliftype:guess-placeholder-string

Conversation

@khaledhosny

Copy link
Copy Markdown
Contributor

See the discussion in #2005

This works in the font overview, but I didn’t manage to find the relevant code in editor, so editing such glyphs still does not shows blank placeholder.

@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch 2 times, most recently from 7d8e70c to 5b939de Compare February 8, 2025 21:35
@justvanrossum

Copy link
Copy Markdown
Member

Thank you very much!

I wonder if the same can be achieved with the "associatedCodePoints" feature. This does roughly the same (including the "_" split), except it also takes the font's cmap/glyphMap into account, and only falls back to glyphs-data if the font doesn't define the base glyph name.

I think we can add associatedCodePoints as an (optional?) argument to the GlyphCell constructor.

Alternatively, we could consider decoupling the making of the placeholder string from the GlyphCell completely, and pass the placeholder string as an additional argument to the GlyphCell constructor.

As for the placeholder string in the canvas: let's indeed focus on the GlyphCell first, and I'll try to figure out what we need to do to make it work in the canvas, too.

@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch from 5b939de to 01a4a14 Compare March 3, 2025 15:28
@khaledhosny

Copy link
Copy Markdown
Contributor Author

I wonder if the same can be achieved with the "associatedCodePoints" feature.

The main difference between associatedCodePoints and this placeholder string is that I insert ZWJ before and/or after the code point to force an Arabic positional form.

Take for example the four glyphs beh-ar, beh-ar.init, beh-ar.medi, and beh-ar.fina. The associatedCodePoints for the last three would be the code point for beh-ar, so using this would show the same fallback for all the four glyphs. Instead, I insert ZWJ after the code point in .init to force initial form, before the code point in .fina to force final form, and before and after the code point in .medi to force the medial form.

Is there is a way to achieve this with associatedCodePoints?

@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch 4 times, most recently from 3e9ce97 to ef62a08 Compare March 3, 2025 22:23
@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch 2 times, most recently from c4e779c to ed23009 Compare March 24, 2025 00:49
@justvanrossum

Copy link
Copy Markdown
Member

(Thanks for keeping this up to date, I'll try to continue reviewing this soon. I am eager to land this feature.)

@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch from ed23009 to bb3b0ae Compare April 6, 2025 02:33

@justvanrossum justvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very good, thank you. I left some minor notes, and a suggestion how to maybe fix the context.direction = "rtl"; line.

Comment thread src-js/fontra-core/src/utils.js Outdated
Comment thread src-js/fontra-core/src/glyph-data.js
Comment thread src-js/views-editor/src/visualization-layer-definitions.js Outdated
Guess placeholder string from glyph name for glyphs without code points.
Checks for the extensions used for Arabic positional forms and add Zero
Width Joiner as appropriate to force the desired positional form.

The glyph-shape-placeholder div needs dir="auto" as ZWJ gets ignored at
string boundaries if text direction is LTR (which is the default in
HTML). With dir="auto", the direction will be resolved based on the
string, so it will be RTL for Arabic text.
@khaledhosny
khaledhosny force-pushed the guess-placeholder-string branch from bb3b0ae to 3ffe090 Compare April 10, 2025 16:17
If one of the ligature components is an unknown glyph name, don’t return
a partial string covering the other components only.
Comment thread src-js/fontra-core/src/glyph-data.js Outdated
Comment thread src-js/fontra-webcomponents/src/glyph-cell.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants