Esempio n. 1
0
        public void LoadGlyphRange(int UnicodeMin, int UnicodeMax, Func <int, bool> IsValid)
        {
            lock (FontLock) {
                Msdfgen.GlyphLoadedCallback(OnGlyph);

                for (int i = UnicodeMin; i < UnicodeMax + 1; i++)
                {
                    if (IsValid(i))
                    {
                        Msdfgen.LoadGlyph(Fnt, i, CharWidth, CharHeight, AngleThreshold, Range, Scale, OffsetX, OffsetY);
                    }
                }
            }
        }
Esempio n. 2
0
        public MSDFFont(string Pth)
        {
            GlyphTexture = new Dictionary <char, Texture>();

            CharWidth  = 32;
            CharHeight = 36;

            AngleThreshold = 3;
            Range          = 4;
            Scale          = 1;
            OffsetX        = 6;
            OffsetY        = 10;

            Pth = Path.GetFullPath(Pth).NormalizeFilePath();
            if (!File.Exists(Pth))
            {
                throw new Exception("File does not exist " + Pth);
            }

            string Ext = Path.GetExtension(Pth).ToLower();

            switch (Ext)
            {
            case ".ttf":
                lock (FontLock) {
                    Fnt = Msdfgen.LoadFont(Pth);
                }
                break;

            default:
                throw new Exception("Unnown font file format " + Ext);
            }

            LoadGlyphRange('A', 'Z');
            LoadGlyphRange('a', 'z');
            LoadGlyphRange('0', '9');
        }