示例#1
0
        public Font(Resources charRess, string charsPath)
        {
            //file.font
            CharArray = new RenderChar[ushort.MaxValue];

            foreach (Texture paten in charRess.GetResources <Texture>(charsPath))
            {
                string fname = paten.Path;
                fname = fname.Remove(fname.LastIndexOf('.'), 4);
                fname = fname.Remove(0, fname.LastIndexOf('/') + 1);

                RenderChar nchr = new RenderChar(paten.TextureObject, ushort.Parse(fname), paten.Widith, paten.Height);
                CharArray[nchr.Code] = nchr;
            }
        }
示例#2
0
        public static int BaseTextRenderOffsetX(string text1, Font font)
        {
            int renderOffsetX = 0;
            int renderOffsetY = 0;

            for (int i = 0; i < text1.Length; i++)
            {
                if (text1[i] == '\n')
                {
                    renderOffsetX  = 0;
                    renderOffsetY += 75;
                    continue;
                }

                {
                    RenderChar rnd = font.CharArray[(ushort)text1[i]];
                    renderOffsetX += rnd.Widith + 5;
                }
            }
            return(renderOffsetX);
        }
示例#3
0
        public static void BaseTextRender(string text1, Font font, IGraphics gp)
        {
            if (string.IsNullOrEmpty(text1))
            {
                return;
            }


            int renderOffsetX = 0;
            int renderOffsetY = 0;

            for (int i = 0; i < text1.Length; i++)
            {
                if (text1[i] == '\n')
                {
                    renderOffsetX  = 0;
                    renderOffsetY += 75;
                    continue;
                }

                {
                    RenderChar rnd = font.CharArray[(ushort)text1[i]];
                    gp.DefuseMap(rnd.TextureObject);
                    gp.DrawTexturedRectangle(
                        new Vector3((float)(renderOffsetX + 0), (float)(renderOffsetY + 0), 0f),
                        new Vector2(-1.0f, 0.0f),
                        new Vector3((float)(renderOffsetX + 0), (float)(renderOffsetY + rnd.Height), 0f),
                        new Vector2(-1.0f, -1.0f),
                        new Vector3((float)(renderOffsetX + rnd.Widith), (float)(renderOffsetY + 0), 0f),
                        new Vector2(0.0f, 0.0f),
                        new Vector3((float)(renderOffsetX + rnd.Widith), (float)(renderOffsetY + rnd.Height), 0f),
                        new Vector2(0.0f, -1.0f)
                        );

                    renderOffsetX += rnd.Widith + 5;
                }
            }
        }