Skip to content

Commit

Permalink
Adjust glyph ranges for korean and chinese;
Browse files Browse the repository at this point in the history
  • Loading branch information
onepiecefreak3 committed Jan 11, 2025
1 parent 45638e9 commit cb005f5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
6 changes: 4 additions & 2 deletions ImGui.Forms/Factories/FontFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ private static unsafe ImVector GetGlyphRanges(FontGlyphRange rangeFlags, string
builder.AddRanges(GlyphRangeProvider.GetLatinRange());
if (rangeFlags.HasFlag(FontGlyphRange.Cyrillic))
builder.AddRanges(GlyphRangeProvider.GetCyrillicRange());
if (rangeFlags.HasFlag(FontGlyphRange.ChineseJapaneseKorean))
builder.AddRanges(GlyphRangeProvider.GetCjkRange());
if (rangeFlags.HasFlag(FontGlyphRange.ChineseJapanese))
builder.AddRanges(GlyphRangeProvider.GetCjRange());
if (rangeFlags.HasFlag(FontGlyphRange.Korean))
builder.AddRanges(GlyphRangeProvider.GetKoreanRange());
if (rangeFlags.HasFlag(FontGlyphRange.Greek))
builder.AddRanges(GlyphRangeProvider.GetGreekRange());
if (rangeFlags.HasFlag(FontGlyphRange.Thai))
Expand Down
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.3.3</version>
<version>1.3.4</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand Down
13 changes: 7 additions & 6 deletions ImGui.Forms/Models/FontGlyphRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ public enum FontGlyphRange
{
Latin = 1 << 0,
Cyrillic = 1 << 1,
ChineseJapaneseKorean = 1 << 2,
Greek = 1 << 3,
Thai = 1 << 4,
Vietnamese = 1 << 5,
Symbols = 1 << 6,
ChineseJapanese = 1 << 2,
Korean = 1 << 3,
Greek = 1 << 4,
Thai = 1 << 5,
Vietnamese = 1 << 6,
Symbols = 1 << 7,

All = 0x7F
All = 0xFF
}
}
18 changes: 15 additions & 3 deletions ImGui.Forms/Providers/GlyphRangeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ internal class GlyphRangeProvider
//0x1e030,0x1e08f
};

private static readonly ushort[] _cjkRange = new ushort[]
private static readonly ushort[] _cjRange = new ushort[]
{
0x2026,0x2026,
0x2e80,0x2fd5,
0x3000,0x303f,
0x3041,0x3096,
Expand All @@ -41,6 +42,12 @@ internal class GlyphRangeProvider
0xff01,0xff9f
};

private static readonly ushort[] _koreanRange = new ushort[]
{
0x3131, 0x3163,
0xac00, 0xd79d
};

private static readonly ushort[] _greekRange = new ushort[]
{
0x0370,0x03ff,
Expand Down Expand Up @@ -90,9 +97,14 @@ public static nint GetCyrillicRange()
return GetPointer(_cyrillicRange);
}

public static nint GetCjkRange()
public static nint GetCjRange()
{
return GetPointer(_cjRange);
}

public static nint GetKoreanRange()
{
return GetPointer(_cjkRange);
return GetPointer(_koreanRange);
}

public static nint GetGreekRange()
Expand Down

0 comments on commit cb005f5

Please sign in to comment.