public unsafe List <ushort> BuildRanges() { ImFontAtlas * atlas = (ImFontAtlas *)0; List <ushort> ranges = new List <ushort>(); if ((GlyphRanges & ScriptGlyphRanges.Default) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesDefault(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Cyrillic) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesCyrillic(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Japanese) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesJapanese(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Korean) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesKorean(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Thai) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesThai(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Vietnamese) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesVietnamese(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.ChineseSimplified) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.ChineseFull) != 0) { AddRangePtr(ImGuiNative.ImFontAtlas_GetGlyphRangesChineseFull(atlas)); } if ((GlyphRanges & ScriptGlyphRanges.Custom) != 0) { foreach (Range range in CustomGlyphRanges) { ranges.AddRange(new[] { range.Start, range.End }); } } return(ranges); void AddRangePtr(ushort *r) { while (*r != 0) { ranges.Add(*r++); } }; }
private unsafe void SetFonts() { var folder = "fonts"; var files = Directory.GetFiles(folder); if (!(Directory.Exists(folder) && files.Length > 0)) { return; } var fontsForLoad = new List <(string, int)>(); if (files.Contains($"{folder}\\config.ini")) { var lines = File.ReadAllLines($"{folder}\\config.ini"); foreach (var line in lines) { var split = line.Split(':'); fontsForLoad.Add(($"{folder}\\{split[0]}.ttf", int.Parse(split[1]))); } } var sm = new ImFontAtlas(); ImFontAtlas *some = &sm; var imFontAtlasGetGlyphRangesCyrillic = ImGuiNative.ImFontAtlas_GetGlyphRangesCyrillic(some); fonts["Default:13"] = new FontContainer(ImGuiNative.ImFontAtlas_AddFontDefault(some, null), "Default", 13); foreach (var tuple in fontsForLoad) { var bytes = Encoding.UTF8.GetBytes(tuple.Item1); fixed(byte *f = &bytes[0]) { fonts[$"{tuple.Item1.Replace(".ttf", "").Replace("fonts\\", "")}:{tuple.Item2}"] = new FontContainer( ImGuiNative.ImFontAtlas_AddFontFromFileTTF(some, f, tuple.Item2, null, imFontAtlasGetGlyphRangesCyrillic), tuple.Item1, tuple.Item2); } } Settings.Font.Values = new List <string>(fonts.Keys); }
public abstract byte ImFontAtlas_GetMouseCursorTexData(ImFontAtlas *self, ImGuiMouseCursor cursor, Vector2 *out_offset, Vector2 *out_size, Vector2 *out_uv_border, Vector2 *out_uv_fill);
public abstract CustomRect *ImFontAtlas_GetCustomRectByIndex(ImFontAtlas *self, int index);
public abstract void ImFontAtlas_ClearInputData(ImFontAtlas *self);
public abstract ImFont *ImFontAtlas_AddFont(ImFontAtlas *self, ImFontConfig *font_cfg);
public abstract IntPtr igCreateContext(ImFontAtlas *shared_font_atlas);
public abstract int ImFontAtlas_AddCustomRectFontGlyph(ImFontAtlas *self, ImFont *font, ushort id, int width, int height, float advance_x, Vector2 offset);
public abstract void ImFontAtlas_ImFontAtlas(ImFontAtlas *self);
public abstract ushort *ImFontAtlas_GetGlyphRangesDefault(ImFontAtlas *self);
public abstract void ImFontAtlas_SetTexID(ImFontAtlas *self, IntPtr id);
public abstract ushort *ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(ImFontAtlas *self);
public abstract ushort *ImFontAtlas_GetGlyphRangesChineseFull(ImFontAtlas *self);
public abstract ushort *ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas *self);
public abstract ushort *ImFontAtlas_GetGlyphRangesThai(ImFontAtlas *self);
public abstract byte ImFontAtlas_IsBuilt(ImFontAtlas *self);
public abstract ushort *ImFontAtlas_GetGlyphRangesKorean(ImFontAtlas *self);
public abstract void ImFontAtlas_ClearTexData(ImFontAtlas *self);
public abstract void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas *self, byte **out_pixels, int *out_width, int *out_height, int *out_bytes_per_pixel);
public abstract void ImFontAtlas_Clear(ImFontAtlas *self);
public abstract ImFont *ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas *self, byte *compressed_font_data_base85, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
public static extern bool frBuildFontAtlas(ImFontAtlas *atlas, uint extra_flags);
public abstract byte ImFontAtlas_Build(ImFontAtlas *self);
public ImFontAtlasPtr(IntPtr nativePtr) { NativePtr = (ImFontAtlas *)nativePtr; }
public abstract ImFont *ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas *self, void *font_data, int font_size, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
public abstract int ImFontAtlas_AddCustomRectRegular(ImFontAtlas *self, uint id, int width, int height);
public abstract ImFont *ImFontAtlas_AddFontFromFileTTF(ImFontAtlas *self, byte *filename, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
public abstract ushort *ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas *self);
public ImFontAtlasPtr(ImFontAtlas *nativePtr) => NativePtr = nativePtr;
public abstract void ImFontAtlas_CalcCustomRectUV(ImFontAtlas *self, CustomRect *rect, Vector2 *out_uv_min, Vector2 *out_uv_max);