QuickFont
Quick
Opentk的现代OpenGL文本渲染库。
从Swax/Quickfont库分叉。原始库Qfont
您可以通过Nuget安装此库。
QuickFont已经过测试并在Windows,Linux和OSX上运行。
最低支持的OpenGL版本为3.0
注意将需要更改示例项目以在OSX上正确构建,因为默认情况下,如果未指定特定版本,则Apple返回OpenGL 2.1上下文。
只需用以下方式替换game.cs构造函数
public Game ( )
: base ( 800 , 600 , GraphicsMode . Default , "QuickFont Example" , GameWindowFlags . Default , DisplayDevice . Default , 3 , 2 , GraphicsContextFlags . Default )这将选择一个OpenGL版本> = 3.2(通常为4.1)。
FreeTypeFont ,则现在从freetype加载kerning信息QFontDrawing无法实现IDisposableQVertexArrayObject 在某些Onload()方法中创建您的Qfont和QfontDrawing
_myFont = new QFont ( "Fonts/HappySans.ttf" , 72 , new QFontBuilderConfiguration ( true ) ) ;
_myFont2 = new QFont ( "basics.qfont" , new QFontBuilderConfiguration ( true ) ) ;
_drawing = new QFontDrawing ( ) ;调用一些打印方法或自己创建绘图原始方法。将它们添加到图纸中。
_drawing . DrawingPrimitives . Clear ( ) ;
_drawing . Print ( _myFont , "text1" , pos , FontAlignment . Left ) ;
// draw with options
var textOpts = new QFontRenderOptions ( )
{
Colour = Color . FromArgb ( new Color4 ( 0.8f , 0.1f , 0.1f , 1.0f ) . ToArgb ( ) ) ,
DropShadowActive = true
} ;
SizeF size = _drawing . Print ( _myFont , "text2" , pos2 , FontAlignment . Left , textOpts ) ;
var dp = new QFontDrawingPrimitive ( _myFont2 ) ;
size = dp . Print ( text , new Vector3 ( bounds . X , Height - yOffset , 0 ) , new SizeF ( maxWidth , float . MaxValue ) , alignment ) ;
drawing . DrawingPrimitives . Add ( dp ) ;
// after all changes do update buffer data and extend it's size if needed.
_drawing . RefreshBuffers ( ) ;然后在您的抽奖循环中做:
_drawing . ProjectionMatrix = proj ;
_drawing . Draw ( ) ;
SwapBuffers ( ) ;在程序结束时,请处理QuickFont资源:
protected virtual void Dispose ( bool disposing )
{
_drawing . Dispose ( ) ;
_myFont . Dispose ( ) ;
_myFont2 . Dispose ( ) ;
}请参阅随附的示例项目以获取更多信息!
以下是为QuickFont做出贡献的人的无尽清单:
詹姆斯·洛尔(James Lohr) - 原始图书馆的创建者(http://www.opentk.com/project/quickfont)
John(Swax)Marshall-添加了顶点缓冲区支持
帕特里克(OPCON)YATES-当前维护者
Robertofon-重构整体Qfont类
马丁纳 - OpenGL ES 2.0支持
扬·波拉克(Jan Polak)
乔纳森
根据MIT许可,请参阅项目root目录中的文件License.txt