From 2991f158872ee49bdba83a15dbdb61f0b26e2fe6 Mon Sep 17 00:00:00 2001 From: Cristian-A Date: Sat, 21 Oct 2023 11:49:14 +0200 Subject: [PATCH 1/4] Fixed exhaustive switch warning --- Source/UI/MBezierPath+Extension_macOS.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/UI/MBezierPath+Extension_macOS.swift b/Source/UI/MBezierPath+Extension_macOS.swift index 4fbfe0b..462c908 100644 --- a/Source/UI/MBezierPath+Extension_macOS.swift +++ b/Source/UI/MBezierPath+Extension_macOS.swift @@ -52,6 +52,8 @@ extension MBezierPath { case .closePath: path.closeSubpath() + case .cubicCurveTo: fallthrough + case .quadraticCurveTo: fallthrough @unknown default: fatalError("Type of element undefined") } From 978a90289ec5288531366bb508a2f80133133e17 Mon Sep 17 00:00:00 2001 From: Cristian-A Date: Sat, 21 Oct 2023 11:49:31 +0200 Subject: [PATCH 2/4] Added font-weight support --- Source/Model/Primitives/SVGFont.swift | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/Model/Primitives/SVGFont.swift b/Source/Model/Primitives/SVGFont.swift index 77e6c86..0e2c3db 100644 --- a/Source/Model/Primitives/SVGFont.swift +++ b/Source/Model/Primitives/SVGFont.swift @@ -13,12 +13,33 @@ public class SVGFont: SerializableBlock { } public func toSwiftUI() -> Font { - return Font.custom(name, size: size)//.weight(fontWeight) + return Font.custom(name, size: size).weight(fontWeight(from: weight)) } func serialize(_ serializer: Serializer) { serializer.add("name", name, "Serif").add("size", size, 16).add("weight", weight, "normal") } + + private func fontWeight(from: String) -> Font.Weight { + // TODO: lighter and bolder are context-based, this is temporary. + switch from { + case "lighter": return .light + case "normal": return .regular + case "bold": return .bold + case "bolder": return .black + case "100": return .ultraLight + case "200": return .thin + case "300": return .light + case "400": return .regular + case "500": return .medium + case "600": return .semibold + case "700": return .bold + case "800": return .heavy + case "900": return .black + default: return .regular + } + } + } From 6e83d9db0e8a54a97b63fd4bc98b5c59d1bb314d Mon Sep 17 00:00:00 2001 From: Cristian Date: Thu, 26 Oct 2023 11:43:53 +0200 Subject: [PATCH 3/4] Update SVGFont.swift --- Source/Model/Primitives/SVGFont.swift | 42 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Source/Model/Primitives/SVGFont.swift b/Source/Model/Primitives/SVGFont.swift index 0e2c3db..1c601dc 100644 --- a/Source/Model/Primitives/SVGFont.swift +++ b/Source/Model/Primitives/SVGFont.swift @@ -23,20 +23,34 @@ public class SVGFont: SerializableBlock { private func fontWeight(from: String) -> Font.Weight { // TODO: lighter and bolder are context-based, this is temporary. switch from { - case "lighter": return .light - case "normal": return .regular - case "bold": return .bold - case "bolder": return .black - case "100": return .ultraLight - case "200": return .thin - case "300": return .light - case "400": return .regular - case "500": return .medium - case "600": return .semibold - case "700": return .bold - case "800": return .heavy - case "900": return .black - default: return .regular + case "lighter": + return .light + case "normal": + return .regular + case "bold": + return .bold + case "bolder": + return .black + case "100": + return .ultraLight + case "200": + return .thin + case "300": + return .light + case "400": + return .regular + case "500": + return .medium + case "600": + return .semibold + case "700": + return .bold + case "800": + return .heavy + case "900": + return .black + default: + return .regular } } From a349503c8d1d505e30092e992f2a0b1e88ad51db Mon Sep 17 00:00:00 2001 From: Cristian Date: Thu, 26 Oct 2023 11:44:27 +0200 Subject: [PATCH 4/4] Update MBezierPath+Extension_macOS.swift --- Source/UI/MBezierPath+Extension_macOS.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/UI/MBezierPath+Extension_macOS.swift b/Source/UI/MBezierPath+Extension_macOS.swift index 462c908..2cd0174 100644 --- a/Source/UI/MBezierPath+Extension_macOS.swift +++ b/Source/UI/MBezierPath+Extension_macOS.swift @@ -52,8 +52,10 @@ extension MBezierPath { case .closePath: path.closeSubpath() - case .cubicCurveTo: fallthrough - case .quadraticCurveTo: fallthrough + case .cubicCurveTo: + fallthrough + case .quadraticCurveTo: + fallthrough @unknown default: fatalError("Type of element undefined") }