frameit 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/frameit/editor.rb +58 -15
- data/lib/frameit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34bc47b3efb69420fd5270e798ba713a9b948af4
|
4
|
+
data.tar.gz: 8158ee167427955839b53705c4787102cd104547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0279c2c77228a3e5bae1bbe84c05338864efca6eb13e63c29eae7b50c0f6d7d20b1b873045c7b9ea557fe0fea2451803aba2873b893eed0bad37f8366044498
|
7
|
+
data.tar.gz: 9bfde1c00507c0521a440a464d23b9d4d73bebc36525829f65b48edba521ddff4e46f039d4ba8ae6ce1e45d0a62e05c9a20af93fb534d9e8428a638a299a52f8
|
data/README.md
CHANGED
@@ -185,7 +185,7 @@ To define the title and optionally the keyword, put two `.strings` files into th
|
|
185
185
|
|
186
186
|
The `keyword.strings` and `title.strings` are standard `.strings` file you already use for your iOS apps, making it easy to use your existing translation service to get localized titles.
|
187
187
|
|
188
|
-
**Note:** These `.strings` files **MUST** be utf-16 encoded. If you are having trouble see [issue #49](https://github.com/fastlane/frameit/issues/49)
|
188
|
+
**Note:** These `.strings` files **MUST** be utf-16 encoded (UTF-16 LE with BOM). They also must begin with an empty line. If you are having trouble see [issue #49](https://github.com/fastlane/frameit/issues/49)
|
189
189
|
|
190
190
|
|
191
191
|
#### Uploading screenshots to iTC
|
data/lib/frameit/editor.rb
CHANGED
@@ -5,6 +5,8 @@ module Frameit
|
|
5
5
|
attr_accessor :image # the current image used for editing
|
6
6
|
attr_accessor :top_space_above_device
|
7
7
|
|
8
|
+
FONT_SIZE_REFERENCE_WIDTH = 640.0 # The size of device a, e.g. "12px" is defined for
|
9
|
+
|
8
10
|
def frame!(screenshot)
|
9
11
|
self.screenshot = screenshot
|
10
12
|
prepare_image
|
@@ -172,18 +174,22 @@ module Frameit
|
|
172
174
|
sum_width = title.width
|
173
175
|
sum_width += keyword.width + keyword_padding if keyword
|
174
176
|
|
175
|
-
#
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
177
|
+
# Only resize if we haven't specified a custom font size
|
178
|
+
font_size = font_size('title')
|
179
|
+
if font_size.nil?
|
180
|
+
# Resize the 2 labels if necessary
|
181
|
+
smaller = 1.0 # default
|
182
|
+
ratio = (sum_width + keyword_padding * 2) / image.width.to_f
|
183
|
+
if ratio > 1.0
|
184
|
+
# too large - resizing now
|
185
|
+
smaller = (1.0 / ratio)
|
186
|
+
|
187
|
+
UI.message "Text for image #{self.screenshot.path} is quite long, reducing font size by #{(ratio - 1.0).round(2)}" if $verbose
|
188
|
+
|
189
|
+
title.resize "#{(smaller * title.width).round}x"
|
190
|
+
keyword.resize "#{(smaller * keyword.width).round}x" if keyword
|
191
|
+
sum_width *= smaller
|
192
|
+
end
|
187
193
|
end
|
188
194
|
|
189
195
|
vertical_padding = vertical_frame_padding
|
@@ -210,13 +216,13 @@ module Frameit
|
|
210
216
|
background
|
211
217
|
end
|
212
218
|
|
213
|
-
def
|
219
|
+
def derived_font_size
|
214
220
|
[@image.width / 10.0].max.round
|
215
221
|
end
|
216
222
|
|
217
223
|
# The space between the keyword and the title
|
218
224
|
def keyword_padding
|
219
|
-
(
|
225
|
+
(derived_font_size / 2.0).round
|
220
226
|
end
|
221
227
|
|
222
228
|
# This will build 2 individual images with the title, which will then be added to the real image
|
@@ -234,6 +240,7 @@ module Frameit
|
|
234
240
|
end
|
235
241
|
|
236
242
|
current_font = font(key)
|
243
|
+
custom_font_size = font_size(key)
|
237
244
|
text = fetch_text(key)
|
238
245
|
UI.message "Using #{current_font} as font the #{key} of #{screenshot.path}" if $verbose and current_font
|
239
246
|
UI.message "Adding text '#{text}'" if $verbose
|
@@ -244,7 +251,12 @@ module Frameit
|
|
244
251
|
title_image.combine_options do |i|
|
245
252
|
i.font current_font if current_font
|
246
253
|
i.gravity "Center"
|
247
|
-
|
254
|
+
if custom_font_size
|
255
|
+
i.pointsize custom_font_size
|
256
|
+
UI.message "Using custom font size #{custom_font_size}" if $verbose
|
257
|
+
else
|
258
|
+
i.pointsize derived_font_size
|
259
|
+
end
|
248
260
|
i.draw "text 0,0 '#{text}'"
|
249
261
|
i.fill fetch_config[key.to_s]['color']
|
250
262
|
end
|
@@ -316,5 +328,36 @@ module Frameit
|
|
316
328
|
UI.message "No custom font specified for #{screenshot}, using the default one" if $verbose
|
317
329
|
return nil
|
318
330
|
end
|
331
|
+
|
332
|
+
def scaled_font_size(font_size)
|
333
|
+
font_ratio = font_size / FONT_SIZE_REFERENCE_WIDTH
|
334
|
+
return (font_ratio * screenshot.size[0].to_f).round
|
335
|
+
end
|
336
|
+
|
337
|
+
# The fontSize we want to use
|
338
|
+
def font_size(key)
|
339
|
+
single_font_size = fetch_config[key.to_s]['fontSize']
|
340
|
+
return single_font_size if single_font_size
|
341
|
+
|
342
|
+
fonts = fetch_config[key.to_s]['fonts']
|
343
|
+
if fonts
|
344
|
+
fonts.each do |font|
|
345
|
+
if font['supported']
|
346
|
+
font['supported'].each do |language|
|
347
|
+
if screenshot.path.include? language
|
348
|
+
return scaled_font_size(font["fontSize"])
|
349
|
+
end
|
350
|
+
end
|
351
|
+
else
|
352
|
+
# No `supported` array, this will always be true
|
353
|
+
UI.message "Found a fontSize with no list of supported languages, using this now" if $verbose
|
354
|
+
return scaled_font_size(font["fontSize"])
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
UI.message "No custom fontSize specified for #{screenshot}, using the default one" if $verbose
|
360
|
+
return nil
|
361
|
+
end
|
319
362
|
end
|
320
363
|
end
|
data/lib/frameit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frameit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|