bigcartel-theme-fonts 1.6.1 → 1.8.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9611be8ee6e83ed90a7624435cb7e8446b75c6a0d1f411ff404a0ff6cf8f81cf
4
- data.tar.gz: 39be88c91805a6862da48a8ad1057433753d8eefcc8dc74ee87216fb0bb2f2ae
3
+ metadata.gz: eda02a423d5ecebee3afd0f6ed53186cb01e1e8322073844ae90749f5ece7d73
4
+ data.tar.gz: c903ea89b42f88293a8d31f1f951fa4694586b63da3b44de22bd7c09235ef18f
5
5
  SHA512:
6
- metadata.gz: f0f7586ace0c21cbdb1ebf36aa56ac4345428646de93ace3412756ea69343bea5735ad204be347a6390bfe3d583f2d201a55bac8a9591bc3f0a6a690f2aae0fd
7
- data.tar.gz: 66726e854e1fa8dbd557c5d4bbd9bbb48ce2d805e50fc9e204c6ef677ef4d9e8b4056cb95f3a4908bc45f629d2886fcbd0ab11bdbdc5860155062e9b32b28eeb
6
+ metadata.gz: fdce3702961befcddfab26283c15993d791ac1a2f35c39ff5eec44f2909b01544b2f5022c1c2c45e14fb9e02a1ce39275696b7f562bdcdab3c17c293ac608869
7
+ data.tar.gz: 4f32a6003308f29b986e63d43fcc03cf1522176c730a2a6d98ac52714295485bf05c1fb05ceda4dde40c725f8f064f113553c28c21b22cd9032fa47ba38b4a7e
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'bigcartel-theme-fonts'
7
- spec.version = '1.6.1'
7
+ spec.version = '1.8.0'
8
8
  spec.authors = ['Big Cartel']
9
9
  spec.email = ['dev@bigcartel.com']
