[HarfBuzz] Alternate/random glyphs

Aleš Mlakar ales.ambits at gmail.com
Fri Feb 14 17:52:49 UTC 2020


Ok I've figured out why my actual text doesn't work correctly now, it's
because pango splits the text into parts (because of color changes etc) and
calls hb_shape on each part which then restarts the substitution logic.

Best,
Ales

On Fri, Feb 14, 2020 at 6:30 PM Aleš Mlakar <ales.ambits at gmail.com> wrote:

> Thanks guys, I've tried to turn off the rand feature (which is on by
> default in pango it seems) and it really did start working differently.
> The example image that I've sent earlier now works identically!
> My actual text doesn't seem to work 100% correctly yet, but there's some
> (per glyph) open type features there (ss01 etc) so I have to triple check
> it that it gets through correctly.
>
> Thanks for your help!
>
> Best regards,
> Ales
>
>
>
> On Fri, Feb 14, 2020 at 6:21 PM Jonathan Kew <jfkthame at gmail.com> wrote:
>
>> On 14/02/2020 15:50, Aleš Mlakar wrote:
>> > Hey Simon,
>> > I think it doesn't use rand feature, because it never gets to that part
>> > of the code or at least not to the random_number() function which is
>> the
>> > only rng function I could find in Harfbuzz :D.
>>
>> HarfBuzz will only use this if the font has a 'rand' feature with an
>> AlternateSubstFormat1 subtable, to pick from among the available
>> alternates for a glyph. You could try dumping the font's GSUB table
>> (e.g. with fonttools) to see what's actually in there.
>>
>> It's entirely possible for a font's 'rand' feature to be implemented in
>> some other way, such as a collection of contextual substitutions; then
>> no real (pseudo-)randomness is involved.
>>
>> JK
>>
>> > I did some debugging and it goes into some coverage functions inside
>> > hb-ot-layout-common.hh from hb-ot-layout-gsub-table.hh, it's too deep
>> > for me to be able to understand it though.
>> > So, as far as I can understand all of this either one of Indesign or
>> > Harfbuzz is doing it wrong.
>> >
>> > Best,
>> > Ales
>> >
>> >
>> > On Fri, Feb 14, 2020 at 1:04 PM Simon Cozens <simon at simon-cozens.org
>> > <mailto:simon at simon-cozens.org>> wrote:
>> >
>> >     On 12/02/2020 19:28, Aleš Mlakar wrote:
>> >      > I did a quick debug through that part of HarfBuzz and it seems
>> it's
>> >      > doing lookups and never gets to the random code.
>> >
>> >     OpenType randomization on the whole isn't *really* random. Most
>> fonts
>> >     implement pseudo-random selection of alternate glyphs by going
>> >     through a
>> >     series of lookup rules (see e.g. the bottom of
>> >     http://opentypecookbook.com/common-techniques.html ). As you can
>> see,
>> >     none of the techniques there actually use any source of randomness;
>> >     they
>> >     just apply deterministic rules to the input stream.
>> >
>> >     There *is* a "rand" feature in the OpenType standard, which asks the
>> >     shaper for non-deterministic random selection, but for this to work,
>> >     two
>> >     things need to be in place: the shaper needs to support it, and the
>> >     font
>> >     needs to define it. Harfbuzz as a shaper supports it, but no others
>> do.
>> >     Because of this, few fonts define it.
>> >
>> >     Even then, Harfbuzz's random number implementation is only
>> pseudorandom
>> >     with a fixed random seed, so you get the same results each time
>> anyway.
>> >
>> >     I don't know whether Daft Brush uses the "rand" feature. It probably
>> >     doesn't. Although if you are seeing differences between harfbuzz and
>> >     InDesign, it might be that it does.
>> >
>> >     In short it is down to the font.
>> >
>> >     S
>> >
>> >
>> >
>> > --
>> > Aleš Mlakar,
>> > Programmer/Consultant
>> > *am.bits*
>> >
>> > _______________________________________________
>> > HarfBuzz mailing list
>> > HarfBuzz at lists.freedesktop.org
>> > https://lists.freedesktop.org/mailman/listinfo/harfbuzz
>> >
>>
>>
>
> --
> Aleš Mlakar,
> Programmer/Consultant
> *am.bits*
>


-- 
Aleš Mlakar,
Programmer/Consultant
*am.bits*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20200214/f76f2ae8/attachment-0001.htm>


More information about the HarfBuzz mailing list