예제 #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++);
                }
            };
        }
예제 #2
0
        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);
        }
예제 #3
0
 public abstract byte ImFontAtlas_GetMouseCursorTexData(ImFontAtlas *self, ImGuiMouseCursor cursor, Vector2 *out_offset, Vector2 *out_size, Vector2 *out_uv_border, Vector2 *out_uv_fill);
예제 #4
0
 public abstract CustomRect *ImFontAtlas_GetCustomRectByIndex(ImFontAtlas *self, int index);
예제 #5
0
 public abstract void ImFontAtlas_ClearInputData(ImFontAtlas *self);
예제 #6
0
 public abstract ImFont *ImFontAtlas_AddFont(ImFontAtlas *self, ImFontConfig *font_cfg);
예제 #7
0
 public abstract IntPtr igCreateContext(ImFontAtlas *shared_font_atlas);
예제 #8
0
 public abstract int ImFontAtlas_AddCustomRectFontGlyph(ImFontAtlas *self, ImFont *font, ushort id, int width, int height, float advance_x, Vector2 offset);
예제 #9
0
 public abstract void ImFontAtlas_ImFontAtlas(ImFontAtlas *self);
예제 #10
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesDefault(ImFontAtlas *self);
예제 #11
0
 public abstract void ImFontAtlas_SetTexID(ImFontAtlas *self, IntPtr id);
예제 #12
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(ImFontAtlas *self);
예제 #13
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesChineseFull(ImFontAtlas *self);
예제 #14
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesCyrillic(ImFontAtlas *self);
예제 #15
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesThai(ImFontAtlas *self);
예제 #16
0
 public abstract byte ImFontAtlas_IsBuilt(ImFontAtlas *self);
예제 #17
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesKorean(ImFontAtlas *self);
예제 #18
0
 public abstract void ImFontAtlas_ClearTexData(ImFontAtlas *self);
예제 #19
0
 public abstract void ImFontAtlas_GetTexDataAsRGBA32(ImFontAtlas *self, byte **out_pixels, int *out_width, int *out_height, int *out_bytes_per_pixel);
예제 #20
0
 public abstract void ImFontAtlas_Clear(ImFontAtlas *self);
예제 #21
0
 public abstract ImFont *ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(ImFontAtlas *self, byte *compressed_font_data_base85, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
예제 #22
0
 public static extern bool frBuildFontAtlas(ImFontAtlas *atlas, uint extra_flags);
예제 #23
0
 public abstract byte ImFontAtlas_Build(ImFontAtlas *self);
예제 #24
0
 public ImFontAtlasPtr(IntPtr nativePtr)
 {
     NativePtr = (ImFontAtlas *)nativePtr;
 }
예제 #25
0
 public abstract ImFont *ImFontAtlas_AddFontFromMemoryTTF(ImFontAtlas *self, void *font_data, int font_size, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
예제 #26
0
 public abstract int ImFontAtlas_AddCustomRectRegular(ImFontAtlas *self, uint id, int width, int height);
예제 #27
0
 public abstract ImFont *ImFontAtlas_AddFontFromFileTTF(ImFontAtlas *self, byte *filename, float size_pixels, ImFontConfig *font_cfg, ushort *glyph_ranges);
예제 #28
0
 public abstract ushort *ImFontAtlas_GetGlyphRangesJapanese(ImFontAtlas *self);
예제 #29
0
 public ImFontAtlasPtr(ImFontAtlas *nativePtr) => NativePtr = nativePtr;
예제 #30
0
 public abstract void ImFontAtlas_CalcCustomRectUV(ImFontAtlas *self, CustomRect *rect, Vector2 *out_uv_min, Vector2 *out_uv_max);