예제 #1
0
        public void GlyphMetrics()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 12);
            int    minx;
            int    miny;
            int    maxx;
            int    maxy;
            int    advance;


            SdlTtf.TTF_GlyphMetrics(fontPtr, 1, out minx, out maxx, out miny, out maxy, out advance);
            Assert.AreEqual(-1, minx);
            Assert.AreEqual(4, maxx);
            Assert.AreEqual(0, miny);
            Assert.AreEqual(8, maxy);
            Assert.AreEqual(5, advance);
//			Console.WriteLine("minx: " + minx.ToString());
//			Console.WriteLine("maxx: " + maxx.ToString());
//			Console.WriteLine("miny: " + miny.ToString());
//			Console.WriteLine("maxy: " + maxy.ToString());
//			Console.WriteLine("advance: " + advance.ToString());
            this.Quit();
        }
예제 #2
0
파일: Font.cs 프로젝트: AlmuChan/Monopoly
 public Font(string fileName, int fontSize)
 {
     fontType = SdlTtf.TTF_OpenFont(fileName, fontSize);
     if (fontType == IntPtr.Zero)
     {
         Console.WriteLine("Font type not found");
     }
 }
예제 #3
0
 public void Load(string fileName, short sizePoints)
 {
     internalPointer = SdlTtf.TTF_OpenFont(fileName, sizePoints);
     if (internalPointer == IntPtr.Zero)
     {
         SdlHardware.FatalError("Font not found: " + fileName);
     }
 }
예제 #4
0
        public void FontHeight()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 9);

            Assert.AreEqual(SdlTtf.TTF_FontHeight(fontPtr), 12);
            this.Quit();
        }
예제 #5
0
        public void OpenFont()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            Assert.IsFalse(fontPtr == IntPtr.Zero);
            this.Quit();
        }
예제 #6
0
 public Font(string fileName, int fontSize)
 {
     fontType = SdlTtf.TTF_OpenFont(fileName, fontSize);
     if (fontType == IntPtr.Zero)
     {
         Console.WriteLine("Font type not found: " + fileName + " " + fontSize);
         Environment.Exit(2);
     }
 }
예제 #7
0
        public void FontFaces()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            Assert.AreEqual(SdlTtf.TTF_FontFaces(fontPtr), 4294967297);
            //Console.WriteLine("FontFaces:" + SdlTtf.TTF_FontFaces(fontPtr).ToString());
            this.Quit();
        }
예제 #8
0
        public void FontLineSkip()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            Assert.AreEqual(17, SdlTtf.TTF_FontLineSkip(fontPtr));
            //Console.WriteLine("FontLineSkip:" + SdlTtf.TTF_FontLineSkip(fontPtr).ToString());
            this.Quit();
        }
예제 #9
0
        public void FontAscent()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            Assert.AreEqual(12, SdlTtf.TTF_FontAscent(fontPtr));
            //Console.WriteLine("FontAscent:" + result.ToString());
            this.Quit();
        }
예제 #10
0
        public void SetGetFontStyle()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            SdlTtf.TTF_SetFontStyle(fontPtr, SdlTtf.TTF_STYLE_BOLD | SdlTtf.TTF_STYLE_ITALIC);
            Assert.AreEqual(SdlTtf.TTF_STYLE_BOLD | SdlTtf.TTF_STYLE_ITALIC, SdlTtf.TTF_GetFontStyle(fontPtr));
            this.Quit();
        }
예제 #11
0
        public void FontFaceStyleName()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);

            //Console.WriteLine("FontFaceStyleName:" + SdlTtf.TTF_FontFaceStyleName(fontPtr).ToString());
            Assert.AreEqual(SdlTtf.TTF_FontFaceStyleName(fontPtr).ToString(), "Roman");
            this.Quit();
        }
예제 #12
0
    public static IntPtr CargarFuente(string fichero, short tamanyo)
    {
        IntPtr fuente = SdlTtf.TTF_OpenFont(fichero, tamanyo);

        if (fuente == IntPtr.Zero)
        {
            System.Console.WriteLine("Fuente inexistente: {0}", fichero);
            Environment.Exit(6);
        }
        return(fuente);
    }
