Example #1
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName, int height,
                                                        float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            var hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_DONTCARE, 0, 0, 0, Win32.DEFAULT_CHARSET,
                                         Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.VARIABLE_PITCH, faceName);

            //  Select the font handle.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

            //  Create the list base.
            var listBase = gl.GenLists(1);

            //  Create space for the glyph metrics.
            var glyphMetrics = new GLYPHMETRICSFLOAT[255];

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase,
                                                   deviation, extrusion, (int)fontOutlineFormat, glyphMetrics);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            var foe = new FontOutlineEntry()
            {
                HDC               = gl.RenderContextProvider.DeviceContextHandle,
                HRC               = gl.RenderContextProvider.RenderContextHandle,
                FaceName          = faceName,
                Height            = height,
                ListBase          = listBase,
                ListCount         = 255,
                Deviation         = deviation,
                Extrusion         = extrusion,
                FontOutlineFormat = fontOutlineFormat,
                GlyphMetrics      = glyphMetrics
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);

            return(foe);
        }
Example #2
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName, int height,
            float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            IntPtr hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_DONTCARE, 0, 0, 0, Win32.DEFAULT_CHARSET, 
                Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.VARIABLE_PITCH, faceName);
            
            //  Select the font handle.
            IntPtr hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, nextListBase,
                deviation, extrusion, (int)fontOutlineFormat, IntPtr.Zero);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            FontOutlineEntry foe = new FontOutlineEntry()
            {
                HDC = gl.RenderContextProvider.DeviceContextHandle,
                HRC = gl.RenderContextProvider.RenderContextHandle,
                FaceName = faceName,
                Height = height,
                ListBase = nextListBase,
                ListCount = 255,
                Deviation = deviation,
                Extrusion = extrusion,
                FontOutlineFormat = fontOutlineFormat
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);
            
            //  Shift the list base.
            nextListBase += 1000;

            return foe;
        }
Example #3
0
        private FontOutlineEntry CreateFontOutlineEntry(OpenGL gl, string faceName, int height,
            float deviation, float extrusion, FontOutlineFormat fontOutlineFormat)
        {
            //  Make the OpenGL instance current.
            gl.MakeCurrent();

            //  Create the font based on the face name.
            var hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_DONTCARE, 0, 0, 0, Win32.DEFAULT_CHARSET, 
                Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.VARIABLE_PITCH, faceName);
            
            //  Select the font handle.
            var hOldObject = Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hFont);
            
            //  Create the list base.
            var listBase = gl.GenLists(1);

            //  Create space for the glyph metrics.
            var glyphMetrics = new GLYPHMETRICSFLOAT[255];

            //  Create the font bitmaps.
            bool result = Win32.wglUseFontOutlines(gl.RenderContextProvider.DeviceContextHandle, 0, 255, listBase,
                deviation, extrusion, (int)fontOutlineFormat, glyphMetrics);

            //  Reselect the old font.
            Win32.SelectObject(gl.RenderContextProvider.DeviceContextHandle, hOldObject);

            //  Free the font.
            Win32.DeleteObject(hFont);

            //  Create the font bitmap entry.
            var foe = new FontOutlineEntry()
            {
                HDC = gl.RenderContextProvider.DeviceContextHandle,
                HRC = gl.RenderContextProvider.RenderContextHandle,
                FaceName = faceName,
                Height = height,
                ListBase = listBase,
                ListCount = 255,
                Deviation = deviation,
                Extrusion = extrusion,
                FontOutlineFormat = fontOutlineFormat,
                GlyphMetrics = glyphMetrics
            };

            //  Add the font bitmap entry to the internal list.
            fontOutlineEntries.Add(foe);

            return foe;
        }