Beispiel #1
0
        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);
Beispiel #10
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesDefault(ImFontAtlas *self);
Beispiel #11
0
 public abstract void ImFontAtlas_SetTexID(ImFontAtlas *self, IntPtr id);
Beispiel #12
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(ImFontAtlas *self);
Beispiel #13
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesChineseFull(ImFontAtlas *self);
Beispiel #14
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas *self);
Beispiel #15
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesThai(ImFontAtlas *self);
Beispiel #16
0
 public abstract byte ImFontAtlas_IsBuilt(ImFontAtlas *self);
Beispiel #17
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesKorean(ImFontAtlas *self);
Beispiel #18
0
 public abstract void ImFontAtlas_ClearTexData(ImFontAtlas *self);
Beispiel #19
0
 public abstract void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas *self, byte **out_pixels, int *out_width, int *out_height, int *out_bytes_per_pixel);
Beispiel #20
0
 public abstract void ImFontAtlas_Clear(ImFontAtlas *self);
Beispiel #21
0
 public abstract ImFont *ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas *self, byte *compressed_font_data_base85, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
Beispiel #22
0
 public static extern bool frBuildFontAtlas(ImFontAtlas *atlas, uint extra_flags);
Beispiel #23
0
 public abstract byte ImFontAtlas_Build(ImFontAtlas *self);
Beispiel #24
0
 public ImFontAtlasPtr(IntPtr nativePtr)
 {
     NativePtr = (ImFontAtlas *)nativePtr;
 }
Beispiel #25
0
 public abstract ImFont *ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas *self, void *font_data, int font_size, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
Beispiel #26
0
 public abstract int ImFontAtlas_AddCustomRectRegular(ImFontAtlas *self, uint id, int width, int height);
Beispiel #27
0
 public abstract ImFont *ImFontAtlas_AddFontFromFileTTF(ImFontAtlas *self, byte *filename, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
Beispiel #28
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas *self);
Beispiel #29
0
 public ImFontAtlasPtr(ImFontAtlas *nativePtr) => NativePtr = nativePtr;
Beispiel #30
0
 public abstract void ImFontAtlas_CalcCustomRectUV(ImFontAtlas *self, CustomRect *rect, Vector2 *out_uv_min, Vector2 *out_uv_max);