mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
Fix CreateImGuiRangesFrom to omit null char (#1709)
* Fix CreateImGuiRangesFrom to omit null char UnicodeRanges.BasicLatin is [0, 127], but ImGui stops reading the glyph range list on encountering a zero. Fixed that by ensuring that 0 never appears in the glyph range list. * Make problems explicit --------- Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
parent
87b9edb448
commit
e52c2755cb
4 changed files with 51 additions and 9 deletions
|
|
@ -493,12 +493,13 @@ public static class ImGuiHelpers
|
|||
/// <returns>The range array that can be used for <see cref="SafeFontConfig.GlyphRanges"/>.</returns>
|
||||
public static ushort[] CreateImGuiRangesFrom(IEnumerable<UnicodeRange> ranges) =>
|
||||
ranges
|
||||
.Where(x => x.FirstCodePoint <= ushort.MaxValue)
|
||||
.Select(x => (First: Math.Max(x.FirstCodePoint, 1), Last: x.FirstCodePoint + x.Length))
|
||||
.Where(x => x.First <= ushort.MaxValue && x.First <= x.Last)
|
||||
.SelectMany(
|
||||
x => new[]
|
||||
{
|
||||
(ushort)Math.Min(x.FirstCodePoint, ushort.MaxValue),
|
||||
(ushort)Math.Min(x.FirstCodePoint + x.Length, ushort.MaxValue),
|
||||
(ushort)Math.Min(x.First, ushort.MaxValue),
|
||||
(ushort)Math.Min(x.Last, ushort.MaxValue),
|
||||
})
|
||||
.Append((ushort)0)
|
||||
.ToArray();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue