Ejemplo n.º 1
0
        public IFont CreateFont(string fontPath)
        {
            var         fileName = "assets/" + fontPath + ".xml";
            fontMetrics j        = client.ClientSettings.LoadXmlFile <fontMetrics>(fileName);

            var assetName = fontPath;
            var font      = CreateImage("../" + assetName, new PointF(0, 0), () => { });

            return(new WebSpriteFont(font, j));
        }
Ejemplo n.º 2
0
        public void CreateFont(string fontName, int fontSize, string fontPath)
        {
            var         fileName = fontPath + ".xml";
            fontMetrics j        = client.ClientSettings.LoadXmlFile <fontMetrics>(fileName);

            var assetName = fontPath + ".png";
            var font      = CreateImage(fontName + fontSize, assetName, new PointF(0, 0), () => { });

            fonts[fontName + fontSize] = new WebSpriteFont(font, j);
        }
        public WebSpriteFont(IImage font, fontMetrics fontMetrics)
        {
            Font        = font;
            FontMetrics = fontMetrics;

            FontDict = new Dictionary <string, Rectangle>();
            foreach (var characters in fontMetrics.character)
            {
                FontDict.Add(((char)int.Parse(characters.character)).ToString(), new Rectangle()
                {
                    X      = int.Parse(characters.x),
                    Y      = int.Parse(characters.y),
                    Width  = int.Parse(characters.width),
                    Height = int.Parse(characters.height),
                });
            }
        }