LoginSignup
1
0

More than 1 year has passed since last update.

LovyanGFXで画面描画(8):内蔵CKTフォント

Posted at

LovyanGFX Advent Calendar 2022 17日目 の記事
「LovyanGFXで画面描画(7):内蔵日本語フォント」
https://qiita.com/nanbuwks/items/04ea0538c52b620de656

では、内蔵の lgfxJapanMincho/lgfxJapanGothic および efontJA を紹介しました。このうち efontJA は http://openlab.ring.gr.jp/efont/ の efont を元にしているらしいです。efont は Unicode 対応で2万文字強対応のワールドワイドになっていて、そのうちの日本語部分が内蔵されていました。

他にも中国語簡体字、中国語繁体字、韓国語フォントが efont から抽出して内蔵されています。

LovyanGFX の src/lgfx/v1/lgfx_fonts.hpp 中に定義されているうちの、以下の分のフォントシェイプを表示しました。
(2022/12/12 の develop branch 18a5440 での記述です)

    extern const lgfx::U8g2font efontCN_10   ;
    extern const lgfx::U8g2font efontCN_10_b ;
    extern const lgfx::U8g2font efontCN_10_bi;
    extern const lgfx::U8g2font efontCN_10_i ;
    extern const lgfx::U8g2font efontCN_12   ;
    extern const lgfx::U8g2font efontCN_12_b ;
    extern const lgfx::U8g2font efontCN_12_bi;
    extern const lgfx::U8g2font efontCN_12_i ;
    extern const lgfx::U8g2font efontCN_14   ;
    extern const lgfx::U8g2font efontCN_14_b ;
    extern const lgfx::U8g2font efontCN_14_bi;
    extern const lgfx::U8g2font efontCN_14_i ;
    extern const lgfx::U8g2font efontCN_16   ;
    extern const lgfx::U8g2font efontCN_16_b ;
    extern const lgfx::U8g2font efontCN_16_bi;
    extern const lgfx::U8g2font efontCN_16_i ;
    extern const lgfx::U8g2font efontCN_24   ;
    extern const lgfx::U8g2font efontCN_24_b ;
    extern const lgfx::U8g2font efontCN_24_bi;
    extern const lgfx::U8g2font efontCN_24_i ;

    extern const lgfx::U8g2font efontKR_10   ;
    extern const lgfx::U8g2font efontKR_10_b ;
    extern const lgfx::U8g2font efontKR_10_bi;
    extern const lgfx::U8g2font efontKR_10_i ;
    extern const lgfx::U8g2font efontKR_12   ;
    extern const lgfx::U8g2font efontKR_12_b ;
    extern const lgfx::U8g2font efontKR_12_bi;
    extern const lgfx::U8g2font efontKR_12_i ;
    extern const lgfx::U8g2font efontKR_14   ;
    extern const lgfx::U8g2font efontKR_14_b ;
    extern const lgfx::U8g2font efontKR_14_bi;
    extern const lgfx::U8g2font efontKR_14_i ;
    extern const lgfx::U8g2font efontKR_16   ;
    extern const lgfx::U8g2font efontKR_16_b ;
    extern const lgfx::U8g2font efontKR_16_bi;
    extern const lgfx::U8g2font efontKR_16_i ;
    extern const lgfx::U8g2font efontKR_24   ;
    extern const lgfx::U8g2font efontKR_24_b ;
    extern const lgfx::U8g2font efontKR_24_bi;
    extern const lgfx::U8g2font efontKR_24_i ;

    extern const lgfx::U8g2font efontTW_10   ;
    extern const lgfx::U8g2font efontTW_10_b ;
    extern const lgfx::U8g2font efontTW_10_bi;
    extern const lgfx::U8g2font efontTW_10_i ;
    extern const lgfx::U8g2font efontTW_12   ;
    extern const lgfx::U8g2font efontTW_12_b ;
    extern const lgfx::U8g2font efontTW_12_bi;
    extern const lgfx::U8g2font efontTW_12_i ;
    extern const lgfx::U8g2font efontTW_14   ;
    extern const lgfx::U8g2font efontTW_14_b ;
    extern const lgfx::U8g2font efontTW_14_bi;
    extern const lgfx::U8g2font efontTW_14_i ;
    extern const lgfx::U8g2font efontTW_16   ;
    extern const lgfx::U8g2font efontTW_16_b ;
    extern const lgfx::U8g2font efontTW_16_bi;
    extern const lgfx::U8g2font efontTW_16_i ;
    extern const lgfx::U8g2font efontTW_24   ;
    extern const lgfx::U8g2font efontTW_24_b ;
    extern const lgfx::U8g2font efontTW_24_bi;
    extern const lgfx::U8g2font efontTW_24_i ;

