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