wgpu text
v0.8.5
wgpu-text wgpuによる高速で簡単なテキストレンダリングのためにglyph-brushのラッパーです。 .otfおよび.ttfフォントをサポートします。

このプロジェクトは、 wgpu_glyphに触発され、類似していますが、追加機能があり、より簡単です。また、プロジェクトにGlyph-Brushを含める必要はありません。
Glyph-Brush Crateは再輸出されており、非常に依存しているため、テキストの管理と追加をよりよく理解するために、セクションドキュメントとセクションの例を使用することをお勧めします。
以下を貨物に追加しますCargo.tomlファイル:
[ dependencies ]
wgpu_text = " 0.9.1 " use wgpu_text :: { glyph_brush :: { Section as TextSection , Text } , BrushBuilder , TextBrush } ;
let brush = BrushBuilder :: using_font_bytes ( font ) . unwrap ( )
/* .initial_cache_size((16_384, 16_384))) */ // use this to avoid resizing cache texture
. build ( & device , config . width , config . height , config . format ) ;
// Directly implemented from glyph_brush.
let section = TextSection :: default ( ) . add_text ( Text :: new ( "Hello World" ) ) ;
// on window resize:
brush . resize_view ( config . width as f32 , config . height as f32 , & queue ) ;
// window event loop:
winit :: event :: Event :: RedrawRequested ( _ ) => {
// Before are created Encoder and frame TextureView.
// Crashes if inner cache exceeds limits.
brush . queue ( & device , & queue , [ & section , .. . ] ) . unwrap ( ) ;
{
let mut rpass = encoder . begin_render_pass ( .. . ) ;
brush . draw ( & mut rpass ) ;
}
queue . submit ( [ encoder . finish ( ) ] ) ;
frame . present ( ) ;
} より詳細な例については、例をご覧ください。
cargo run --example <example-name>正確なパフォーマンスのために--releaseで例を実行します。
基本的なテキストのレンダリングとグリフブラシの機能に加えて、いくつかの機能がカスタマイズを追加します。
あらゆる種類の貢献を歓迎します。