すべて 24dot を表示しています。
比較のために、最初に日本語フォントを表示、続いて簡体字、繁体字、韓国語の順序に表示しています。
表示する文字種は以下の通りです。

 display.println(" !\"#$%&'()*+,./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
  display.println("Hello こんにちは 你好 안녕하세요 Καλή μέρα Здравствуйте يوم جيد ①㈱㎏㌕😀");
  display.println("Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞  ∑⇆⇅𝐹𝑥");
  display.println("艦隊これくしょんウマ娘\n碧蓝航线快把我哥带走\n廖添丁絕代凶賊之末日食用系少女\n블루아카이던전앤파이터브토막");

image.png

以下のことがわかります

  • 古の全角半角の大きさ比率 全角は正方形、半角はその半分幅。
  • ASCII文字はどれも同じ
  • ギリシャ語はアクセント記号無しなら大丈夫?
  • ギリシャ語、ロシア語はASCII文字と同じ幅
  • 数学記号は "Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞" は Unicode と JIS で規定されているもの、 "∑⇆⇅𝐹𝑥" は Unicode で規定されているもの。efontKR が健闘。
  • efontKR が日本フォントシェイプを含んでいる?

スケッチは以下のものを使いました。

#include "pc.hpp"
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>


LGFX display ( 750,1200,1 );

void setup() {
  display.init();
  display.setSwapBytes(true); 
  display.setTextSize(1);
}

void loop(){

// nlgfxJapan
  display.clear();
  display.setCursor(0, 0);


  display.setFont(&fonts::DejaVu18);
  display.setTextColor(TFT_BLACK, TFT_YELLOW);
  display.printf(      "\nefontJA_24 :(10/12/14/16/24px monospaced font)\n");
  display.setFont(&fonts::efontJA_24  );
  display.setTextColor(TFT_WHITE, TFT_BLACK);
  display.println(" !\"#$%&'()*+,./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
  display.println("Hello こんにちは 你好 안녕하세요 Καλή μέρα Здравствуйте يوم جيد ①㈱㎏㌕カナ😀");
  display.println("Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞  ∑⇆⇅𝐹𝑥");
  display.println("艦隊これくしょんウマ娘\n碧蓝航线快把我哥带走\n廖添丁絕代凶賊之末日食用系少女\n블루아카이던전앤파이터브토막");
  

  display.setFont(&fonts::DejaVu18);
  display.setTextColor(TFT_BLACK, TFT_YELLOW);
  display.printf(      "\nefontCN_24 :(10/12/14/16/24px monospaced font)\n");
  display.setFont(&fonts::efontCN_24  );
  display.setTextColor(TFT_WHITE, TFT_BLACK);
  display.println(" !\"#$%&'()*+,./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
  display.println("Hello こんにちは 你好 안녕하세요 Καλή μέρα Здравствуйте يوم جيد ①㈱㎏㌕カナ😀");
  display.println("Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞  ∑⇆⇅𝐹𝑥");
  display.println("艦隊これくしょんウマ娘\n碧蓝航线快把我哥带走\n廖添丁絕代凶賊之末日食用系少女\n블루아카이던전앤파이터브토막");
  

  display.setFont(&fonts::DejaVu18);
  display.setTextColor(TFT_BLACK, TFT_YELLOW);
  display.printf(      "\nefontTW_24 :(10/12/14/16/24px monospaced font)\n");
  display.setFont(&fonts::efontTW_24  );
  display.setTextColor(TFT_WHITE, TFT_BLACK);
  display.println(" !\"#$%&'()*+,./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
  display.println("Hello こんにちは 你好 안녕하세요 Καλή μέρα Здравствуйте يوم جيد ①㈱㎏㌕カナ😀");
  display.println("Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞  ∑⇆⇅𝐹𝑥");
  display.println("艦隊これくしょんウマ娘\n碧蓝航线快把我哥带走\n廖添丁絕代凶賊之末日食用系少女\n블루아카이던전앤파이터브토막");
  

  display.setFont(&fonts::DejaVu18);
  display.setTextColor(TFT_BLACK, TFT_YELLOW);
  display.printf(      "\nefontKR_24 :(10/12/14/16/24px monospaced font)\n");
  display.setFont(&fonts::efontKR_24  );
  display.setTextColor(TFT_WHITE, TFT_BLACK);
  display.println(" !\"#$%&'()*+,./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
  display.println("Hello こんにちは 你好 안녕하세요 Καλή μέρα Здравствуйте يوم جيد ①㈱㎏㌕カナ😀");
  display.println("Σ⇄←∫∀∂√∴≒℃№ℏ∈∇∞  ∑⇆⇅𝐹𝑥");
  display.println("艦隊これくしょんウマ娘\n碧蓝航线快把我哥带走\n廖添丁絕代凶賊之末日食用系少女\n블루아카이던전앤파이터브토막");
  

  delay(5000);
  
}


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0