Skip to content

Commit

Permalink
Update Text.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
JoachimM7 authored Dec 8, 2017
1 parent ad365d3 commit 1afb910
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Source/model/scene/Text.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ open class Text: Node {
if let customFont = RenderUtils.loadFont(name: f.name, size: f.size) {
font = customFont
} else {
font = MFont.systemFont(ofSize: CGFloat(f.size))
font = MFont.systemFont(ofSize: CGFloat(f.size), weight: getWeight(f.weight))
}
} else {
font = MFont.systemFont(ofSize: MFont.mSystemFontSize)
Expand All @@ -85,6 +85,21 @@ open class Text: Node {
h: size.height.doubleValue
)
}

fileprivate func getWeight(_ weight: String) -> MFont.Weight {
switch weight {
case "normal":
return MFont.Weight.regular
case "bold":
return MFont.Weight.bold
case "bolder":
return MFont.Weight.semibold
case "lighter":
return MFont.Weight.light
default:
return MFont.Weight.regular
}
}

fileprivate func calculateBaselineOffset(font: MFont) -> Double {
var baselineOffset = 0.0
Expand Down

0 comments on commit 1afb910

Please sign in to comment.