Pass Burmese text in typing order to ShapeRun. The zip’s myanmar.ttf is a Noto Sans Myanmar subset. Use Unicode Myanmar text, not Zawgyi.
dotnet add package RecursiveAI.OneFontRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneFont; var face = FontFace.Load( File.ReadAllBytes("myanmar.ttf")); // Ka, medial Ra, vowel E (ကြေ). var run = TextShaping.ShapeRun( "\u1000\u103C\u1031", face); foreach (var cluster in run) foreach (var glyph in cluster.Glyphs) Console.WriteLine(glyph.GlyphId);
If a cluster has HasMissingGlyph set, use a face with coverage for the cluster rather than treating the missing glyph as a valid shape.
Paste the code above into Program.cs of a new dotnet new console project and dotnet run, or unzip the example and dotnet run.
If you paste the code, put myanmar.ttf from the zip next to Program.cs, or put another Noto Sans Myanmar font file there and change the filename in the code.
Prints the glyph IDs in the order returned for this cluster: vowel E, medial Ra, then Ka.
370 196 2
Variations
Shape a kinzi above a consonant
Replace the run declaration with the following. The first three code points form the kinzi, the mark to be placed above the base:
var run = TextShaping.ShapeRun( "\u1004\u103A\u1039\u1000", face);
2 187
Glyph 2 is the Ka base; glyph 187 is the kinzi, which follows the base for positioning.
Related recipes
The short answer
Load a Unicode Myanmar font and call TextShaping.ShapeRun on the original string. No script override is needed for the Myanmar text above. Read the glyphs from each cluster and keep the original text for storage and editing. The program prints glyph IDs so you can see the reordered sequence without drawing it.
How is the Burmese alphabet written in Unicode text?
Encode consonant Ka (U+1000), medial Ra (U+103C) and vowel sign E (U+1031) in that logical order. The fact that the vowel displays before the consonant does not mean it should come first in the string. Microsoft’s Myanmar shaping guide describes the difference between encoded order and the glyph sequence used for layout.
Keep the input unchanged and let the shaper do the reordering. For this cluster, OneFont moves the vowel E to the start and the medial Ra just before the base. Looking up one glyph per code point with GetGlyphIndex doesn’t perform that step. Reversing the string doesn’t do it either and can separate a mark from its base.
How do Myanmar fonts form stacked consonants and kinzi?
OneFont recognizes a consonant followed by asat and virama before another consonant as a kinzi. It places the kinzi directly after the base in the glyph sequence so the font’s above-base lookups can position it. A virama joining two consonants can instead select the font’s stacked form. These are different cases even though both use the virama code point.
Glyph IDs aren’t Unicode values and aren’t portable between fonts. When drawing, use the same face you shaped with and apply the returned advances and offsets, not just the order printed here. A mark can have zero advance but still have a positioning offset. Keep the cluster’s source range with the glyphs so selection or caret logic can refer back to the original string rather than to each reordered glyph as if it were a separate character.