Weird sorting behaviour breaking to new lines

This just does not make sense. I removed sortName (because you have yet to actual clarify how it affects sorting), they all have same script, same category, but different subCategory.

<glyph name="dvVocalicRr" category="Letter" subCategory="Matra" script="devanagari" unicode="0960" ...
... end Matra subCategory ...
<glyph name="dvB" category="Letter" subCategory="Barfoo" script="devanagari" ...
...
<glyph name="dvJh" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvK" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvKR" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvKSs" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvKSsM" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvKh" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvKhh" category="Letter" subCategory="Barfoo" script="devanagari" ...
<glyph name="dvL" category="Letter" subCategory="Barfoo" script="devanagari" ...
...
<glyph name="dvZ" category="Letter" subCategory="Barfoo" script="devanagari" ...
... end Barfoo subCategory ...
...
<glyph name="dvZZa" category="Letter" subCategory="Conjunct" script="devanagari" ...
... end Conjung subCategory ...
<glyph name="dvBa" category="Letter" subCategory="Foobar" script="devanagari" unicode="092C" ...
...
<glyph name="dvJja" category="Letter" subCategory="Foobar" script="devanagari" unicode="097C" ...
<glyph name="dvKa" category="Letter" subCategory="Foobar" script="devanagari" unicode="0915" ...
<glyph name="dvKha" category="Letter" subCategory="Foobar" script="devanagari" unicode="0916" ...
<glyph name="dvKhha" category="Letter" subCategory="Foobar" script="devanagari" unicode="0959" ...
<glyph name="dvLa" category="Letter" subCategory="Foobar" script="devanagari" unicode="0932" ...
...
<glyph name="dvZha" category="Letter" subCategory="Foobar" script="devanagari" unicode="0979" ...
... end Foobar subCategory ...

And yet, where (mostly) violet is “Foobar” green is “Barfoo”.

Suspiciously dvKa, with the lowest unicode, comes as the first of all Foobar glyphs, not dvBa as one might expect looking at the GlyphData. And then dvK coming after dvKa and not dvKha just…

It might be that the internal glyph data is interfering. Because for some attributes, the local one is just amending the existing entries. So you should run this script to know what is actually used:

for l in Font.selectedLayers:
    g = l.parent
    print(g.name, g.sortName(), g.subCategory)

Could you send me your .glyphs and GlyphData file? And what sorting are you trying to achieve (Ka K Kha Kh or Ka Kha K Kh)

Sent you the sample files.

For the Devanagari glyphs here that are “one per line” the script output is:

(u'dvKa', u'deva040', u'Foobar')
(u'dvK', u'deva042', u'Barfoo')
(u'dvKha', u'deva044', u'Foobar')
(u'dvKh', u'deva046', u'Barfoo')
(u'dvGa', u'deva048', u'Foobar')
(u'dvG', u'deva050', u'Barfoo')
(u'dvGha', u'deva052', u'Foobar')

So sortName > Category? What about subCategory, name, script?!

Also note that the GlyphData.xml I sent you and used here does not have sortNames… so it seems GlyphApp uses sortName from the App folder, and if glyphs are sorted and their subcategory varies they break to new lines? So I cannot actually use the subCategory to sort like I want, but need to explicitly overwrite each sortName?!

Can you PLEASE just state what is the full sorting logic.

Even when I remove category, subCategory and explicitly add a sortName to overwrite the inherited one, the ordering is BS.

I’ve set a sortName for dvB, yet this is the script output for three consecutive glyphs:

(u'dvBa', u'deva132', u'Letter', u'Other')
(u'dvB', u'deva001', u'Letter', u'Other')
(u'dvBha', u'deva136', u'Letter', u'Other')

dvB should be first. This is frustrating, to say the least.

As a fallback I am trying to get my desired sorting by manually writing the glyphOrder via glyphsLib but can’t get around GlyphsApp’s behaviour to not update the interface until manually triggered in the app.

How can I save the file in a way GlyphsApp will automatically update the interface to reflect the state of glyphOrder in the file?


I’d still also be curious as to how to get the GlyphData xml to behave in any predictable way.

I had a look last night and the sorting is strange. Need to look into this more. I don’t think it is the fault of the GlyphData. Because it did sort correct when I removed all other glyphs.

1 Like

I use a custom glyphData as well. If that can help:

  • custom categories can be sorted by appending a number in front of their name, eg: 01 Caps
  • each glyph in the glyphData has a sortName that is a number. To avoid large reordering when updating the glyphData, the number is like xx_xxx where the first two are the category number and the last three the number inside that category.
    I haven’t had weird results with glyph sorting since I’ve been using this system. Of course you should make a script to help with actually writing the xml file because that is tedious by hand.