Weird sorting behaviour breaking to new lines

I’ve been trying to debug why the sorting from my custom GlyphData.xml would end up breaking those glyphs here to new lines. It furthermore seems the sortNames aren’t really respected at all, e.g. the last glyph that gets sorted into the “row” of glyphs has sortName deva270, whereas the first “single row” glyph has deva040 and should come before those. Changing the sortName between restarts also does not seem to have an effect.

How can I debug the GlyphData to figure out “where it breaks” and what could cause this weird line breaking behaviour?

Sorting and line braking looks at the categories and subcategories, too.

Okay, but even so I have, for example, glyphs with Category ‘Letter’ and Subcategory ‘Conjunct’ here breaking to new rows after one glyph. I removed the sortName altogether to test (I suppose it falls back to name then?).

Order in the GlyphData does not matter, does it? And supposedly Category and Subcategory each force a new “row break” and inside each Category-Subcategory combination the sortName is what matters, if set, and name is used otherwise?

That is correct.

When you change the glyphData and reopen the file, you need to trigger a resorting by selecting one glyph and run “Update Glyph Info”.

Okay, essential to know :slight_smile:

But this still does not seem right. In my above screenshot the selected glyph is named (in my custom GlyphData) dvK, the one above it dvKa and the one below it dvKha.

Here’s the lines from the GlyphData:

<glyph unicode="0915" name="dvKa"  category="Letter" subCategory="Letter" script="devanagari" production="u0915" altNames="kadeva, dvKa, ka-deva" ... description="DEVANAGARI LETTER KA" />
<glyph unicode="A8EC" name="dvKacomb" sortName="DevanagariExtended13" category="Mark" subCategory="Nonspacing" script="devanagari" production="uA8EC" altNames="kacomb-deva" ... description="COMBINING DEVANAGARI LETTER KA" />
<glyph unicode="0916" name="dvKha"  category="Letter" subCategory="Letter" script="devanagari" production="u0916" altNames="kha-deva, khadeva, dvKha" ... description="DEVANAGARI LETTER KHA" />
<glyph unicode="0959" name="dvKhha"  category="Letter" subCategory="Letter" script="devanagari" production="u0959" altNames="khha-deva, dvKhha, khhadeva" ... description="DEVANAGARI LETTER KHHA" />
<glyph name="dvK"  category="Letter" subCategory="Halfform" script="devanagari" production="u0915094D" altNames="dvK, k-deva" ... description="DEVANAGARI LETTER KA" />

dvKa and dvKha are both “Letter” / “Letter” glyphs, dvK is a “Letter” / “Halfform” glyph. How come dvKa and dvKha are not on the same row, and how come dvK is between them?

Can you send me the .glyphs and the GlyphData file?

Emailed you a subset of the file + GlyphData. Thanks for taking a look.

You need to leave the subCategory blank for the full forms (dont’t put “Letter” in subCategory).

And, by the way, you don’t need a custom glyph data for most of your glyphs. The cvXX scheme is supported with the altNames attribute.

I’m reviving this thread because I am still struggling to really understand what is going on with this sorting.

Take this example GlyphData.xml:

<glyph name="Gmacron" category="Letter" subCategory="Uppercase" script="latin" unicode="1E20" production_name="u1E20" decompose="G, macroncomb" description="LATIN CAPITAL LETTER G WITH MACRON" altNames="Gmacron" />
<glyph name="Gobliquestroke" category="Letter" subCategory="Uppercase" script="latin" unicode="A7A0" production_name="uA7A0" description="LATIN CAPITAL LETTER G WITH OBLIQUE STROKE" altNames="Gobliquestroke" />
<glyph name="Gscript" category="Letter" subCategory="Uppercase" script="latin" unicode="A7AC" production_name="uA7AC" description="LATIN CAPITAL LETTER SCRIPT G" altNames="Gscript" />
<glyph name="Gtilde" category="Letter" subCategory="Uppercase" script="latin" production_name="u00470303" decompose="G, tildecomb" description="LATIN CAPITAL LETTER G WITH TILDE" />
<glyph name="Gturnedinsular" category="Letter" subCategory="Uppercase" script="latin" unicode="A77E" production_name="uA77E" description="LATIN CAPITAL LETTER TURNED INSULAR G" altNames="Gturnedinsular" />
<glyph name="H" category="Letter" subCategory="Uppercase" script="latin" unicode="0048" production_name="u0048" anchors="top, bottom, center, topleft" accents="circumflexcomb, barlongcomb" description="LATIN CAPITAL LETTER H" altNames="H" />
<glyph name="Halfh" category="Letter" subCategory="Uppercase" script="latin" unicode="2C75" production_name="u2C75" anchors="top, bottom" accents="caroncomb, gravecomb, acutecomb, circumflexcomb, tildecomb, dieresiscomb, macroncomb, brevecomb, dotbelowcomb, macronbelowcomb" description="LATIN CAPITAL LETTER HALF H" altNames="Halfh" />
<glyph name="Hbar" category="Letter" subCategory="Uppercase" script="latin" unicode="0126" production_name="u0126" decompose="H, barlongcomb" description="LATIN CAPITAL LETTER H WITH STROKE" altNames="Hbar" />
<glyph name="Hbrevebelow" category="Letter" subCategory="Uppercase" script="latin" unicode="1E2A" production_name="u1E2A" decompose="H, brevebelowcomb" description="LATIN CAPITAL LETTER H WITH BREVE BELOW" altNames="Hbrevebelow" />

And yet I am seeing:

And then waaaay later another section of Letter, Latin that has the Gtilde (plus various intersected sections with one or two glyphs only)

What is the exact algorithm that determines sorting?!

I am assuming category and subCategory have to be one of the GlyphApps define values (or do they?!). I am assuming the sorting is script > category > subCategory > sortName > name. Does GlyphData.xml order matter? When does it use GlyphsApp fallbacks?

Can you run “update glyph info” for one if the glyphs. Just to trigger a sorting.

Aha! That sorted it.

Should maybe restarting the app and opening a file also trigger the sorting?

So are may stated assumptions regarding sorting correct? It would be really helpful, if it just said so in the tutorial, if that is indeed the only place this is covered.

Also, is there a way to have some categories twice?
Imagine e.g. wanting to have ASCII first separated in the category of its glyphs, and then later one category after the other.

Can I use arbitrary sub/categories for this?

The order is preserved so that you have a chance when you open an older file and it would sorted differently because of GlyphData or algorithms changed.

You can add your own subCategories. There is a default sorting for the existing categories/subcategories. But you can experiment with your own.

If I add a category “Basic”, is there a way for it to come as the first?

Also, could you just outline what is the sorting logic? It is infuriating tapping around in the dark like this.

I have the same GlyphData.xml content, but I get different sorting results if I a) write them to file in arbitrary order or b) write them to the file sorted by script > category > subCategory > name — should this or should this not be the case and why or what does affect the sorting beyond those attributes?

Also, why does sortName=“_A” come after name=“Z” of same category/subCategory/script without sortName

Can you please document this. :triumph:

This is just how symbols sort in macOS, the underscore comes after the letters, period and space come before:


Also coming back to this. That contradicts what you said above, no? Why would creating a subCategory of things I want to group together not group them together?!

Thanks for clarifying. Folders on Mac sort _ABC and python sorts _ABC so it is not entirely clear to my why that would be. What symbols are you talking of? Does Objective C really sort in a different manner?