• R/O
  • SSH

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョンfb923892c39f0bb13f0192998fb8bbd9275497ca (tree)
日時2019-10-05 21:11:43
作者Martin Krošlák <kroslakma@gmai...>
コミッターMartin Krošlák

ログメッセージ

* enabled compilation of stbtt code path for fonts

変更サマリ

差分

diff -r a3fa2de2fc2a -r fb923892c39f mel-asset/src/font.rs
--- a/mel-asset/src/font.rs Thu Oct 03 22:06:58 2019 +0200
+++ b/mel-asset/src/font.rs Sat Oct 05 14:11:43 2019 +0200
@@ -291,31 +291,33 @@
291291 // stb_truetype version
292292 // -----------------------------------------------------------------------------------------
293293 {
294- let _offset = stbtt::get_font_offset_for_index(&bytes, 0).unwrap();
295- // let font_stb = stbtt::FontInfo::new(bytes, offset as usize).unwrap();
296- // let v_metrics = font_stb.get_v_metrics();
297- // let font_scale_px = font_stb.scale_for_pixel_height(glyph_height_px);
298- // let _font_scale_inv_px = 1.0 / font_scale_px;
299- // let _font_scale_norm = font_stb.scale_for_pixel_height(1.0);
300- // new_font.ascent_tt = v_metrics.ascent;
301- // new_font.descent_tt = v_metrics.descent;
302- // new_font.line_gap_tt = v_metrics.line_gap;
303- // for &c in charset.iter() {
304- // let glyph_idx = font_stb.find_glyph_index(c.into());
305- // let h_metrics = font_stb.get_glyph_h_metrics(glyph_idx);
306- // let is_empty = font_stb.is_glyph_empty(glyph_idx);
307- // if is_empty && h_metrics.advance_width == 0 {
308- // new_font.code_points.push(CodePoint {
309- // value: c,
310- // glyph_idx: 0,
311- // });
312- // continue;
313- // }
314- // new_font.code_points.push(CodePoint {
315- // value: c,
316- // glyph_idx: new_font.glyphs.len() as u32,
317- // });
318- // }
294+ let offset = stbtt::get_font_offset_for_index(&bytes, 0).unwrap();
295+ if false {
296+ let font_stb = stbtt::FontInfo::new(bytes, offset as usize).unwrap();
297+ let v_metrics = font_stb.get_v_metrics();
298+ let font_scale_px = font_stb.scale_for_pixel_height(glyph_height_px);
299+ let _font_scale_inv_px = 1.0 / font_scale_px;
300+ let _font_scale_norm = font_stb.scale_for_pixel_height(1.0);
301+ new_font.ascent_tt = v_metrics.ascent as f32;
302+ new_font.descent_tt = v_metrics.descent as f32;
303+ new_font.line_gap_tt = v_metrics.line_gap as f32;
304+ for &c in charset.iter() {
305+ let glyph_idx = font_stb.find_glyph_index(c.into());
306+ let h_metrics = font_stb.get_glyph_h_metrics(glyph_idx);
307+ let is_empty = font_stb.is_glyph_empty(glyph_idx);
308+ if is_empty && h_metrics.advance_width == 0 {
309+ new_font.code_points.push(CodePoint {
310+ value: c,
311+ glyph_idx: 0,
312+ });
313+ continue;
314+ }
315+ new_font.code_points.push(CodePoint {
316+ value: c,
317+ glyph_idx: new_font.glyphs.len() as u32,
318+ });
319+ }
320+ }
319321 }
320322
321323 Ok((