Commit ee9cc8d1 by Daniel Dahan

updated font facility

parent 61144394
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */; settings = {ASSET_TAGS = (); }; }; 65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */; settings = {ASSET_TAGS = (); }; };
65BDD14D1BB5ED9F006F7F2B /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */; settings = {ASSET_TAGS = (); }; }; 65BDD14D1BB5ED9F006F7F2B /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */; settings = {ASSET_TAGS = (); }; };
65BDD14F1BB5EE4A006F7F2B /* MaterialGravity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */; settings = {ASSET_TAGS = (); }; }; 65BDD14F1BB5EE4A006F7F2B /* MaterialGravity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */; settings = {ASSET_TAGS = (); }; };
65BDD1521BB6EE7C006F7F2B /* RobotoFont.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65BDD1511BB6EE7C006F7F2B /* RobotoFont.swift */; settings = {ASSET_TAGS = (); }; };
65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */; }; 65DBE4201B9A9244000C804F /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */; };
65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; }; 65DBE4211B9A9244000C804F /* Roboto-Thin.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */; };
962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; }; 962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */; };
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialFont.swift; sourceTree = "<group>"; }; 65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialFont.swift; sourceTree = "<group>"; };
65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTheme.swift; sourceTree = "<group>"; }; 65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTheme.swift; sourceTree = "<group>"; };
65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialGravity.swift; sourceTree = "<group>"; }; 65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialGravity.swift; sourceTree = "<group>"; };
65BDD1511BB6EE7C006F7F2B /* RobotoFont.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RobotoFont.swift; sourceTree = "<group>"; };
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; }; 65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = "<group>"; };
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; }; 65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Thin.ttf"; sourceTree = "<group>"; };
962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; }; 962F3E521BACA68C0004B8AD /* NavigationBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationBarView.swift; sourceTree = "<group>"; };
...@@ -82,6 +84,19 @@ ...@@ -82,6 +84,19 @@
name = View; name = View;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
65BDD1501BB6EE5C006F7F2B /* Roboto */ = {
isa = PBXGroup;
children = (
65BDD1511BB6EE7C006F7F2B /* RobotoFont.swift */,
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */,
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */,
9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */,
9AAC38571B8956CF00FE6B2D /* Roboto-Medium.ttf */,
9AAC38551B8956C500FE6B2D /* Roboto-Light.ttf */,
);
name = Roboto;
sourceTree = "<group>";
};
9638322C1B88DFD80015F710 = { 9638322C1B88DFD80015F710 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -142,7 +157,6 @@ ...@@ -142,7 +157,6 @@
children = ( children = (
65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */, 65BDD14C1BB5ED9F006F7F2B /* MaterialTheme.swift */,
65BDD1481BB5DC98006F7F2B /* MaterialColor.swift */, 65BDD1481BB5DC98006F7F2B /* MaterialColor.swift */,
65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */,
65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */, 65BDD14E1BB5EE4A006F7F2B /* MaterialGravity.swift */,
); );
name = Theme; name = Theme;
...@@ -151,11 +165,8 @@ ...@@ -151,11 +165,8 @@
9AAC38521B89553800FE6B2D /* Font */ = { 9AAC38521B89553800FE6B2D /* Font */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
65DBE41E1B9A9244000C804F /* Roboto-Bold.ttf */, 65BDD14A1BB5DD02006F7F2B /* MaterialFont.swift */,
65DBE41F1B9A9244000C804F /* Roboto-Thin.ttf */, 65BDD1501BB6EE5C006F7F2B /* Roboto */,
9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */,
9AAC38571B8956CF00FE6B2D /* Roboto-Medium.ttf */,
9AAC38551B8956C500FE6B2D /* Roboto-Light.ttf */,
); );
name = Font; name = Font;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -276,6 +287,7 @@ ...@@ -276,6 +287,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
65BDD1471BB5B916006F7F2B /* MaterialView.swift in Sources */, 65BDD1471BB5B916006F7F2B /* MaterialView.swift in Sources */,
65BDD1521BB6EE7C006F7F2B /* RobotoFont.swift in Sources */,
962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */, 962F3E531BACA68C0004B8AD /* NavigationBarView.swift in Sources */,
65BDD14F1BB5EE4A006F7F2B /* MaterialGravity.swift in Sources */, 65BDD14F1BB5EE4A006F7F2B /* MaterialGravity.swift in Sources */,
65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */, 65BDD14B1BB5DD02006F7F2B /* MaterialFont.swift in Sources */,
......
...@@ -18,95 +18,32 @@ ...@@ -18,95 +18,32 @@
import UIKit import UIKit
// font public protocol MaterialFontType {}
public struct MaterialFont {
public struct MaterialFont : MaterialFontType {
/** /**
:name: pointSize :name: pointSize
*/ */
public static var pointSize: CGFloat = 16 public static let pointSize: CGFloat = 16
/**
:name: thin
*/
public static var thin: UIFont {
return thinWithSize(MaterialFont.pointSize)
}
/** /**
:name: thinWithSize :name: systemFontWithSize
*/ */
public static func thinWithSize(size: CGFloat) -> UIFont { public static func systemFontWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Thin", size: size) {
return f
}
return UIFont.systemFontOfSize(size) return UIFont.systemFontOfSize(size)
} }
/** /**
:name: light :name: boldSystemFontWithSize
*/ */
public static var light: UIFont { public static func boldSystemFontWithSize(size: CGFloat) -> UIFont {
return lightWithSize(MaterialFont.pointSize) return UIFont.boldSystemFontOfSize(size)
} }
/** /**
:name: lightWithSize :name: italicSystemFontWithSize
*/ */
public static func lightWithSize(size: CGFloat) -> UIFont { public static func italicSystemFontWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Light", size: size) { return UIFont.italicSystemFontOfSize(size)
return f
}
return UIFont.systemFontOfSize(size)
}
/**
:name: regular
*/
public static var regular: UIFont {
return regularWithSize(MaterialFont.pointSize)
}
/**
:name: mediumWithSize
*/
public static func mediumWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Medium", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
/**
:name: medium
*/
public static var medium: UIFont {
return mediumWithSize(MaterialFont.pointSize)
}
/**
:name: regularWithSize
*/
public static func regularWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
/**
:name: bold
*/
public static var bold: UIFont {
return boldWithSize(MaterialFont.pointSize)
}
/**
:name: boldWithSize
*/
public static func boldWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
} }
} }
\ No newline at end of file
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
import UIKit import UIKit
public class MaterialView: UIView { public class MaterialView: UIView {
/** /**
:name: image :name: image
*/ */
...@@ -197,10 +196,10 @@ public class MaterialView: UIView { ...@@ -197,10 +196,10 @@ public class MaterialView: UIView {
:name: prepareBounds :name: prepareBounds
*/ */
internal func prepareBounds() { internal func prepareBounds() {
self.x = frame.origin.x x = frame.origin.x
self.y = frame.origin.y y = frame.origin.y
self.width = frame.size.width width = frame.size.width
self.height = frame.size.height height = frame.size.height
} }
/** /**
......
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public struct RobotoFont : MaterialFontType {
/**
:name: pointSize
*/
public static var pointSize: CGFloat {
return MaterialFont.pointSize
}
/**
:name: thin
*/
public static var thin: UIFont {
return thinWithSize(MaterialFont.pointSize)
}
/**
:name: thinWithSize
*/
public static func thinWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Thin", size: size) {
return f
}
return MaterialFont.systemFontWithSize(size)
}
/**
:name: light
*/
public static var light: UIFont {
return lightWithSize(MaterialFont.pointSize)
}
/**
:name: lightWithSize
*/
public static func lightWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Light", size: size) {
return f
}
return MaterialFont.systemFontWithSize(size)
}
/**
:name: regular
*/
public static var regular: UIFont {
return regularWithSize(MaterialFont.pointSize)
}
/**
:name: regularWithSize
*/
public static func regularWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return MaterialFont.systemFontWithSize(size)
}
/**
:name: mediumWithSize
*/
public static func mediumWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Medium", size: size) {
return f
}
return MaterialFont.boldSystemFontWithSize(size)
}
/**
:name: medium
*/
public static var medium: UIFont {
return mediumWithSize(MaterialFont.pointSize)
}
/**
:name: bold
*/
public static var bold: UIFont {
return boldWithSize(MaterialFont.pointSize)
}
/**
:name: boldWithSize
*/
public static func boldWithSize(size: CGFloat) -> UIFont {
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return MaterialFont.boldSystemFontWithSize(size)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment