Drawing improvements

This commit is contained in:
Ilya Laktyushin
2022-12-24 15:45:17 +04:00
parent c42220b618
commit 6ece02e998
3 changed files with 19 additions and 28 deletions

View File

@@ -78,7 +78,6 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
enum Font: Codable {
case sanFrancisco
case newYork
case other(String, String)
}
@@ -551,11 +550,9 @@ final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate {
var font: UIFont
switch self.textEntity.font {
case .sanFrancisco:
font = Font.with(size: fontSize, design: .regular, weight: .semibold)
case .newYork:
font = Font.with(size: fontSize, design: .serif, weight: .semibold)
font = Font.with(size: fontSize, design: .round, weight: .semibold)
case let .other(fontName, _):
font = UIFont(name: fontName, size: fontSize) ?? Font.with(size: fontSize, design: .regular, weight: .semibold)
font = UIFont(name: fontName, size: fontSize) ?? Font.with(size: fontSize, design: .round, weight: .semibold)
}
text.addAttribute(.font, value: font, range: range)
@@ -1286,6 +1283,7 @@ private var availableFonts: [String: (String, String)] = {
var preferredFont: String?
for name in names {
print(name)
let originalName = name
let name = name.lowercased()
if (!name.contains("-") || name.contains("regular")) && preferredFont == nil {
@@ -1301,6 +1299,6 @@ private var availableFonts: [String: (String, String)] = {
result[shortname] = (preferredFont, family)
}
}
print(result)
//print(result)
return result
}()