FontDueは、シンプルなno_std (標準ライブラリを移植性に使用しません)、Pure Rust、TrueType( .ttf/.ttc )&Opentype( .otf )フォントラスター化型およびレイアウトツールです。できるだけ速くフォントとの対話をするよう努めており、現在、フォントラスター化装置の最低端から端までのレイテンシを持っています。
fontdue 、 rusttype (link)、 ab_glyph (link)、 glyph_brush (link)、およびglyph_brush_layout (link)の代替品として設計されています。これは、シェーピングに取り組んでいないフォントライブラリのクラスです。
シェーピングライブラリと統合する時間がある可能性は低いでしょう。より完全なフォントエンジンが必要な場合は、非常に完全な純粋な錆テキストライブラリであるWonderful Cosmic Text Projectをチェックする必要があります。
このライブラリの非ゴールは、割り当てが無料であり、高速な「ゼロコスト」の初期負荷を持つことです。このライブラリは割り当てを行い、 alloc Crateに依存します。フォントは作成に完全に解析され、関連情報はアクセス形式により便利に保存されます。他のフォントライブラリとは異なり、フォント構造には独自のスペースを割り当てるため、寿命の依存関係はありません。
ライブデモ。このデモは、ブラウザキャンバスにラスター化するfontdueのWebアセンブリのビルドです。これは、同じパラメーターで提供されたfontdueのキャンバステキストAPIの間で、キャラクターがラスター化されている文字の並んでいます。
他のいくつかの例は、./dev/examplesの下にあります。
ラスター化APIは、近い将来に大きな変化を見ないはずです。
// Read the font data.
let font = include_bytes ! ( "../resources/Roboto-Regular.ttf" ) as & [ u8 ] ;
// Parse it into the font type.
let font = fontdue :: Font :: from_bytes ( font , fontdue :: FontSettings :: default ( ) ) . unwrap ( ) ;
// Rasterize and get the layout metrics for the letter 'g' at 17px.
let ( metrics , bitmap ) = font . rasterize ( 'g' , 17.0 ) ;レイアウトAPIは未熟で、壊れた変化が見られる場合があります。 fontdueが提供するレイアウトはナイーブであり、 glyph_brushのような既存のライブラリと同等になるように設計されています。
// Read the font data.
let font = include_bytes ! ( "../resources/fonts/Roboto-Regular.ttf" ) as & [ u8 ] ;
// Parse it into the font type.
let roboto_regular = Font :: from_bytes ( font , fontdue :: FontSettings :: default ( ) ) . unwrap ( ) ;
// The list of fonts that will be used during layout.
let fonts = & [ roboto_regular ] ;
// Create a layout context. Laying out text needs some heap allocations; reusing this context
// reduces the need to reallocate space. We inform layout of which way the Y axis points here.
let mut layout = Layout :: new ( CoordinateSystem :: PositiveYUp ) ;
// By default, layout is initialized with the default layout settings. This call is redundant, but
// demonstrates setting the value with your custom settings.
layout . reset ( & LayoutSettings {
.. LayoutSettings :: default ( )
} ) ;
// The text that will be laid out, its size, and the index of the font in the font list to use for
// that section of text.
layout . append ( fonts , & TextStyle :: new ( "Hello " , 35.0 , 0 ) ) ;
layout . append ( fonts , & TextStyle :: new ( "world!" , 40.0 , 0 ) ) ;
// Prints the layout for "Hello world!"
println ! ( "{:?}" , layout . glyphs ( ) ) ;
// If you wanted to attached metadata based on the TextStyle to the glyphs returned in the
// glyphs() function, you can use the TextStyle::with_metadata function. In this example, the
// Layout type is now parameterized with u8 (Layout<u8>). All styles need to share the same
// metadata type.
let mut layout = Layout :: new ( CoordinateSystem :: PositiveYUp ) ;
layout . append ( fonts , & TextStyle :: with_user_data ( "Hello " , 35.0 , 0 , 10u8 ) ) ;
layout . append ( fonts , & TextStyle :: with_user_data ( "world!" , 40.0 , 0 , 20u8 ) ) ;
println ! ( "{:?}" , layout . glyphs ( ) ) ; これらのベンチマークは、テキスト「Sphinx of Black Quartz、My Vowの判断」のGlyphメトリックとビットマップを生成するのにかかる時間を測定します。さまざまなサイズを超えて。グラフのラインが低いほど、より良いです。


このベンチマークは、サンプルテキストのラテン文字をレイアウトするのにかかる時間を測定し、単語の境界を包み込みます。

のいずれかでライセンスされています
あなたのオプションで。
明示的に特に述べていない限り、Apache-2.0ライセンスで定義されているように、お客様による作業に含めるために意図的に提出された貢献は、追加の条件なしで、上記のように多ライセンスを取得するものとします。
あなたが見つけた新しい機能や癖について私と一緒に我慢してください。バグは優先されますが、Fontdueで作業したいほど時間がないので、我慢してください。これはソロプロジェクトです。
fontdueは、幅広いTrueTypeおよびOpenType機能をサポートするフォントの解析のttf-parser (リンク)に依存します。
Fontdue 、ラスター化の速さとrusttype (link)CrateがFontの解析の見た目を作ったため、 font-rs (link)の漠然とより多くのプロダクションレディフォーク(リンク)としてスタートしました。それ以来、私は多くのフォント仕様とモダンなラスター化技術を読み、その過程でゼロから独自の獣にfontdueました。