10
10
  spec.description = %q{A simple class for working with Big Cartel's supported theme fonts.}
@@ -66,6 +66,33 @@ class ThemeFont < Struct.new(:name, :family, :weights, :collection)
66
66
  google_fonts.empty? ? nil : google_font_url_for_fonts(google_fonts)
67
67
  end
68
68
 
69
+ def google_font_url_for_theme_array(fonts, settings, options = {})
70
+ defaults = {
71
+ include_protocol: false,
72
+ include_weights: true
73
+ }
74
+ opts = defaults.merge(options)
75
+
76
+ google_fonts = fonts.keys.map { |key| settings[key] }.compact
77
+ .map { |font_name| find_by_name(font_name) }
78
+ .compact
79
+ .select { |font| font.collection == 'google' }
80
+ .sort_by { |font| font.name }
81
+
82
+ return [] if google_fonts.empty?
83
+
84
+ base_url = opts[:include_protocol] ? "https://fonts.googleapis.com/css?family=" : "//fonts.googleapis.com/css?family="
85
+
86
+ google_fonts.map do |font|
87
+ font_string = if opts[:include_weights] && font.weights
88
+ "#{font.name}:#{font.weights}"
89
+ else
90
+ font.name
91
+ end
92
+ "#{base_url}#{font_string.gsub(' ', '+')}&display=swap"
93
+ end
94
+ end
95
+
69
96
  private
70
97
 
71
98
  def source
@@ -57,6 +57,10 @@ google:
57
57
  name: Abril Fatface
58
58
  family: '"Abril Fatface", cursive'
59
59
 
60
+ alumni_sans_pinstripe:
61
+ name: Alumni Sans Pinstripe
62
+ family: '"Alumni Sans Pinstripe", sans-serif'
63
+
60
64
  amaranth:
61
65
  name: Amaranth
62
66
  family: '"Amaranth", serif'
@@ -76,6 +80,15 @@ google:
76
80
  name: Asap
77
81
  family: '"Asap", sans-serif'
78
82
 
83
+ atkinson_hyperlegible_next:
84
+ name: Atkinson Hyperlegible Next
85
+ family: '"Atkinson Hyperlegible Next", sans-serif'
86
+ weights: "200,300,400,500,600,700,800"
87
+
88
+ atma:
89
+ name: Atma
90
+ family: 'Atma, sans-serif'
91
+
79
92
  bevan:
80
93
  name: Bevan
81
94
  family: '"Bevan", cursive'
@@ -103,6 +116,10 @@ google:
103
116
  family: '"Chivo", sans-serif'
104
117
  weights: "400,700"
105
118
 
119
+ coiny:
120
+ name: Coiny
121
+ family: '"Coiny", cursive'
122
+
106
123
  concert_one:
107
124
  name: Concert One
108
125
  family: '"Concert One", cursive'
@@ -120,6 +137,10 @@ google:
120
137
  name: Cutive Mono
121
138
  family: '"Cutive Mono", serif'
122
139
 
140
+ dekko:
141
+ name: Dekko
142
+ family: 'Dekko, sans-serif'
143
+
123
144
  delius:
124
145
  name: Delius
125
146
  family: '"Delius", cursive'
@@ -134,6 +155,11 @@ google:
134
155
  family: '"Dosis", sans-serif'
135
156
  weights: "400,700"
136
157
 
158
+ doto:
159
+ name: Doto
160
+ family: 'Doto, monospace'
161
+ weights: "300,400,500,700"
162
+
137
163
  enriqueta:
138
164
  name: Enriqueta
139
165
  family: '"Enriqueta", serif'
@@ -167,6 +193,11 @@ google:
167
193
  family: '"Glegoo", serif'
168
194
  weights: "400,700"
169
195
 
196
+ gorditas:
197
+ name: Gorditas
198
+ family: '"Gorditas", sans-serif'
199
+ weights: "400,700"
200
+
170
201
  goudy_bookletter_1911:
171
202
  name: Goudy Bookletter 1911
172
203
  family: '"Goudy Bookletter 1911", serif'
@@ -176,6 +207,10 @@ google:
176
207
  family: '"Hahmlet", serif'
177
208
  weights: "400,700"
178
209
 
210
+ honk:
211
+ name: Honk
212
+ family: 'Honk, sans-serif'
213
+
179
214
  inconsolata:
180
215
  name: Inconsolata
181
216
  family: '"Inconsolata", sans-serif'
@@ -194,12 +229,16 @@ google:
194
229
  karla:
195
230
  name: Karla
196
231
  family: '"Karla", sans-serif'
197
- weights: "400,700"
232
+ weights: "300,400,500,700"
233
+
234
+ langar:
235
+ name: Langar
236
+ family: '"Langar", cursive'
198
237
 
199
238
  lato:
200
239
  name: Lato
201
240
  family: '"Lato", sans-serif'
202
- weights: "400,700"
241
+ weights: "300,400,700"
203
242
 
204
243
  lekton:
205
244
  name: Lekton
@@ -224,7 +263,7 @@ google:
224
263
  lora:
225
264
  name: Lora
226
265
  family: '"Lora", serif'
227
- weights: "400,700"
266
+ weights: "400,500,700"
228
267
 
229
268
  marcellus:
230
269
  name: Marcellus
@@ -233,12 +272,12 @@ google:
233
272
  merriweather:
234
273
  name: Merriweather
235
274
  family: '"Merriweather", serif'
236
- weights: "400,700"
275
+ weights: "300,400,500,700"
237
276
 
238
277
  montserrat:
239
278
  name: Montserrat
240
279
  family: '"Montserrat", sans-serif'
241
- weights: "400,500,700"
280
+ weights: "300,400,500,700"
242
281
 
243
282
  muli:
244
283
  name: Muli
@@ -257,7 +296,7 @@ google:
257
296
  open_sans:
258
297
  name: Open Sans
259
298
  family: '"Open Sans", sans-serif'
260
- weights: "400,700"
299
+ weights: "300,400,500,700"
261
300
 
262
301
  overlock:
263
302
  name: Overlock
@@ -277,27 +316,46 @@ google:
277
316
  noto_sans:
278
317
  name: Noto Sans
279
318
  family: '"Noto Sans", sans-serif'
280
- weights: "400,700"
319
+ weights: "300,400,500,700"
281
320
 
282
321
  noto_serif:
283
322
  name: Noto Serif
284
323
  family: '"Noto Serif", serif'
285
- weights: "400,700"
324
+ weights: "300,400,500,700"
286
325
 
287
326
  nunito_sans:
288
327
  name: Nunito Sans
289
328
  family: '"Nunito Sans", sans-serif'
290
- weights: "400,700"
329
+ weights: "300,400,500,700"
330
+
331
+ parkinsans:
332
+ name: ParkinSans
333
+ family: '"ParkinSans", sans-serif'
334
+ weights: "300,400,500,700"
335
+
336
+ permanent_marker:
337
+ name: Permanent Marker
338
+ family: '"Permanent Marker", cursive'
291
339
 
292
340
  playfair_display:
293
341
  name: Playfair Display
294
342
  family: '"Playfair Display", serif'
343
+ weights: "400,500,700"
344
+
345
+ playfair_display_sc:
346
+ name: Playfair Display SC
347
+ family: '"Playfair Display SC", serif'
295
348
  weights: "400,700"
296
349
 
350
+ playwrite_hrvatska_lijeva:
351
+ name: Playwrite Hrvatska Lijeva
352
+ family: '"Playwrite Hrvatska Lijeva", cursive'
353
+ weights: "100,200,300,400"
354
+
297
355
  poppins:
298
356
  name: Poppins
299
357
  family: '"Poppins", sans-serif'
300
- weights: "400,600"
358
+ weights: "300,400,600"
301
359
 
302
360
  prata:
303
361
  name: Prata
@@ -325,53 +383,78 @@ google:
325
383
  quicksand:
326
384
  name: Quicksand
327
385
  family: '"Quicksand", sans-serif'
328
- weights: "400,700"
386
+ weights: "300,400,500,700"
329
387
 
330
388
  raleway:
331
389
  name: Raleway
332
390
  family: '"Raleway", sans-serif'
333
391
  weights: "400,700"
334
392
 
393
+ radio_canada:
394
+ name: Radio Canada
395
+ family: '"Radio Canada", sans-serif'
396
+ weights: "300,400,500,600,700"
397
+
398
+ reddit_sans:
399
+ name: Reddit Sans
400
+ family: '"Reddit Sans", sans-serif'
401
+ weights: "200,300,400,500,600,700,800"
402
+
335
403
  roboto:
336
404
  name: Roboto
337
405
  family: '"Roboto", sans-serif'
338
- weights: "400,700"
406
+ weights: "300,400,500,700"
339
407
 
340
408
  rokkitt:
341
409
  name: Rokkitt
342
410
  family: '"Rokkitt", serif'
343
- weights: "400,700"
411
+ weights: "300,400,500,700"
344
412
 
345
413
  signika:
346
414
  name: Signika
347
415
  family: '"Signika", sans-serif'
348
- weights: "400,700"
416
+ weights: "300,400,500,700"
417
+
418
+ source_code_pro:
419
+ name: Source Code Pro
420
+ family: '"Source Code Pro", monospace'
421
+ weights: "300,400,500,700"
349
422
 
350
423
  source_sans_pro:
351
424
  name: Source Sans Pro
352
425
  family: '"Source Sans Pro", sans-serif'
353
- weights: "400,700"
426
+ weights: "300,400,500,700"
354
427
 
355
428
  sora:
356
429
  name: Sora
357
430
  family: '"Sora", sans-serif'
358
- weights: "400,700"
431
+ weights: "300,400,500,700"
432
+
433
+ sour_gummy:
434
+ name: Sour Gummy
435
+ family: '"Sour Gummy", sans-serif'
436
+ weights: "200,300,400,500,700"
359
437
 
360
438
  spectral:
361
439
  name: Spectral
362
440
  family: '"Spectral", serif'
363
- weights: "400,700"
441
+ weights: "300,400,500,700"
364
442
 
365
443
  syne:
366
444
  name: Syne
367
445
  family: '"Syne", sans-serif'
368
- weights: "400,700"
446
+ weights: "400,500,600,700"
369
447
 
370
448
  titillium_web:
371
449
  name: Titillium Web
372
450
  family: '"Titillium Web", sans-serif'
373
- weights: "400,700"
451
+ weights: "400,600,700"
374
452
 
453
+ ubuntu:
454
+ name: Ubuntu
455
+ family: '"Ubuntu", sans-serif'
456
+ weights: "300,400,500,700"
457
+
375
458
  vampiro_one:
376
459
  name: Vampiro One
377
460
  family: '"Vampiro One", cursive'
@@ -383,4 +466,8 @@ google:
383
466
  work_sans:
384
467
  name: Work Sans
385
468
  family: '"Work Sans", sans-serif'
386
- weights: "400,600,700"
469
+ weights: "400,500,600,700"
470
+
471
+ yuji_mai:
472
+ name: Yuji Mai
473
+ family: '"Yuji Mai", cursive'
@@ -143,4 +143,83 @@ describe ThemeFont do
143
143
  ThemeFont.google_font_url_for_theme(fonts, settings).should be_nil
144
144
  end
145
145
  end
146
+
147
+ describe ".google_font_url_for_theme_array" do
148
+ let(:fonts) {{ :header_font => {}, :body_font => {}, :paragraph_font => {} }}
149
+
150
+ before(:each) do
151
+ stub(ThemeFont).all {[
152
+ ThemeFont.new('One Font', 'One Family', '400,700', 'google'),
153
+ ThemeFont.new('Two', 'Two Family', nil, 'default'),
154
+ ThemeFont.new('Three', 'Three Family', '300,600', 'google')
155
+ ]}
156
+ end
157
+
158
+ context "with default options" do
159
+ it "returns an array of URLs with weights and no protocol" do
160
+ settings = { :header_font => 'One Font', :body_font => 'Two', :paragraph_font => 'Three' }
161
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
162
+ result.should == [
163
+ "//fonts.googleapis.com/css?family=One+Font:400,700&display=swap",
164
+ "//fonts.googleapis.com/css?family=Three:300,600&display=swap"
165
+ ]
166
+ end
167
+
168
+ it "returns a single URL in array when only one Google font" do
169
+ settings = { :header_font => 'One Font', :body_font => 'Two' }
170
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
171
+ result.should == ["//fonts.googleapis.com/css?family=One+Font:400,700&display=swap"]
172
+ end
173
+
174
+ it "returns empty array when no Google fonts" do
175
+ settings = { :body_font => 'Two' }
176
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
177
+ result.should == []
178
+ end
179
+
180
+ it "deduplicates identical fonts" do
181
+ settings = { :header_font => 'One Font', :body_font => 'One Font' }
182
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
183
+ result.should == ["//fonts.googleapis.com/css?family=One+Font:400,700&display=swap"]
184
+ end
185
+ end
186
+
187
+ context "with include_protocol: true" do
188
+ it "returns URLs with https protocol" do
189
+ settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
190
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings, include_protocol: true)
191
+ result.should == [
192
+ "https://fonts.googleapis.com/css?family=One+Font:400,700&display=swap",
193
+ "https://fonts.googleapis.com/css?family=Three:300,600&display=swap"
194
+ ]
195
+ end
196
+ end
197
+
198
+ context "with include_weights: false" do
199
+ it "returns URLs without weights" do
200
+ settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
201
+ result = ThemeFont.google_font_url_for_theme_array(fonts, settings, include_weights: false)
202
+ result.should == [
203
+ "//fonts.googleapis.com/css?family=One+Font&display=swap",
204
+ "//fonts.googleapis.com/css?family=Three&display=swap"
205
+ ]
206
+ end
207
+ end
208
+
209
+ context "with both options customized" do
210
+ it "returns URLs with protocol and no weights" do
211
+ settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
212
+ result = ThemeFont.google_font_url_for_theme_array(
213
+ fonts,
214
+ settings,
215
+ include_protocol: true,
216
+ include_weights: false
217
+ )
218
+ result.should == [
219
+ "https://fonts.googleapis.com/css?family=One+Font&display=swap",
220
+ "https://fonts.googleapis.com/css?family=Three&display=swap"
221
+ ]
222
+ end
223
+ end
224
+ end
146
225
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigcartel-theme-fonts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Big Cartel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2025-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler