Skip to content

Commit

Permalink
Merge pull request #461 from aure/master
Browse files Browse the repository at this point in the history
Moved lowercasing as to not be destructive
  • Loading branch information
ystrot authored Aug 20, 2018
2 parents 5c1ae4e + be9cec1 commit e188751
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Source/render/RenderUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,22 @@ class RenderUtils {
class func loadFont(name: String, size: Int, weight: String?) -> MFont? {

var fontName = ""
let fontPriorities = name.split(separator: ",").map { String($0).trimmingCharacters(in: CharacterSet(charactersIn: " '")).lowercased() }
let fontPriorities = name.split(separator: ",").map { String($0).trimmingCharacters(in: CharacterSet(charactersIn: " '")) }

for font in fontPriorities {
if availableFonts.contains(font) {
let lowercasedFont = font.lowercased()

if availableFonts.contains(lowercasedFont) {
fontName = font
}

if font == "serif" {
if lowercasedFont == "serif" {
fontName = "Georgia"
}
if font == "sans-serif" {
if lowercasedFont == "sans-serif" {
fontName = "Arial"
}
if font == "monospace" {
if lowercasedFont == "monospace" {
fontName = "Courier"
}
}
Expand Down

0 comments on commit e188751

Please sign in to comment.