Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
23c46664
Commit
23c46664
authored
Jul 13, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed MaterialFont to Font and updated Font for Swift 2.3
parent
dd004d08
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
82 deletions
+115
-82
Material.xcodeproj/project.pbxproj
+6
-6
Sources/iOS/Font.swift
+45
-31
Sources/iOS/RobotoFont.swift
+64
-45
No files found.
Material.xcodeproj/project.pbxproj
View file @
23c46664
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
96BCB7C11CB40DC500C806FE
/* MaterialDepth.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7781CB40DC500C806FE
/* MaterialDepth.swift */
;
};
96BCB7C11CB40DC500C806FE
/* MaterialDepth.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7781CB40DC500C806FE
/* MaterialDepth.swift */
;
};
96BCB7C21CB40DC500C806FE
/* MaterialDevice.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7791CB40DC500C806FE
/* MaterialDevice.swift */
;
};
96BCB7C21CB40DC500C806FE
/* MaterialDevice.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7791CB40DC500C806FE
/* MaterialDevice.swift */
;
};
96BCB7C31CB40DC500C806FE
/* MaterialEdgeInset.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77A1CB40DC500C806FE
/* MaterialEdgeInset.swift */
;
};
96BCB7C31CB40DC500C806FE
/* MaterialEdgeInset.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77A1CB40DC500C806FE
/* MaterialEdgeInset.swift */
;
};
96BCB7C41CB40DC500C806FE
/*
MaterialFont.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* Material
Font.swift */
;
};
96BCB7C41CB40DC500C806FE
/*
Font.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/*
Font.swift */
;
};
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
};
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C61CB40DC500C806FE
/* Icon.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
};
96BCB7C71CB40DC500C806FE
/* MaterialKeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
;
};
96BCB7C71CB40DC500C806FE
/* MaterialKeyframeAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
;
};
...
@@ -134,7 +134,7 @@
...
@@ -134,7 +134,7 @@
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76A1CB40DC500C806FE
/* Material+UIImage+Resize.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76B1CB40DC500C806FE
/* Material+UIImage+Size.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB76C1CB40DC500C806FE
/* Material+UIImage.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8311CB4115200C806FE
/*
MaterialFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/* Material
Font.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8311CB4115200C806FE
/*
Font.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77B1CB40DC500C806FE
/*
Font.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB77D1CB40DC500C806FE
/* Icon.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8341CB4115200C806FE
/* Layer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Layer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
96BCB8341CB4115200C806FE
/* Layer.swift in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7801CB40DC500C806FE
/* Layer.swift */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
96BCB7781CB40DC500C806FE
/* MaterialDepth.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialDepth.swift
;
sourceTree
=
"<group>"
;
};
96BCB7781CB40DC500C806FE
/* MaterialDepth.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialDepth.swift
;
sourceTree
=
"<group>"
;
};
96BCB7791CB40DC500C806FE
/* MaterialDevice.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialDevice.swift
;
sourceTree
=
"<group>"
;
};
96BCB7791CB40DC500C806FE
/* MaterialDevice.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialDevice.swift
;
sourceTree
=
"<group>"
;
};
96BCB77A1CB40DC500C806FE
/* MaterialEdgeInset.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialEdgeInset.swift
;
sourceTree
=
"<group>"
;
};
96BCB77A1CB40DC500C806FE
/* MaterialEdgeInset.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialEdgeInset.swift
;
sourceTree
=
"<group>"
;
};
96BCB77B1CB40DC500C806FE
/*
MaterialFont.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Material
Font.swift
;
sourceTree
=
"<group>"
;
};
96BCB77B1CB40DC500C806FE
/*
Font.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Font.swift
;
sourceTree
=
"<group>"
;
};
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialGravity.swift
;
sourceTree
=
"<group>"
;
};
96BCB77C1CB40DC500C806FE
/* MaterialGravity.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialGravity.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77D1CB40DC500C806FE
/* Icon.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Icon.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
96BCB77E1CB40DC500C806FE
/* MaterialKeyframeAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKeyframeAnimation.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -545,7 +545,7 @@
...
@@ -545,7 +545,7 @@
96BCB8071CB4101C00C806FE
/* Font */
=
{
96BCB8071CB4101C00C806FE
/* Font */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
96BCB77B1CB40DC500C806FE
/*
Material
Font.swift */
,
96BCB77B1CB40DC500C806FE
/* Font.swift */
,
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
,
96BCB7941CB40DC500C806FE
/* RobotoFont.swift */
,
);
);
name
=
Font
;
name
=
Font
;
...
@@ -691,7 +691,7 @@
...
@@ -691,7 +691,7 @@
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
,
96BCB82E1CB4115200C806FE
/* Material+UIImage+Resize.swift in Headers */
,
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
,
96BCB82F1CB4115200C806FE
/* Material+UIImage+Size.swift in Headers */
,
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
,
96BCB8301CB4115200C806FE
/* Material+UIImage.swift in Headers */
,
96BCB8311CB4115200C806FE
/*
Material
Font.swift in Headers */
,
96BCB8311CB4115200C806FE
/* Font.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
96BCB8321CB4115200C806FE
/* RobotoFont.swift in Headers */
,
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
,
96BCB8331CB4115200C806FE
/* Icon.swift in Headers */
,
96BCB8341CB4115200C806FE
/* Layer.swift in Headers */
,
96BCB8341CB4115200C806FE
/* Layer.swift in Headers */
,
...
@@ -941,7 +941,7 @@
...
@@ -941,7 +941,7 @@
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7D01CB40DC500C806FE
/* InterimSpace.swift in Sources */
,
96BCB7B31CB40DC500C806FE
/* Material+UIImage+Resize.swift in Sources */
,
96BCB7B31CB40DC500C806FE
/* Material+UIImage+Resize.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
96BCB7E81CB40DC500C806FE
/* Toolbar.swift in Sources */
,
96BCB7C41CB40DC500C806FE
/*
Material
Font.swift in Sources */
,
96BCB7C41CB40DC500C806FE
/* Font.swift in Sources */
,
96BCB7B41CB40DC500C806FE
/* Material+UIImage+Size.swift in Sources */
,
96BCB7B41CB40DC500C806FE
/* Material+UIImage+Size.swift in Sources */
,
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
,
96BCB7AA1CB40DC500C806FE
/* Grid.swift in Sources */
,
96BCB7E71CB40DC500C806FE
/* TextView.swift in Sources */
,
96BCB7E71CB40DC500C806FE
/* TextView.swift in Sources */
,
...
...
Sources/iOS/
Material
Font.swift
→
Sources/iOS/Font.swift
View file @
23c46664
...
@@ -30,61 +30,76 @@
...
@@ -30,61 +30,76 @@
import
UIKit
import
UIKit
public
protocol
Material
FontType
{}
public
protocol
FontType
{}
public
struct
MaterialFont
:
Material
FontType
{
public
struct
Font
:
FontType
{
/// Size of font.
/// Size of font.
public
static
let
pointSize
:
CGFloat
=
16
public
static
let
pointSize
:
CGFloat
=
16
/// Retrieves the system font with a specified size.
/**
public
static
func
systemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
Retrieves the system font with a specified size.
return
UIFont
.
systemFontOfSize
(
size
)
- Parameter fontName: A String font name.
*/
public
static
func
systemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
systemFont
(
ofSize
:
size
)
}
}
/// Retrieves the bold system font with a specified size.
/**
public
static
func
boldSystemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
Retrieves the bold system font with a specified size..
return
UIFont
.
boldSystemFontOfSize
(
size
)
- Parameter fontName: A String font name.
*/
public
static
func
boldSystemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
boldSystemFont
(
ofSize
:
size
)
}
}
/// Retrieves the italic system font with a specified size.
/**
public
static
func
italicSystemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
Retrieves the italic system font with a specified size.
return
UIFont
.
italicSystemFontOfSize
(
size
)
- Parameter fontName: A String font name.
*/
public
static
func
italicSystemFontWithSize
(
size
:
CGFloat
)
->
UIFont
{
return
UIFont
.
italicSystemFont
(
ofSize
:
size
)
}
}
/// Loads a font if it is needed.
/**
public
static
func
loadFontIfNeeded
(
fontName
:
String
)
{
Loads a given font if needed.
MaterialFontLoader
.
loadFontIfNeeded
(
fontName
)
- Parameter name: A String font name.
*/
public
static
func
loadFontIfNeeded
(
name
:
String
)
{
FontLoader
.
loadFontIfNeeded
(
name
:
name
)
}
}
}
}
/// Loads fonts packaged with Material.
/// Loads fonts packaged with Material.
private
class
Material
FontLoader
{
private
class
FontLoader
{
/// A Dictionary of the fonts already loaded.
/// A Dictionary of the fonts already loaded.
static
var
loadedFonts
:
Dictionary
<
String
,
String
>
=
Dictionary
<
String
,
String
>
()
static
var
loadedFonts
:
Dictionary
<
String
,
String
>
=
Dictionary
<
String
,
String
>
()
/// Loads a font specified if needed.
/**
static
func
loadFontIfNeeded
(
fontName
:
String
)
{
Loads a given font if needed.
let
loadedFont
:
String
?
=
MaterialFontLoader
.
loadedFonts
[
fontName
]
- Parameter fontName: A String font name.
*/
static
func
loadFontIfNeeded
(
name
:
String
)
{
let
loadedFont
:
String
?
=
FontLoader
.
loadedFonts
[
name
]
if
nil
==
loadedFont
&&
nil
==
UIFont
(
name
:
fontN
ame
,
size
:
1
)
{
if
nil
==
loadedFont
&&
nil
==
UIFont
(
name
:
n
ame
,
size
:
1
)
{
MaterialFontLoader
.
loadedFonts
[
fontName
]
=
fontN
ame
FontLoader
.
loadedFonts
[
name
]
=
n
ame
let
bundle
:
NSBundle
=
NSBundle
(
forClass
:
Material
FontLoader
.
self
)
let
bundle
=
Bundle
(
for
:
FontLoader
.
self
)
let
identifier
:
String
?
=
bundle
.
bundleIdentifier
let
identifier
=
bundle
.
bundleIdentifier
let
fontURL
:
NSURL
?
=
true
==
identifier
?
.
hasPrefix
(
"org.cocoapods"
)
?
bundle
.
URLForResource
(
fontName
,
withExtension
:
"ttf"
,
subdirectory
:
"io.cosmicmind.material.fonts.bundle"
)
:
bundle
.
URLForResource
(
fontN
ame
,
withExtension
:
"ttf"
)
let
fontURL
=
true
==
identifier
?
.
hasPrefix
(
"org.cocoapods"
)
?
bundle
.
urlForResource
(
name
,
withExtension
:
"ttf"
,
subdirectory
:
"io.cosmicmind.material.fonts.bundle"
)
:
bundle
.
urlForResource
(
n
ame
,
withExtension
:
"ttf"
)
if
let
v
:
NSURL
=
fontURL
{
if
let
v
=
fontURL
{
let
data
:
NSData
=
NSData
(
contentsOfURL
:
v
)
!
let
data
=
NSData
(
contentsOf
:
v
as
URL
)
!
let
provider
:
CGDataProvider
=
CGDataProviderCreateWithCFData
(
data
)
!
let
provider
=
CGDataProvider
(
data
:
data
)
!
let
font
:
CGFont
=
CGFontCreateWithDataProvider
(
provider
)
!
let
font
=
CGFont
(
provider
)
var
error
:
Unmanaged
<
CFError
>
?
var
error
:
Unmanaged
<
CFError
>
?
if
!
CTFontManagerRegisterGraphicsFont
(
font
,
&
error
)
{
if
!
CTFontManagerRegisterGraphicsFont
(
font
,
&
error
)
{
let
errorDescription
:
CFString
Ref
=
CFErrorCopyDescription
(
error
!.
takeUnretainedValue
())
let
errorDescription
:
CFString
=
CFErrorCopyDescription
(
error
!.
takeUnretainedValue
())
let
nsError
:
NSError
=
error
!.
takeUnretainedValue
()
as
AnyObject
as!
NSError
let
nsError
:
NSError
=
error
!.
takeUnretainedValue
()
as
AnyObject
as!
NSError
NSException
(
name
:
NSI
nternalInconsistencyException
,
reason
:
errorDescription
as
String
,
userInfo
:
[
NSUnderlyingErrorKey
:
nsError
])
.
raise
()
NSException
(
name
:
.
i
nternalInconsistencyException
,
reason
:
errorDescription
as
String
,
userInfo
:
[
NSUnderlyingErrorKey
:
nsError
])
.
raise
()
}
}
}
}
}
}
}
}
}
}
\ No newline at end of file
Sources/iOS/RobotoFont.swift
View file @
23c46664
...
@@ -30,79 +30,99 @@
...
@@ -30,79 +30,99 @@
import
UIKit
import
UIKit
public
struct
RobotoFont
:
Material
FontType
{
public
struct
RobotoFont
:
FontType
{
/// Size of font.
/// Size of font.
public
static
var
pointSize
:
CGFloat
{
public
static
var
pointSize
:
CGFloat
{
return
Material
Font
.
pointSize
return
Font
.
pointSize
}
}
/// Thin font.
/// Thin font.
public
static
var
thin
:
UIFont
{
public
static
var
thin
:
UIFont
{
return
thinWithSize
(
Material
Font
.
pointSize
)
return
thinWithSize
(
size
:
Font
.
pointSize
)
}
}
/// Thin with size font.
/// Light font.
public
static
func
thinWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
var
light
:
UIFont
{
MaterialFont
.
loadFontIfNeeded
(
"Roboto-Thin"
)
return
lightWithSize
(
size
:
Font
.
pointSize
)
}
/// Regular font.
public
static
var
regular
:
UIFont
{
return
regularWithSize
(
size
:
Font
.
pointSize
)
}
/// Medium font.
public
static
var
medium
:
UIFont
{
return
mediumWithSize
(
size
:
Font
.
pointSize
)
}
/// Bold font.
public
static
var
bold
:
UIFont
{
return
boldWithSize
(
size
:
Font
.
pointSize
)
}
/**
Thin with size font.
- Parameter size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
public
static
func
thinWithSize
(
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Thin"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
return
f
return
f
}
}
return
MaterialFont
.
systemFontWithSize
(
size
)
return
Font
.
systemFontWithSize
(
size
:
size
)
}
}
/// Light font.
/**
public
static
var
light
:
UIFont
{
Light with size font.
return
lightWithSize
(
MaterialFont
.
pointSize
)
- Parameter size: A CGFLoat for the font size.
}
- Returns: A UIFont.
*/
/// Light with size font.
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
lightWithSize
(
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Light"
)
MaterialFont
.
loadFontIfNeeded
(
"Roboto-Light"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
f
return
f
}
}
return
MaterialFont
.
systemFontWithSize
(
size
)
return
Font
.
systemFontWithSize
(
size
:
size
)
}
/// Regular font.
public
static
var
regular
:
UIFont
{
return
regularWithSize
(
MaterialFont
.
pointSize
)
}
}
/// Regular with size font.
/**
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
Regular with size font.
MaterialFont
.
loadFontIfNeeded
(
"Roboto-Regular"
)
- Parameter size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
public
static
func
regularWithSize
(
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Regular"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
return
f
}
}
return
MaterialFont
.
systemFontWithSize
(
size
)
return
Font
.
systemFontWithSize
(
size
:
size
)
}
}
/// Medium font.
/**
public
static
var
medium
:
UIFont
{
Medium with size font.
return
mediumWithSize
(
MaterialFont
.
pointSize
)
- Parameter size: A CGFLoat for the font size.
}
- Returns: A UIFont.
*/
/// Medium with size font.
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
mediumWithSize
(
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Medium"
)
MaterialFont
.
loadFontIfNeeded
(
"Roboto-Medium"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
f
return
f
}
}
return
MaterialFont
.
boldSystemFontWithSize
(
size
)
return
Font
.
boldSystemFontWithSize
(
size
:
size
)
}
/// Bold font.
public
static
var
bold
:
UIFont
{
return
boldWithSize
(
MaterialFont
.
pointSize
)
}
}
/// Bold with size font.
/**
public
static
func
boldWithSize
(
size
:
CGFloat
)
->
UIFont
{
Bold with size font.
MaterialFont
.
loadFontIfNeeded
(
"Roboto-Bold"
)
- Parameter size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
public
static
func
boldWithSize
(
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Bold"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
return
f
return
f
}
}
return
MaterialFont
.
boldSystemFontWithSize
(
size
)
return
Font
.
boldSystemFontWithSize
(
size
:
size
)
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment