Any app that support OpenType "rand" feature?

I just noticed the "rand" feature in the official Microsoft list of OpenType features and it made me wonder if anyone is aware of an application that actually supports it?
«1

Comments

  • I believe PagePlus supports it.

    FontCreator also supports it in the OpenType Designer.
  • AbrahamLee
    AbrahamLee Posts: 262
    Thanks @Erwin Denissen for the info. Looks like FontForge also supports it. That's so cool!
  • Khaled Hosny
    Khaled Hosny Posts: 289
    edited July 2017
    Support in font editors does not require anything special as it is just a multiple alternates feature. Support in applications is a different story and AFAIK no mainstream application of OpenType layout engine supports it.
  • AbrahamLee
    AbrahamLee Posts: 262
    Support in font editors does not require anything special as it is just a multiple alternates feature. Support in applications is a different story and AFAIK no mainstream application of OpenType layout engine supports it.
    Understood. Just because a feature is an option, doesn't mean any apps know what to do with it.
  • Kent Lew
    Kent Lew Posts: 944
    To support a {rand} feature in a page layout app, something more than just the font and text engine would be required. A routine needs to be included to generate random numbers, then use that result to make a selection from the one-from-many GSUB table registered to the feature.

    The generator would need to first parse out how many options there are to choose from for any given character and tailor the random number generation to that limit on a character-by-character basis.

    It can’t be done from within the font itself. So, it falls to the developers to implement all this randomness and hook it up to the text engine. Plenty of extraneous processing that I imagine layout app developers probably won’t ever be inclined to bother with.
  • Affinity Designer supports rand.
  • Mark Simonson
    Mark Simonson Posts: 1,739
    edited July 2017
    I thought {rand} was not supported at all, deprecated even. Why else would there be so many examples over the years simulating the effect of such a feature, but using {calt}?
  • Khaled Hosny
    Khaled Hosny Posts: 289
    The biggest issue preventing support for “rand” feature is, well, the randomness. Many implementations and applications need predictable results; if you give it the same text, font, and set of features to switch, it should always give the same output so it can be cached and reused as needed. You don’t want your page to re-flow every time you scroll it! So the randomness needs to be pseudo random with reproducible results. Very few people are interested in figuring all this out.

    I’m pretty sure that is another example of features specified before there were any implementations or clear understanding of what OpenType was going to end up like, as @John Hudson said multiple times.
  • Not deprecated. 

    There is latitude in the spec for stepping through the alternates or seeding the alternates assigning numbers to them and what not.

    I believe Serif did the easiest with stepping through them.

    But once the glyph swap has occurred, there isn't reflow issues. In that sense it is no different than any gsub once it occurs. 
  • John Hudson
    John Hudson Posts: 3,230
    But once the glyph swap has occurred, there isn't reflow issues. In that sense it is no different than any gsub once it occurs. 
    It's a little different in that if you were to turn the feature off and back on again, the randomisation routine would presumably run again, which means that you would have no guarantee of getting back the same substitutions that you had previously. Depending how implemented, even Undo results might be unpredictable.

  • Mark Simonson
    Mark Simonson Posts: 1,739
    Although I think they have done a great job with implementing OT features in Affinity Designer in the most recent version, it was pretty rough at first. For quite a while, they had implemented {calt} completely wrong (flipping back and forth between normal and alternate forms, seemingly ignoring the feature code). So I'm curious what they've done with {rand}. I guess I could make a test font and try it out (I do have Designer).
  • AbrahamLee
    AbrahamLee Posts: 262
    @Kent Lew: Nearly all (or all) programming languages have routines for random number generation, which means that it should be fairly painless because all you need to do is use them, not create them. I can't imagine that would be a limitation for not having it. On the other hand, not having enough fonts out there that use the feature to want to support it, that's a reason I can understand.

    @Mike Wenzloff: Thanks for the pointer to Affinity Designer. I'll look into that. Do many folks here use it? I've considered getting it myself. It looks really nice, but it would have to be so much easier for me to use than Inkscape to get me to swap. But I digress.

    @Mark Simonson: Unless you want very controlled, predictable substitutions via {calt} (which some people abuse to get the affect of randomness), using {rand} would be SOOO much easier to implement. From the app designer's perspective, the text engine would simply need a routine to goes something like this: When you encounter the glyph, pull a random integer i between 0 and N (where N is the number of alternate glyphs available) and then grab the glyph at the th index. It's quite straightforward. I've done this very thing myself.

    @Khaled Hosny: Although I can completely understand what you're saying about re-flow, I think the people who would actually be using it wouldn't care if it did happen because they would be more interested in the randomness. At least I would.
  • Khaled Hosny
    Khaled Hosny Posts: 289
    edited July 2017
    @AbrahamLee the people might not care, but application developers do. For example many applications cache the shaping results per word, so they expect that a word appearing anywhere in the document will be shapped the same (when using same font and feature), so “random” glyph substitution have to be deterministic or this promise is broken which either means degraded performance (by disabling caching entirely when “rand” is used or broken layout.

  • Support in font editors does not require anything special as it is just a multiple alternates feature. Support in applications is a different story and AFAIK no mainstream application of OpenType layout engine supports it.
    The preview feature in our font editor mimics how word processing applications can handle it. It is pretty easy with a fixed random seed, so it remains "predictable random" and no reflow issues. For us it was basically these lines of code:

    &nbsp; // At first<br>&nbsp; RandSeed := 123;<br><br>&nbsp; // Then while processing lookups:<br>&nbsp; if Feature = Randomize then<br>&nbsp;&nbsp;&nbsp; AlternateIndex := Random(AlternatatesCount);




  • Thanks for the correction, John. 

    Other than testing, I guess I hadn't ever turned the feature on/off and paid any close attention.

    So this is what I get in AD. Feature on, feature off, feature back on.


    The font was one that Erwin prepared using calt that I repurposed to using rand.
  • Nick Shinn
    Nick Shinn Posts: 2,216
    edited July 2017
    Randomness isn’t much use unless you randomize glyph generation, as per Beowolf.
    With a limited number of alternates, randomization will give you the same alternate side-by-side, from time to time, which doesn’t look “random”.
    What’s really sought is non-repetition of glyphs, which is the purpose of pseudo-randomization.

    I’ve written a code for pseudo-randomizing four sets of characters, that non-repeats for a sequence of up to nine characters in a text stream—but it doesn’t address the problem of each line starting out with the same glyph of a character.  
  • I think the rand feature is OK. Seemingly poor application support. I think that, for myself, I would only really have the feature on in a drawing application such as AD if doing certain types of design work. Even then I don't know if I would use that feature or simply choose from whatever alternates were present. CorelDraw has what I consider the best UI for such work with OT features (SS, alts, etc.). Makes it dead easy to swap things around while designing.

    What I cannot see it used for on my end is an actual layout application with longer runs of text. At least for what I layout that feature makes little sense. Especially seeing how layout application support for features I do use is so spotty—or simply not supported.
  • AbrahamLee said:...

    @Mike Wenzloff: Thanks for the pointer to Affinity Designer. I'll look into that. Do many folks here use it? I've considered getting it myself. It looks really nice, but it would have to be so much easier for me to use than Inkscape to get me to swap. But I digress.
    ...
    I certainly keep an eye on it. I try to like it but I believe there are work-flow issues and just plain oddness in certain features. I don't illustrate and that is one type of work I think they target. But there are too many features missing or implemented poorly for me to use it daily for actual work. One for instance is seeing the bleed amount without a work-around. Kinda dumb. But there are other issues for my work.

    That said, it probably does have one of the fullest OT feature implementations that just work. More to be done in this regards, but Dave H of Serif has done a good job and is very receptive to correction and or suggested additions. I think that if nothing else it is a good application for the testing of OT Features, which is what I mostly use it for.

    I wrote a hist feature that replies on chaining contexts for handling the medial s (long s) for some journals I laid out. For ID, because it doesn't support hist directly, I had to test well in AD, then stuffed that work into an SS for ID and QXP (but QXP has issues with matching too early with chaining contexts and then moving on). Using AD to test features is for me a prime application.

    Mike
  • John Hudson
    John Hudson Posts: 3,230
    Mike,
    So this is what I get in AD. Feature on, feature off, feature back on.
    To clarify: reversibility is going to depend on how the rand feature is implemented in software. If cycling through the variants and always starting the cycle in the same way, or using pre-seeded pseudo-randomisation, then you will get reversible results, i.e. always the same 'randomisation' of substitutions for the same input text. But if the implementation were to actually generate random numbers to select variants, then you would expect different results every time the feature was applied.
  • RaseOne
    RaseOne Posts: 9
    Hello everyone. I've been researching & experimenting with the rand feature for a while now. I understand that InDesign & maybe even Photoshop now support this feature when the world-ready type engine is activated & I've read about it in the Microsoft spec as well as in a few threads in this forum and elsewhere.... but I'm unable to get it to do anything. It's totally inert. I understand that there is no UI element to turn it on/off in the Adobe apps but my understanding is that it should be active by default. I'm starting to think I'm writing the feature itself wrong. I've searched high & low for code samples but I've not found a single one. I figured it should look something like this:

    feature rand {
      sub a by a.1 a.2 a.3;  
      sub b by b.1 b.2 b.3; 
      sub c by c.1 c.2 c.3;  
      # ... and so on for other glyphs
    } rand;

    I see that Mike Wenzloff has made it work above so it's obviously possible. I must be missing something on a funfdamental level. Any help would be appreciated.
  • It seems to me that it would be more correct:

    rand function {
    sub exclude from [a1 a2 a3 a4 a5 a6 a7];
    } rand;

    In Photoshop 2021, you need to enable "rand".
    1) Edit > Settings > Type.
    2) Select "World-Ready Layout".
    3) Go to the paragraphs panel and select the "World-Ready Layout" from the context menu.

  • Is there a test font available? Would love to see what the browsers are doing.

  • You can test any opentype feature in Adobe Indesign using this fantastic free script!:
    https://github.com/RolandDreger/open-type-features
  • RaseOne said:

    I've searched high & low for code samples but I've not found a single one. I figured it should look something like this:

    feature rand {
      sub a by a.1 a.2 a.3;  
      sub b by b.1 b.2 b.3; 
      sub c by c.1 c.2 c.3;  
      # ... and so on for other glyphs
    } rand;
    You only want one of the possible output glyphs, instead of all of them. So instead of “by” you need “from” and a grouping, like this:

    sub a from [a.1 a.2 a.3];

    Leastways, that is how I remember it. Haven’t coded that sort of thing in a while now.
  • I forgot about this repo, thanks for sharing. As expected, rand doesn't work in any browser I tried. Fun fact: setting a different value for rand (e.g. `font-feature-settings: 'rand' 3`) does show the other versions of a glyph.
  • As expected, rand doesn't work in any browser I tried.
    Win11. Firefox and Edge:



  • Neat! I guess Windows has `rand` implemented on OS level.
  • Edge is based on Chromium, with its own renderer, and Firefox has its own renderer. If “rand” is part of Windows itself now, which I’m not convinced it is, there are multiple places it could be implemented, for example XAML only, Uniscribe, God knows where. But I’m pretty sure the browsers have their own rendering engines.
  • Holy schnikes, indeed! I was playing around with https://simoncozens.github.io/feature-tags/ and seeing the same A repeated when the feature was turned on.

    Seems like the rand feature is enabled by default, and `font-feature-settings: 'rand' 0` turns it off, and any other numeric value gets the those specific glyphs:



    It's only when not setting the feature at all that the random characters appear:



    As far as I know, seeing that you can only pass `on`, `off` or numeric values to `font-feature-settings` there doesn't seem to be a way to simply turn it on. Maybe that's why this feature is enabled by default?

    On Mac it works on Chrome and Firefox too, but not in Safari.