[DllImport("opengl32", EntryPoint = "wglUseFontOutlines", CallingConvention=CallingConvention.Winapi)]
public static extern bool wglUseFontOutlines(
IntPtr hDC,
[MarshalAs(UnmanagedType.U4)] UInt32 first,
[MarshalAs(UnmanagedType.U4)] UInt32 count,
[MarshalAs(UnmanagedType.U4)] UInt32 listBase,
[MarshalAs(UnmanagedType.R4)] Single deviation,
[MarshalAs(UnmanagedType.R4)] Single extrusion,
[MarshalAs(UnmanagedType.I4)] Int32 format,
[Out] Gdi.GLYPHMETRICSFLOAT[] lpgmf);
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct GLYPHMETRICSFLOAT
{
public Single gmfBlackBoxX;
public Single gmfBlackBoxY;
public POINTFLOAT gmfptGlyphOrigin;
public Single gmfCellIncX;
public Single gmfCellIncY;
}
public struct POINTFLOAT
{
public Single x;
public Single y;
}
Declare Function wglUseFontOutlines Lib "opengl32.dll" (TODO) As TODO
None.
None.
Seems to work for Win98, WinNT, WinXP, Win2K, and Win2003.
public void glPrint(String outputString,Int32 x1, Int32 y1, Int32 x2,
Int32 y2)
{
if(outputString == null)
return;
if(outputString.Length == 0)
return;
GL.glPushMatrix();
Single scale = 15.0f;
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glTranslatef(x1,y1,0);
GL.glScalef(scale, -scale, scale);
GL.glPushAttrib(GL.GL_LIST_BIT);
GL.glListBase(m_Parent.m_TagcWorkspaceControl.FontBase);
// Find width of string
Int32 i=0;
float width = 0;
for( ; i<outputString.Length; i++)
{
width +=
m_Parent.m_TagcWorkspaceControl.gmf[ outputString[i] ] .
gmfCellIncX * scale;
if((x1+width)>=x2)
break;
if((y1+
m_Parent.m_TagcWorkspaceControl.gmf[ outputString[i] ] .
gmfCellIncY * scale)>=y2)
break;
}
// Print the string if there is room
if(i>0)
GL.glCallLists(i, GL.GL_UNSIGNED_BYTE, outputString);
GL.glPopAttrib();
GL.glPopMatrix();
}
public Int32 getPrintWidth(String outputString)
{
if(outputString == null)
return 0;
if(outputString.Length == 0)
return 0;
Single scale = 15.0f;
// Find width of string
float width = 0;
for(Int32 i=0; i<outputString.Length; i++)
{
width +=
m_Parent.m_TagcWorkspaceControl.gmf[ outputString[i] ] .
gmfCellIncX * scale;
}
return (Int32)Math.Ceiling(width);
}
Do you know one? Please contribute it!