0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

M5Paper: Noto_Sans_JP フォントを使う

Last updated at Posted at 2022-06-28

次のフォントファイルをダウンロードします。

Noto_Sans_JP.zip

解凍して出来た次のファイルを使います。

NotoSansJP-Regular.otf

このファイルを ttf に変換します。
変換は、 Ubuntu 22.04 で、fontforge を使いました。
fontforge の使い方はこちら
FontForgeで OTF形式のフォントファイルを TTF形式に変換する方法

変換結果

4548208  1月 29  2015 NotoSansJP-Regular.otf
4968020  6月 28 13:23 NotoSansJP-Regular.ttf

NotoSansJP-Regular.ttf を font.ttf にリメームして、
fat32 で初期化した SD に書き込みます。

M5Paper のプログラム

ttf_sd.ino
// ---------------------------------------------------------------
//	ttf_sd.ino
//
//				Jun/28/2022
// ---------------------------------------------------------------
#include <M5EPD.h>
#include <FS.h>

#define USE_SD

M5EPD_Canvas canvas(&M5.EPD);

// ---------------------------------------------------------------
void setup() {
	M5.begin();
	M5.TP.SetRotation(90);
	M5.EPD.SetRotation(90);
	M5.EPD.Clear(true);
Serial.print ("*** setup ***\r\n");
Serial.print ("*** Jun/28/2022 PM 14:00 ***\r\n");
 	

	canvas.createCanvas(540, 960);
	canvas.setTextDatum(TC_DATUM);
	canvas.setTextSize(3);

	canvas.drawString("... Initializing ...", 270, 640);
	canvas.pushCanvas(0,0,UPDATE_MODE_A2);

	canvas.drawString("Loading font ...", 270, 230);
	canvas.pushCanvas(0,0,UPDATE_MODE_A2);

	Serial.print ("*** bbb ***\r\n");
	canvas.loadFont("/font.ttf", SD);
	Serial.print ("*** ccc ***\r\n");
 
	canvas.createRender(96, 256);
	canvas.createRender(40, 256);
	Serial.print ("*** ddd ***\r\n");

	canvas.drawString("OK!", 270, 254);
	canvas.pushCanvas(0,0,UPDATE_MODE_A2);
Serial.print ("*** eee ***\r\n");


	// 時計を描画
//	M5.EPD.Clear(true);
}

// ---------------------------------------------------------------
void loop() {
	draw_proc();
	delay(5000);
	Serial.print("*** loop ***\r\n");
}

// ---------------------------------------------------------------
void draw_proc() {

	canvas.setTextDatum(TL_DATUM);
	canvas.fillCanvas(0);
	canvas.drawLine(0, 80, 540, 80, 2, 15);

	String arraya[] = {"ブレーメンの音楽隊","白雪姫","あかずきん",
			"ヘンデルとグレーテル","おおかみと七匹のこやぎ",
			"灰かぶり","親指こぞう","三枚の鳥の羽",
		"AAAA","BBBB","CCCC","DDDD","EEEE","FFFF","IIII","JJJJ"};
int xpos = 50;
	canvas.setTextSize(40);

	for (short it=0; it< 16; it++)
		{	
		canvas.drawString(arraya[it], xpos, 100 + 50 *  it);
		}

// canvas.pushCanvas(0,0,UPDATE_MODE_DU4);
	
	 canvas.pushCanvas(0,0,UPDATE_MODE_A2);

}

// ---------------------------------------------------------------

Arduino IDE
image.png

SD を挿入して実行した結果
IMG_20220628_142600.jpg

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?