예제 #13
0
파일: Font.cs 프로젝트: spech66/LightFireCS
        public int LoadFont(string ttfFile, int size)
        {
            font = SdlTtf.TTF_OpenFont(ttfFile, size);

            if (IntPtr.Zero == font)
            {
                EngineLog.Get().Error("Error loading " + ttfFile + ": " + SdlTtf.TTF_GetError(), "Font");
                return(1);
            }

            EngineLog.Get().Info(ttfFile + " loaded", "Font");
            return(0);
        }
예제 #14
0
        /// <summary>
        /// Font Constructor
        /// </summary>
        /// <param name="fileName">Font filename</param>
        /// <param name="pointSize">Size of font</param>
        public Font(string fileName, int pointSize)
        {
            if (!Font.IsFontSystemInitialized)
            {
                Font.InitializeFontSystem();
            }

            this.Handle = SdlTtf.TTF_OpenFont(fileName, pointSize);
            if (this.Handle == IntPtr.Zero)
            {
                throw FontException.Generate();
            }
        }
예제 #15
0
        public void FontFaceIsFixedWidth()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 12);

            Assert.AreEqual(SdlTtf.TTF_FontFaceIsFixedWidth(fontPtr), 0);
            IntPtr fontPtrMono = SdlTtf.TTF_OpenFont("../../FreeMono.ttf", 12);

            Assert.IsTrue(SdlTtf.TTF_FontFaceIsFixedWidth(fontPtrMono) != 0);
            //Console.WriteLine("FontFaceIsFixedWidth:" +
            //	SdlTtf.TTF_FontFaceIsFixedWidth(fontPtrMono).ToString());
            this.Quit();
        }
예제 #16
0
        public void EscribirTexto(string texto, short x, short y, short size, byte r, byte g, byte b)
        {
            IntPtr tipoLetra = SdlTtf.TTF_OpenFont("SEGOEPRB.TTF", size);

            Sdl.SDL_Color color           = new Sdl.SDL_Color(r, g, b);
            IntPtr        textoComoImagen = SdlTtf.TTF_RenderText_Solid(tipoLetra, texto, color);

            if (textoComoImagen == IntPtr.Zero)
            {
                Environment.Exit(5);
            }
            Sdl.SDL_Rect origen = new Sdl.SDL_Rect(0, 0, ancho, alto);
            Sdl.SDL_Rect dest   = new Sdl.SDL_Rect(x, y, ancho, alto);
            Sdl.SDL_BlitSurface(textoComoImagen, ref origen, pantalla, ref dest);
        }
예제 #17
0
        public void SizeUNICODE()
        {
            this.Quit();
            this.Init();
            IntPtr fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 10);
            int    w;
            int    h;

            SdlTtf.TTF_SizeUNICODE(fontPtr, "hello", out w, out h);
            Console.WriteLine("w: " + w.ToString());
            Console.WriteLine("h: " + h.ToString());
            Assert.AreEqual(w, 22);
            Assert.AreEqual(17, h);
            this.Quit();
        }
예제 #18
0
        /**
         * Obtain a pointer to the SDL_TTF font handle for a particular point size. Caching occurs here.
         *
         * @param size The point size to retrieve
         * @return A pointer to the font's handle
         */
        public IntPtr getFontHandle(int size)
        {
            // Load the font if it is not already present
            if (!handles.ContainsKey(size))
            {
                IntPtr handle = SdlTtf.TTF_OpenFont(path, size);
                if (handle == IntPtr.Zero)
                {
                    throw new Exception("Could not open font " + path + " at point size " + size);
                }
                handles[size] = handle;
            }

            // Return the font handle
            return(handles[size]);
        }
