public static TrueTypeText CreateTrueTypeText(Renderer renderer, string fontPath, int fontSize, Color color, string text, int wrapLength)
 {
     Font font = new Font(fontPath, fontSize);
     Surface surface = new Surface(font, text, color, wrapLength);
     TrueTypeText trueTypeText = new TrueTypeText(renderer, surface, text, font, color, wrapLength);
     return trueTypeText;
 }
Esempio n. 2
0
        public TrueTypeText(Renderer renderer, Surface surface, string text, Font textFont, Color color, int wrapLength)
        {
            Assert.IsNotNull(renderer, Errors.E_RENDERER_NULL);
            Assert.IsNotNull(surface, Errors.E_SURFACE_NULL);
            Assert.IsNotNull(textFont, Errors.E_FONT_NULL);

            Text = text;
            Font = textFont;
            Color = color;
            WrapLength = wrapLength;
            if (wrapLength > 0)
                IsWrapped = true;
            else
                IsWrapped = false;
            Texture = new Texture(renderer, surface);
        }
Esempio n. 3
0
        public Surface(Font font, string text, Color color, int wrapLength)
        {
            if (wrapLength < 0)
                throw new ArgumentOutOfRangeException("wrapLength", "Wrap length must be greater than 0.");

            Type = SurfaceType.Text;
            SDL.SDL_Color rawColor = new SDL.SDL_Color() { r = color.R, g = color.G, b = color.B };

            if (wrapLength > 0)
                Handle = SDL_ttf.TTF_RenderText_Blended_Wrapped(font.Handle, text, rawColor, (uint)wrapLength);
            else
                Handle = SDL_ttf.TTF_RenderText_Blended(font.Handle, text, rawColor);

            if (Handle == IntPtr.Zero)
                throw new Exception(String.Format("Error while loading text surface: {0}", SDL.SDL_GetError()));

            GetSurfaceMetaData();
        }
Esempio n. 4
0
 public Surface(Font font, string text, Color color)
     : this(font, text, color, 0)
 {
 }