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 3 years have passed since last update.

P5.js 日本語リファレンス(textFont)

Last updated at Posted at 2020-06-21

このページでは[「P5.js 日本語リファレンス」] (https://qiita.com/bit0101/items/91818244dc26c767a0fe) の textFont関数を説明します。

textFont()

説明文

text() で描画される現在のフォントを設定します。

WEBGLモードのとき:loadFont() を介して読み込まれたフォントのみがサポートされます。

構文

textFont()

textFont(font, [size])

パラメタ

  • font
    Object | String:loadFont() を介して読み込まれたフォント、またはWebセーフフォント(すべてのシステムで一般的に利用可能なフォント)を表す文字列

  • size
    Number:使用するフォントサイズ(オプション、デフォルト:12)

戻り値

Object:現在のフォント

例1

let fontRegular,  fontBold;

function preload() {
  fontRegular = loadFont('assets/Inconsolata-Regular.ttf');
  fontBold = loadFont('assets/Inconsolata-Bold.ttf');
}

function setup()  {
  createCanvas(300, 300);
  background(210);
  fill(0)
   .strokeWeight(0)
   .textSize(24);
  textFont(fontRegular);
  text('Font Style Normal', 10, 30);
  textFont(fontBold);
  text('Font Style Bold', 10, 70);
}

実行結果

https://editor.p5js.org/bit0101/sketches/t1EsW2OD_

著作権

p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.

ライセンス

Creative Commons(CC BY-NC-SA 4.0) に従います。

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?