---
title: "Shape Burmese (Myanmar) text in C#"
url: https://recursiveai.org/onefont/cookbook/shape-myanmar-text/
description: "Shape Unicode Burmese text into positioned glyphs in C#. See OneFont reorder the Myanmar vowel E and medial Ra with the included Noto Sans Myanmar font."
version: "1.5.1"
---

# Shape Burmese (Myanmar) text in C#

**onefont** is a free, open-source font and text-shaping library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneFont) · [GitHub](https://github.com/recursive-ai-oss/onefont-csharp) · [Docs](https://recursiveai.org/onefont/docs/) · [Download example (.zip)](https://recursiveai.org/onefont/cookbook/shape-myanmar-text/shape-myanmar-text.zip)

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.

```shell
dotnet add package RecursiveAI.OneFont
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
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](https://recursiveai.org/onefont/cookbook/shape-myanmar-text/shape-myanmar-text.zip) 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.

```text
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:

```csharp
var run = TextShaping.ShapeRun(
    "\u1004\u103A\u1039\u1000", face);
```

```text
2
187
```

Glyph `2` is the Ka base; glyph `187` is the kinzi, which follows the base for positioning.

## Related recipes

- [Shape text into glyphs](https://recursiveai.org/onefont/cookbook/shape-text/)
- [Shape text with font fallback](https://recursiveai.org/onefont/cookbook/shape-text-with-font-fallback/)
- [Convert shaped text to SVG paths](https://recursiveai.org/onefont/cookbook/text-to-svg-path/)

---

## 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](https://learn.microsoft.com/en-us/typography/script-development/myanmar) 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](https://recursiveai.org/onefont/docs/shaping/) 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.
