freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Progress update on adjustment database


From: Craig White
Subject: Re: Progress update on adjustment database
Date: Sat, 16 Sep 2023 19:17:35 -0400

> Yes, you should try each one, and all combinations of them.  However,
the number of features that are of interest (at least for latin
scripts) is small, which means that the number of iterations doesn't
become very large; see macro `META_STYLE_LATIN` in file `afstyles.h`
for a list.

Is testing all these combinations really necessary?  There are 9 styles listed, which is 2^9 combinations, each of which will be queried for the over 100 adjustment database entries currently listed, for a total of 5000 queries to hb_ot_shape_glyphs_closure.  My intuition says very few of these combinations actually matter.  5 are related to capital forms of letters, so it would be strange for there to be a different form of a glyph when 2 of these are enabled at once.

I wrote some pseudocode for a different approach that I believe accomplishes the same thing, while being more efficient and hopefully removing the need to constrain the set of features considered:
Definitions:
lookup(c, fs) takes a set of featues fs and a codepoint c and returns all intermediate and final forms of the glyph (same as hb_ot_shape_glyphs_closure)
"features" is a set of all features in the font, potentially reduced to only the relevant ones.

func all_glyphs(codepoint c, set<feature> fs = ∅)
{
    set<glyph_index> result = ∅
    foreach (feature f ∈ (features - fs)) //for all features not already in fs
    {
        if (lookup(c, fs) != lookup(c, fs ∪ f) //if adding the feature f to the lookup adds new glyphs to the result...
            && (lookup(c, fs ∪ f) - lookup(c, fs)) ⊈ result)  //...and at least one of these glyphs aren't already in the result list
        {
            result = result ∪ all_glyphs(c, fs ∪ f)
        }
    }
    return result
}
calling this function like all_glyphs(c) will return all variants of codepoint c.

Let me know your thoughts and questions about this algorithm.

> Please also post some images.

I attached some pictures of the tilde unflattening approaches.  I chose sizes that showcase the differences between the approaches, and also committed my current code if you would like to try it yourself.

On Tue, Sep 12, 2023 at 10:56 AM Werner LEMBERG <wl@gnu.org> wrote:

> So, if my understanding is correct, hb_ot_shape_glyphs_closure will
> take an input character or characters and tell me all the glyphs
> that it gets transformed into, as well as the final form.

Yes.

> I'm not sure about this interpretation, because the documentation
> uses the term "Transitive closure", which I'm not familiar with.

Indeed, it's a bit unfortunate that the documentation is not more
verbose.

> As for iterating through auto-hinter styles, do you mean that I
> should get a list of features and try each one for the 'features'
> parameter?

Yes, you should try each one, and all combinations of them.  However,
the number of features that are of interest (at least for latin
scripts) is small, which means that the number of iterations doesn't
become very large; see macro `META_STYLE_LATIN` in file `afstyles.h`
for a list.

> Also, I wanted to share my progress in the tilde unflattening.
> [...]

This sounds very promising, thanks!

> The segment removal should be part of the solution, but the question
> is to what extent the vertical stretch should be part of the
> solution.

My gut feeling says that both is needed.  I hope that you find
constraints that work reliably for a large bunch of (common) fonts.

To try to answer this, I tested on a bunch of fonts.
> [...]

Please also post some images.


    Werner

Attachment: tilde strategy comprison.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]