Exemplo n.º 1
0
        public override void Dispose()
        {
            Font.Dispose();
            Font = null;

            FontData.Dispose();
            FontData = null;
        }
Exemplo n.º 2
0
    public Main()
    {
        this.random = new Random();

        this.font = new DynamicFont();
        this.font.SetSize(15);
        DynamicFontData font_data = new DynamicFontData();

        font_data.SetFontPath("res://opens.ttf");
        this.font.SetFontData(font_data);

        this.fires = this.InitFires();
    }
Exemplo n.º 3
0
            public Country()
            {
                DynamicFont     font = new DynamicFont();
                DynamicFontData data = new DynamicFontData();

                data.SetFontPath("res://Fonts/good times rg.ttf");
                font.SetFontData(data);
                font.Size      = 20;
                font.UseFilter = true;

                numberOfTroopsTxt.RectSize = new Vector2(30, 30);
                numberOfTroopsTxt.AddFontOverride("normal_font", font);
                numberOfTroopsTxt.PushAlign(RichTextLabel.Align.Center);

                numberOfTroops.Texture = texture;
                owner  = null;
                troops = 0;
            }
Exemplo n.º 4
0
        public override void Load(IResourceCache cache, string path)
        {
            if (!System.IO.File.Exists(path))
            {
                throw new FileNotFoundException(path);
            }

            var res = ResourceLoader.Load(path);

            if (!(res is DynamicFontData fontData))
            {
                throw new InvalidDataException("Path does not point to a font.");
            }

            FontData = fontData;
            Font     = new DynamicFont();
            Font.AddFallback(FontData);
        }
Exemplo n.º 5
0
    public static unsafe ImFontPtr AddFont(DynamicFontData fontData, int fontSize)
    {
        ImFontPtr rv = null;

        Godot.File fi  = new File();
        var        err = fi.Open(fontData.FontPath, File.ModeFlags.Read);

        byte[] buf = fi.GetBuffer((int)fi.GetLen());
        fi.Close();

        // can't add a name, ImFontConfig seems unusable

        // let ImGui manage this memory
        IntPtr p = Marshal.AllocHGlobal(buf.Length);

        Marshal.Copy(buf, 0, p, buf.Length);
        rv = ImGui.GetIO().Fonts.AddFontFromMemoryTTF(p, buf.Length, (float)fontSize);

        return(rv);
    }
Exemplo n.º 6
0
        public override void Load(IResourceCache cache, ResourcePath path)
        {
            if (!cache.ContentFileExists(path))
            {
                throw new FileNotFoundException("Content file does not exist for texture");
            }
            if (!cache.TryGetDiskFilePath(path, out string diskPath))
            {
                throw new InvalidOperationException("Textures can only be loaded from disk.");
            }

            var res = ResourceLoader.Load(diskPath);

            if (!(res is DynamicFontData fontData))
            {
                throw new InvalidDataException("Path does not point to a font.");
            }

            FontData = fontData;
            Font     = new DynamicFont();
            Font.AddFallback(FontData);
        }