Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
フォントの基本とUIFont/UIFontDescriptor
Search
satoshin21
January 14, 2017
Programming
12
3.5k
フォントの基本とUIFont/UIFontDescriptor
デザイナーとのコミュニケーションに必須なフォントの基本と
iOSの開発に用いられるUIFontと更に柔軟にフォントを扱えるUIFontDescriptorについて #potatotips36
satoshin21
January 14, 2017
Tweet
Share
More Decks by satoshin21
See All by satoshin21
少数精鋭で戦うための技術的改善について
satoshin21
3
1.1k
GTXiLibで小さく始めるAccessibility Testing
satoshin21
0
4.9k
iPhoneのカメラで写真撮影から現像までの技術を紐解く
satoshin21
4
3.2k
try! swift-sh
satoshin21
2
880
Reduxを取り入れて開発はpairs開発はどう変わったか
satoshin21
0
350
レガシーなアプリケーションの 60fps化を目指す為にやっていること
satoshin21
12
3.8k
Introducing CodeLayout with Tips
satoshin21
6
1.5k
World of No Interface Builder
satoshin21
0
1.8k
What I've done to attend WWDC
satoshin21
0
95
Other Decks in Programming
See All in Programming
Symfony Mapper Component
soyuka
2
730
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
160
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
Haze - Real time background blurring
chrisbanes
1
510
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
370
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
67
4.4k
Building Adaptive Systems
keathley
38
2.3k
Typedesign – Prime Four
hannesfritz
40
2.4k
Making Projects Easy
brettharned
116
5.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Docker and Python
trallard
42
3.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
4 Signs Your Business is Dying
shpigford
181
21k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
BBQ
matthewcrist
85
9.4k
Code Review Best Practice
trishagee
65
17k
Transcript
ϑΥϯτͷجຊͱ UIFont/UIFontDescriptor @SatoshiN21
satoshin21 SatoshiN21 ࡔ ޛࢤ (Nagasaka Satoshi) - iOS Engineer of
pairs Div. eureka, Inc. - Swift, Objective-C, Java(Android), Apple Script
- pairs - Couples
class UIFont
ϑΥϯτ/ॻମ ‣ ϑΥϯτ㲈ॻମ w ॻମʮ͋ΔҰ؏ͨ͠σβΠϯํͰ࡞ΒΕͨจࣈͷू·Γʯ w ൛ͱ w ϑΥϯτͦΕΛදݱ͢Δखஈɺ͘͠Ұଗ͍ͷσʔλ
UIFont ‣ 6*'POU͕͍࣋ͬͯΔใ w /BNF GPOU/BNF GBNJMZ/BNF w QPJOU4J[F
w )FJHIUܥ MJOF)FJHIU MFBEJOH DBQ)FJHIU w CBTFMJOFܥ
baseline CBTFMJOF YIFJHIU DBQTIFJHIU "TDFOEFS %FTDFOEFS
baseline CBTFMJOF YIFJHIU DBQTIFJHIU "TDFOEFS %FTDFOEFS ‣ CBTFMJOFΛىʹͯ͠ԤจϑΥϯτϨΠΞτ͞ΕΔ ‣ BTDFOEFS
w CBTFMJOF͔Β্෦ͷڑ ‣ EFTDFOEFS w CBTFMJOF͔ΒԼ෦ͷڑ ෛ ‣ MFBEJOH w GPOUͷ࣋ͭߦؒ w MFBEJOHͷͳ͍ϑΥϯτ γεςϜϑΥϯτͳͲ
// San Francisco(.SFUIText) let font = UIFont.systemFont(ofSize: 12) let height
= abs(font.descender) + font.ascender + font.leading font.lineHeight == height // true font.lineHeight
AutoLayout தԝἧ͑ minLabel.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 10).isActive = true minLabel.rightAnchor.constraint(equalTo: largeLabel.leftAnchor,
constant: -12).isActive = true // Y軸を揃える minLabel.centerYAnchor .constraint(equalTo: largeLabel.centerYAnchor).isActive = true
AutoLayout firstBaseline // first baselineを揃える minLabel.firstBaselineAnchor .constraint(equalTo: largeLabel.firstBaselineAnchor).isActive = true
AutoLayout lastBaseline // last baselineを揃える minLabel.lastBaselineAnchor.constraint(equalTo : largeLabel.lastBaselineAnchor).isActive = true
ϑΥϯτʹҰखؒՃ͍͑ͨɾɾ
class UIFontDescriptor
UIFontDescriptorͱ ‣ ༷ʑͳϑΥϯτใΛऔಘ͢Δ͜ͱ͕Մೳ w ΣΠτɺΧεέʔυϑΥϯτɺελΠϧ ࣼମͷ֯ ‣ ্هͷΛมߋɺՃ͢Δ͜ͱ͕Մೳ
UIFontDescriptorCascadeListAttribute ‣ ΧεέʔυϑΥϯτΛྻͰࢦఆ ‣ ຊޠͷ߹͜ͷϑΥϯτͰද͍ࣔͨ͠ͱ͍͏࣌ͳͲʹ׆༻
UIFontDescriptorCascadeListAttribute let fontDescriptor = UIFontDescriptor(fontAttributes: [UIFontDescriptorNameAttribute: ".SFUIDisplay"]) let japaneseFont =
UIFontDescriptor(fontAttributes: [UIFontDescriptorNameAttribute: "HiraMinProN-W3"]) // カスケードフォントを配列で指定 let mixedFontDescriptor = fontDescriptor.addingAttributes([UIFontDescriptorCascadeListAttribute: [japaneseFont]]) label.font = UIFont(descriptor: mixedFontDescriptor, size: 75)
UIFontDescriptorMatrixAttribute ‣ ֤άϦϑ จࣈ ʹରͯ͠ΞϑΟϯม $("⒏OF5SBOTGPSN Λߦ͏ w ֦େɾॖখ w
ճసͳͲ
UIFontDescriptorMatrixAttribute let scale = CGAffineTransform(scaleX: 1.0, y: 2.0) let fontDescriptor
= UIFontDescriptor(name: ".SFUIDisplay", matrix: scale) label.font = UIFont(descriptor: fontDescriptor, size: 75)
UIFontDescriptorMatrixAttribute let rotate = CGAffineTransform(rotationAngle: CGFloat(M_PI * 15.0 / 180.0))
let fontDescriptor = UIFontDescriptor(name: ".SFUIDisplay", matrix: rotate) label2.font = UIFont(descriptor: fontDescriptor, size: 75)
ͦͷଞ UIFontDescriptor Attributes ‣ 6*'POU%FTDSJQUPS5SBJUT"UUSJCVUF w ΣΠτଐੑઢͷ෯ɺࣼମͷ֯ͳͲͷϑΥϯτಛੑ ‣ 6*'POU%FTDSJQUPS'JYFE"EWBODF"UUSJCVUF w
ࣈૹΓ "EWBODF ͷΛࢦఆ w ࣈؒ/4"UUSJCVUFE4USJOHͷ/4,FSO"UUSJCVUF/BNFͰࢦఆ
ϑΥϯτΛཧղͯ͠ σβΠφʔͱԁͳίϛϡχέʔγϣϯΛ
Thank you IUUQTXXXOBTBHPWNJTTJPO@QBHFT/11OFXTFBSUIBUOJHIUIUNM