@matiks/rn-stroke-text 0.1.0 → 0.1.2

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,54 @@ 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 {
149
- 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"
154
+ private func resolveFontName(family: String, weight: Int, italic: Bool) -> String {
155
+ let singleFaceFonts: Set<String> = [
156
+ "bebasneue",
157
+ "bebas neue"
158
+ ]
159
+
160
+ if singleFaceFonts.contains(family.lowercased()) {
161
+ return "\(family)-Regular"
160
162
  }
163
+ let base: String
164
+ switch weight {
165
+ case 100: base = "Thin"
166
+ case 200: base = "ExtraLight"
167
+ case 300: base = "Light"
168
+ case 400: base = "Regular"
169
+ case 500: base = "Medium"
170
+ case 600: base = "SemiBold"
171
+ case 700: base = "Bold"
172
+ case 800: base = "ExtraBold"
173
+ case 900: base = "Black"
174
+ default: base = "Regular"
175
+ }
176
+
177
+ if italic {
178
+ return "\(family)-Italic"
179
+ }
180
+
181
+ return "\(family)-\(base)Italic"
161
182
  }
162
183
 
163
184
  // 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.2",
4
4
  "description": "rn-stroke-text",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",