@matiks/rn-stroke-text 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,8 +111,8 @@ class StrokeTextView: UIView {
111
111
  private func updateFont() {
112
112
  let size = CGFloat(truncating: fontSize)
113
113
 
114
- let (family, weight) = parseFontFamily(fontFamily)
115
- let resolvedName = resolveFontName(family: family, weight: weight)
114
+ let (family, weight, italic) = parseFontFamily(fontFamily)
115
+ let resolvedName = resolveFontName(family: family, weight: weight, italic: italic)
116
116
 
117
117
  let cacheKey = "\(resolvedName)-\(size)"
118
118
  if let cached = fontCache[cacheKey] {
@@ -131,33 +131,46 @@ class StrokeTextView: UIView {
131
131
 
132
132
  /// Extracts trailing numeric weight
133
133
  /// "Montserrat-900" → ("Montserrat", 900)
134
- private func parseFontFamily(_ raw: String) -> (String, Int) {
135
- let parts = raw.split(separator: "-")
134
+ private func parseFontFamily(_ raw: String) -> (family: String, weight: Int, italic: Bool) {
135
+ let parts = raw.lowercased().split(separator: "-")
136
136
 
137
- if
138
- parts.count == 2,
139
- let weight = Int(parts[1])
140
- {
141
- return (String(parts[0]), weight)
137
+ var family = parts.first.map(String.init) ?? raw
138
+ var weight = 400
139
+ var italic = false
140
+
141
+ for part in parts.dropFirst() {
142
+ if part == "italic" {
143
+ italic = true
144
+ } else if let w = Int(part) {
145
+ weight = w
146
+ }
142
147
  }
143
148
 
144
- return (raw, 400)
149
+ return (family, weight, italic)
145
150
  }
146
151
 
152
+
147
153
  /// Maps numeric weight → iOS PostScript name
148
- private func resolveFontName(family: String, weight: Int) -> String {
154
+ private func resolveFontName(family: String, weight: Int, italic: Bool) -> String {
155
+ let base: String
149
156
  switch weight {
150
- case 100: return "\(family)-Thin"
151
- case 200: return "\(family)-ExtraLight"
152
- case 300: return "\(family)-Light"
153
- case 400: return "\(family)-Regular"
154
- case 500: return "\(family)-Medium"
155
- case 600: return "\(family)-SemiBold"
156
- case 700: return "\(family)-Bold"
157
- case 800: return "\(family)-ExtraBold"
158
- case 900: return "\(family)-Black"
159
- default: return "\(family)-Regular"
160
- }
157
+ case 100: base = "Thin"
158
+ case 200: base = "ExtraLight"
159
+ case 300: base = "Light"
160
+ case 400: base = "Regular"
161
+ case 500: base = "Medium"
162
+ case 600: base = "SemiBold"
163
+ case 700: base = "Bold"
164
+ case 800: base = "ExtraBold"
165
+ case 900: base = "Black"
166
+ default: base = "Regular"
167
+ }
168
+
169
+ if italic {
170
+ return "\(family)-Italic"
171
+ }
172
+
173
+ return "\(family)-\(base)Italic"
161
174
  }
162
175
 
163
176
  // MARK: - Color Helper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matiks/rn-stroke-text",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "rn-stroke-text",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",