notofonts / noto-build

Scripts, data and libraries to work with Noto fonts and sources
Apache License 2.0
5 stars 2 forks source link

CLI: Swap #4

Open davelab6 opened 4 years ago

davelab6 commented 4 years ago

The readme said there will be a --swap argument to put alternates as default (eg I.alt and J.alt, but also tabular figures, etc).

I'm filing this to track that implementation and update the readme

jbmorizot commented 3 years ago

The feature has been added. The --swap argument accept the "altIJ", "tosf", "osf" and "lining" as argument. It puts (in LGC fonts) the alternate glyphs as default by remapping the cmap. It works, but changing numbers breaks the substitutions that involves figures: 'frac' is not working anymore. A workaround could be to update the OT features in the source files: for exemple by adding a sub [zero.osf etc] by [zero.numr ect]; in the features. Right now 'frac' comes before the osf substitution and doesn't need to consider other figures than the default ones, so editing this should do the job.

jbmorizot commented 3 years ago

Maybe something like that:

lookup FRAC {
    sub slash by fraction;
} FRAC;
lookup UP {
    sub [zero one two three four five six seven eight nine] by [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr];
    sub [zero.lf one.lf two.lf three.lf four.lf five.lf six.lf seven.lf eight.lf nine.lf] by [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr];
    sub [zero.osf one.osf two.osf three.osf four.osf five.osf six.osf seven.osf eight.osf nine.osf] by [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr];
    sub [zero.tosf one.tosf two.tosf three.tosf four.tosf five.tosf six.tosf seven.tosf eight.tosf nine.tosf] by [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr];
} UP;
lookup DOWN {
    sub fraction [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr]' by [zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom];
    sub [zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom] [zero.numr one.numr two.numr three.numr four.numr five.numr six.numr seven.numr eight.numr nine.numr]' by [zero.dnom one.dnom two.dnom three.dnom four.dnom five.dnom six.dnom seven.dnom eight.dnom nine.dnom];
} DOWN;