LoginSignup
0
1

More than 1 year has passed since last update.

Rails6でフォントをカスタマイズしたい

Posted at

作成中のアプリで手書き風の表示にしたかったので、フォントを導入したかったんです。

手順はめちゃくちゃ簡単

1.フォントをダウンロードする

お好きなフォントをダウンロードしてください。
使用するのはttf,otfと言う拡張子のファイルです。

2.app/assets配下にfontsディレクトリを作成する

ぶっちゃけfontsじゃなくても良いですが、わかりやすいディレクトリ名にしましょう

3.ダウンロードしたフォントファイルをfontsディレクトリに配置

4.application.scssの変更

app/assets/stylesheets/application.scss
 *= require_tree .
 *= require_self
 */

 @font-face {
  font-family: "huifont"; #好きな名前でOK
  font-style: normal;
  src: asset_url('HuiFont29.ttf');
}

これであとは実際のcssでfont-familyで設定したクラス名を指定してあげれば適用できます。

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