Exemplo n.º 1
0
        private void init()
        {
            // Allocate some memory to store the texture ids, initialize the arrays to hold the character widths
            textures   = new uint[128];
            charWidths = new int[128];

            //Create and initilize a freetype font library
            Library library = new Library();

            //The object in which Freetype holds information on a given
            //font is called a "face".
            Face face;

            //This is where we load in the font information from the file.
            //Of all the places where the code might die, this is the most likely,
            //as FT_New_Face will die if the font file does not exist or is somehow broken.
            face = new Face(library, font);

            // set the character size
            face.SetCharSize((int)height, (int)height, 96, 96);

            //Here we ask opengl to allocate resources for
            //all the textures and displays lists which we
            //are about to create.
            list_base = glView.glGenLists(128);
            glView.glGenTextures(128, textures);

            //This is where we actually create each of the fonts display lists.
            // loop for every character (we want to use) in the font
            for (uint i = 0; i < 128; i++)
            {
                if (charEnabled[i])
                {
                    charWidths[i] = make_dlist(face, i, list_base, textures);
                }
            }
            //We don't need the face information now that the display
            //lists have been created, so we free the assosiated resources.
            face.Dispose();

            //Ditto for the library.
            library.Dispose();

            // set font as initialized
            initialized = true;
        }