Skip to content

Commit

Permalink
Merge pull request #248 from Lupurus/Text/text_bounds_
Browse files Browse the repository at this point in the history
Resolve #241: Text bounds fix
  • Loading branch information
ystrot authored Dec 18, 2017
2 parents c82404f + 1afb910 commit d001a4c
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 d001a4c

Please sign in to comment.