Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Typeface
Keishin Yokomaku
September 24, 2014
Technology
0
1k
Typeface
Android library for easy use of typeface.
Keishin Yokomaku
September 24, 2014
Tweet
Share
More Decks by Keishin Yokomaku
See All by Keishin Yokomaku
持続的なアプリ開発のためのDXを支える技術
keithyokoma
2
4.1k
Make the objects serializable with kotlinx.serialization
keithyokoma
0
3.2k
Kotlin で書く Gradle Custom Tasks
keithyokoma
0
400
DX Improvements
keithyokoma
3
310
Get Things Done with Gradle Custom Tasks
keithyokoma
1
82
詳解 Android Auto - 使い方からそれを支える技術まで -
keithyokoma
1
2k
Fail fast, Fail cheap, Fail automatically: Localization
keithyokoma
0
120
WebView😇😇😇
keithyokoma
0
630
Android 1.5 - 8.0 Walk through - Retro/Prospective Android Application Development
keithyokoma
4
250
Other Decks in Technology
See All in Technology
アムロは成長しているのか AIから分析する
miyakemito
1
350
20230123_FinJAWS
takuyay0ne
0
110
グローバルチームことはじめ / Bootstrapping a global team
tasshi
1
630
230125 モニターマウントLT ITガジェット翁(Ryu.Cyber)さん
comucal
PRO
0
260
USB PD で迎える AC アダプター大統一時代
puhitaku
2
1.5k
AKIBA.SaaS資料
yasumuusan
0
160
ステート管理を超えるRecoil運用の考え方
uhyo
7
5.4k
AI Services 概要 / AI Services overview
oracle4engineer
PRO
0
160
IoTを始めたきっかけの話と個人でできるIoTの今後 / 新年LT会「私の愛するIoT 2023」
you
0
140
plotlyで動くグラフを作る
kosshi
0
730
230125 古いタブレットの活用 かーでぃさん
comucal
PRO
0
1k
Akiba-dot-SaaS-ExtraHop
sakaitakeshi
1
110
Featured
See All Featured
Music & Morning Musume
bryan
36
4.6k
Designing with Data
zakiwarfel
91
4.2k
jQuery: Nuts, Bolts and Bling
dougneiner
57
6.6k
GitHub's CSS Performance
jonrohan
1020
430k
Building a Modern Day E-commerce SEO Strategy
aleyda
6
4.5k
Building Flexible Design Systems
yeseniaperezcruz
314
35k
Atom: Resistance is Futile
akmur
256
24k
The Illustrated Children's Guide to Kubernetes
chrisshort
22
42k
Ruby is Unlike a Banana
tanoku
93
9.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
29
7.8k
Statistics for Hackers
jakevdp
785
210k
Adopting Sorbet at Scale
ufuk
65
7.8k
Transcript
Typeface @KeithYokoma - Drivemode, Inc. potatotips #9
About myself • KeithYokoma • Keishin Yokomaku • Drivemode, Inc.
• GitHub: https://github.com/KeithYokoma • e-Book: http://amzn.to/1mZNydv
Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface
Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface Typeface
http://bit.ly/1rjOdtN
Typeface • Cool • Nice • Beautiful • Android provides
Roboto by default
Typeface • If you would like to change the typeface…
TextView#setTypeface(Typeface) Paint#setTypeface(Typeface) Button#setTypeface(Typeface) EditText#setTypeface(Typeface)
Typeface • Read Typeface from your assets Typeface.createFromAsset(AssetManager, String)
Typeface • Read Typeface from your assets ! • Caution!
Typeface.createFromAsset(AssetManager, String) Typeface.createFromAsset leaks asset stream! http://bit.ly/1rVOkir
Typeface • Workaround: cache private final Hashtable<String, Typeface> mCache =
new Hashtable<String, Typeface>();! private final Application mApplication;! ! public synchronized Typeface get(String name) {! ! Typeface typeface = mCache.get(name);! ! if(typeface == null) {! ! ! try {! ! ! ! typeface = Typeface.createFromAsset(mApplication.getAssets(), name);! ! ! } catch (Exception exp) {! ! ! ! return null;! ! ! }! ! ! mCache.put(name, typeface);! ! }! ! return typeface;! }
Typeface • If you would like to change the typeface
for ActionBar title Dialog button texts Dialog message text ActionBar tab text All text views in the view group blah blah blah…
Typeface • Got it, we introduce you our library! TypefaceHelper
- http://bit.ly/1AxfqLz
Typeface • First, initialize the object in your Application. public
class SampleApp extends Application {! ! @Override! ! public void onCreate() {! ! ! super.onCreate();! ! ! TypefaceHelper.initialize(this);! ! }! ! ! @Override! ! public void onTerminate() {! ! ! TypefaceHelper.destroy();! ! ! super.onTerminate();! ! }! }
Typeface • Set your Typeface. public class SampleActivity extends Activity
{! ! ! TextView mTextView;! ! ! @Override! ! public void onCreate(Bundle icicle) {! ! ! // …! ! ! TypefaceHelper helper = TypefaceHelper.getInstance();! ! ! helper.setTypeface(this, “MyFont.ttf”);! ! ! helper.setTypeface(mTextView, “Another.ttf”);! ! }! }
Typeface • That's it. Just do it!
Typeface • You can set your Typeface to… • All
views that is a child of TextView. • All TextViews that is belong to ViewGroup. • Activity, Fragment, Dialog. • Canvas(thanks to Nohana team!)
Typeface • Works in progress 1. OptionsMenu 2. Preferences 3.
Set typeface by annotation
Typeface @KeithYokoma - Drivemode, Inc. potatotips #9