예제 #19
0
        } //Stuff that goes before load content

        static void Init_LoadContent()
        {
            vera     = SdlTtf.TTF_OpenFont("Content/Fonts/Vera.ttf", 24);                           //Load in 12-point Vera font.
            veraData = (SdlTtf.TTF_Font)Marshal.PtrToStructure(vera, typeof(SdlTtf.TTF_Font));      //Put the font data in its place

            veraSmall     = SdlTtf.TTF_OpenFont("Content/Fonts/Vera.ttf", 10);                      //Load in 12-point Vera font.
            veraSmallData = (SdlTtf.TTF_Font)Marshal.PtrToStructure(vera, typeof(SdlTtf.TTF_Font)); //Put the font data in its place

            DrawText(veraSmall, "Pre-initialization complete", new Point2D(15, 15));
            DrawText(veraSmall, "Fonts loaded; loading images...", new Point2D(15, 30));
            Sdl.SDL_Flip(screen); //Update screen

            IntPtr rwop    = Sdl.SDL_RWFromFile("Content/Tiles/ASCII_Tileset.PNG", "rb");
            IntPtr tileSet = SdlImage.IMG_LoadPNG_RW(rwop);

            short n = 0;

            target.w = source.w = TILEWIDTH;  //I love this combination thing
            target.h = source.h = TILEHEIGHT; //It's so elegant

            for (byte y = 0; y < 16; y++)
            {
                for (byte x = 0; x < 16; x++)                                                                      //16x16 tiles
                {
                    source.x = (short)(x * 17);                                                                    //X to grab from
                    source.y = (short)(y * 17);                                                                    //Y to grab from

                    image[n] = Sdl.SDL_CreateRGBSurface(Sdl.SDL_SWSURFACE, TILEWIDTH, TILEHEIGHT, 32, 0, 0, 0, 0); //Allocate image area
                    Sdl.SDL_BlitSurface(tileSet, ref source, image[n], ref target);
                    image[n]     = Sdl.SDL_DisplayFormatAlpha(image[n]);
                    imageData[n] = (Sdl.SDL_Surface)Marshal.PtrToStructure(image[n], typeof(Sdl.SDL_Surface)); //Put the image data in its place
                    Transparencify(n, Color.Magenta);                                                          //Magenta is the transparent color
                    image[n]     = Sdl.SDL_DisplayFormatAlpha(image[n]);
                    imageData[n] = (Sdl.SDL_Surface)Marshal.PtrToStructure(image[n], typeof(Sdl.SDL_Surface)); //Put the image data in its place
                    n++;
                }
            }

            DrawText(veraSmall, "Creatures loaded. External content loading complete.", new Point2D(15, 120));
            DrawText(veraSmall, "Post-initializing...", new Point2D(15, 135));
            Sdl.SDL_Flip(screen); //Update screen
        } //Loads in the external content
예제 #20
0
        public void RenderGlyph_Blended()
        {
            this.Quit();
            this.Init();
            IntPtr surfacePtr = VideoSetup();

            Sdl.SDL_Rect rect1   = new Sdl.SDL_Rect(0, 0, 400, 400);
            Sdl.SDL_Rect rect2   = new Sdl.SDL_Rect(0, 0, 400, 400);
            IntPtr       fontPtr = SdlTtf.TTF_OpenFont("../../FreeSans.ttf", 12);

            Sdl.SDL_Color colorfg        = new Sdl.SDL_Color(254, 0, 0);
            IntPtr        fontSurfacePtr = SdlTtf.TTF_RenderGlyph_Blended(fontPtr, 1000, colorfg);

            Assert.IsFalse(fontSurfacePtr == IntPtr.Zero);
            int result = Sdl.SDL_BlitSurface(fontSurfacePtr, ref rect1, surfacePtr, ref rect2);

            Assert.AreEqual(result, 0);
            Sdl.SDL_UpdateRect(surfacePtr, 0, 0, 400, 400);
            Thread.Sleep(sleepTime);
            this.Quit();
        }
예제 #21
0
        private SDLFontv2(string FontPath, int Size, FontStyle Style)
        {
            if (!File.Exists(FontPath))
            {
                throw new FileNotFoundException("Could not find font " + FontPath);
            }

            this.FontPath = FontPath;

            if (SdlTtf.TTF_WasInit() != 1)
            {
                SdlTtf.TTF_Init();
            }

            this.m_Font   = SdlTtf.TTF_OpenFont(this.FontPath, Size);
            this.FontSize = Size;
            this.Style    = Style;
            switch (Style)
            {
            case FontStyle.Bold:
                SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_BOLD);
                break;

            case FontStyle.Italic:
                SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_ITALIC);
                break;

            case FontStyle.Regular:
                SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_NORMAL);
                break;

            case FontStyle.Underline:
                SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_UNDERLINE);
                break;
            }
        }