예제 #1
0
        private void LoadFontPart(SpriteReference sprite, int index)
        {
            Texture2D tex = sprite.Texture;

            Color[] blah = new Color[tex.Width * tex.Height];
            tex.GetData <Color>(0, new Rectangle(0, 0, tex.Width, tex.Height), blah, 0, blah.Length);

            for (int i = 0; i < FontUtil.CharsPerPage; i++)
            {
                FontUtil.RegisterChar(blah, tex.Width, tex.Height, (char)(index * FontUtil.CharsPerPage + i), i);
            }
        }
예제 #2
0
        public void DrawChar(char chr, Vector2 drawpos, TextFormatting format, DialogParams param)
        {
            Texture2D tex = Game.FontSprites[chr / FontUtil.CharsPerPage].Texture;

            int index  = chr % FontUtil.CharsPerPage;
            int offset = FontUtil.GetCharOffset(chr);
            int width  = FontUtil.GetCharWidth(chr);

            var color        = param.Color;
            var border       = param.Border;
            var charOffset   = param.Offset;
            var charScale    = param.Scale;
            var charAngle    = param.Angle;
            var bold         = format.Bold;
            var scriptOffset = 0;

            //DrawCharLine(drawpos + charOffset + new Vector2(0, 15), width + 1 + (bold ? 1 : 0), color, border);
            //DrawCharLine(drawpos + charOffset + new Vector2(0, 2), width + 1 + (bold ? 1 : 0), color, border);

            var rect   = FontUtil.GetCharRect(index);
            var middle = FontUtil.GetCharMiddle(index);

            if (border.A > 0)
            { //Only draw outline if it's actually non-transparent
                Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset - 1, scriptOffset + 0) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset, scriptOffset + 1) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset, scriptOffset - 1) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                if (bold)
                {
                    Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset + 2, scriptOffset + 0) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                    Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset + 1, scriptOffset + 1) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                    Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset + 1, scriptOffset - 1) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                }
                else
                {
                    Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset + 1, scriptOffset) + middle, rect, border, charAngle, middle, charScale, SpriteEffects.None, 0);
                }
            }

            Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset, scriptOffset) + middle, rect, color, charAngle, middle, charScale, SpriteEffects.None, 0);
            if (bold)
            {
                Scene.SpriteBatch.Draw(tex, drawpos + charOffset + new Vector2(-offset + 1, scriptOffset) + middle, rect, color, charAngle, middle, charScale, SpriteEffects.None, 0);
            }

            //if(charOffset == Vector2.Zero)
            //    DrawCharLine(drawpos + charOffset + new Vector2(-1, 8), width + 2 + (bold ? 1 : 0), color, border);
        }
예제 #3
0
 public int GetCharWidth(char chr)
 {
     return(FontUtil.GetCharWidth(chr) + (Bold ? 1 : 0));
 }