beutl icon indicating copy to clipboard operation
beutl copied to clipboard

Fontを読み込むときNullReferenceExceptionが発生する

Open yuto-trd opened this issue 3 years ago • 1 comments

概要

以下の部分でNullReferenceExceptionが発生することがある。

https://github.com/b-editor/BEditor/blob/main/src/libraries/BEditor.Drawing/Font.cs#L44-L44

yuto-trd avatar Nov 23 '21 16:11 yuto-trd

フォントの拡張子だけで判断して、フォントが実際に有効か確認してないゆえに、このバグが発生していると見受けられます。

かんたんなバグの再現方法

  1. とあるフォルダにテキストファイルを作成し、拡張子をttfに変える。
  2. BEditorを起動し、設定->フォントで、そのフォルダを追加する。
  3. BEditorを再起動する。
  4. バグが再現される。

かんたんなバグの解決方法

BEditor/src/libraries/BEditor.Drawing/Font.csのGetTypeface()での結果がnullか確認する。

nyanrus avatar Nov 25 '21 09:11 nyanrus