ユーザ用ツール

サイト用ツール


android:viewのフォント追加

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
android:viewのフォント追加 [2019/11/15 23:06]
ips
android:viewのフォント追加 [2019/11/16 00:28] (現在)
ips [ビルドツールのインストール]
ライン 10: ライン 10:
 ====== bdfフォントttfに変換してをAndroidに追加する ====== ====== bdfフォントttfに変換してをAndroidに追加する ======
  
-<​code>​ +===== ビルドツールのインストール ===== 
-[[https://​ips.nekotype.com/​4991/​|wsl]]ubuntu... + 
-まずはビルドツールインストールする+<​code ​cmd
 + 
 +wslのubunt 
 + 
 +ビルドツールインストール
 $ sudo apt install build-essential $ sudo apt install build-essential
-$ sudo apt install make+... 
 +Do you want to continue? [Y/n] y 
 +Ign:1 http://​archive.ubuntu.com/​ubuntu bionic-updates/​main amd64 binutils-common amd64 2.30-20ubuntu2~18.04 
 +Err:1 http://​security.ubuntu.com/​ubuntu bionic-updates/​main amd64 binutils-common amd64 2.30-20ubuntu2~18.04 
 +  404  Not Found [IP: 2001:​67c:​1560:​8001::​11 80] 
 +...
  
-bdf2ttfをcloneする +# リポジトリ更新 
-git clone https://github.com/koron/bdf2ttf.git +sudo sed -i.bak -e "​s%http://archive.ubuntu.com/ubuntu/%http://ftp.jaist.ac.jp/​pub/​Linux/​ubuntu/​%g"​ /​etc/​apt/​sources.list
-$ cd bdf2ttf+
  
 +# やっぱりエラー
 +$ sudo apt install build-essential
 +Reading package lists... Done
 +Building dependency tree
 +Reading state information... Done
 +E: Unable to locate package build-essential
 +
 +
 +# aptアップデートが必要だった(これをしないとaptできない)
 +$ sudo apt update
 +
 +# ビルドツールのインストール
 +$ sudo apt install build-essential
 +
 +# 確認
 +$ gcc -version
 +gcc: error: unrecognized command line option ‘-version’
 +gcc: fatal error: no input files
 +compilation terminated.
 +</​code>​
 +
 +<​code>​
 +bdf2ttfをcloneしてコンパイルする
 +$ git clone git@github.com:​koron/​bdf2ttf.git
 +$ cd bdf2ttf
 +$ cp compile/​Make_gcc.mak makefile
 +$ make
  
 +// dbf を ttfに変換
 +$ ./bdf2ttf ayu20gothic-1.7a.ttf ./​sample.ini ./​ayu20gothic-1.7a/​10x20grkm.bdf
 </​code> ​ </​code> ​
  
 +↓ttfファイルができあがる
 +{{:​android:​pasted:​20191115-232102.png}}
  
 +↓appにassetsフォルダを作成する。
 + Target Source Set が「main」になっていることを確認して Finish。
 {{:​android:​pasted:​20191115-222111.png}} {{:​android:​pasted:​20191115-222111.png}}
 +
 +↓assetsの中にfontディレクトリを作成する
 +{{:​android:​pasted:​20191115-233159.png}}
 +
 +↓ttfを貼り付ける。
 +{{:​android:​pasted:​20191115-233318.png}}
 +
 +# app.gradleに追加
 +implementation '​uk.co.chrisjenx:​calligraphy:​2.3.0'​
 +
 +
 +<​code>​
 +       val am = this.getApplicationContext().getAssets()
 +       val typeface = Typeface.createFromAsset(am,​String.format(Locale.US,​ "​font/​%s",​ "​shnm6x12a.ttf"​))
 +       
 +       ​もしくは
 +       
 +       val custom_font = Typeface.createFromAsset(assets,​ "​font/​shnm6x12a.ttf"​)
 +       
 +       ↓
 +       
 +       ​holder.textTitle?​.typeface=typeface
 +       ​holder.textSub?​.typeface=typeface
 +</​code>​
 +
android/viewのフォント追加.1573826817.txt.gz · 最終更新: 2019/11/15 23:06 by ips