mork 0.18.0 → 0.18.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46d443ec81a0831a6048e8a7a7b6a16eb35d6a7d9a1a0a13287427d44d7e9b77
4
- data.tar.gz: 15788c1658c1c07dce5fc1e0c66a345afb1a15a28a3b85bca787437a6500b13e
3
+ metadata.gz: 9c871eb798a14173c833892d6cb6030e266158239058f9ef0fbb2ff359c1073f
4
+ data.tar.gz: 8e2ac94ee3e806455d617f959459eebe6964521c9711064e5f0c86facf9fda8f
5
5
  SHA512:
6
- metadata.gz: cd65ed345abadaad63c283965c49c9af3c5b7b57564a8f0cabae07bc7d5bc32e8c167156c5703ad03b1b2ea4ff6bb0b363f976258589b2d37639cc3a39e4c1cc
7
- data.tar.gz: bf1ae484be720c8a60f4e4f2cb540d5f9e235f89fd772089cb5bd5968762d54a3a1a1e4fb99725c29653633dbbec1732e3d8da953009fc583e4d734e86665a76
6
+ metadata.gz: 464bb64cfe62e30bba0037b154d527a00d165b1bd71b4ffa4534bc28cace42fd86aa8455d927d6d660c218d25be92cca4292f60aa66b787af8ce9ed7bea82ba9
7
+ data.tar.gz: 37ab32c16c165c6c120a8addca74a6bafbe44a02d494ab80968a499dd5d44bad1b6402031c3ff8703a94b8ffbcdd8fc6afd093369b9535883aa49aa2ff2dd0e3
@@ -8,7 +8,8 @@ module Mork
8
8
  class SheetPDF < Prawn::Document
9
9
  DEFAULT_FONT_FAMILY = 'Open Sans'
10
10
  DEFAULT_FONT_PATH = File.expand_path('fonts/OpenSans-Regular.ttf', __dir__)
11
- private_constant :DEFAULT_FONT_FAMILY, :DEFAULT_FONT_PATH
11
+ ITEM_TEXT_RISE_EM = 0.177
12
+ private_constant :DEFAULT_FONT_FAMILY, :DEFAULT_FONT_PATH, :ITEM_TEXT_RISE_EM
12
13
 
13
14
  include Extensions
14
15
  def initialize(content, layout=nil, duplex=false)
@@ -142,7 +143,7 @@ module Mork
142
143
  def question_numbers
143
144
  ch_len.first.length.times do |i|
144
145
  text_box "#{i+1}",
145
- at: @grip.qnum_xy(i),
146
+ at: item_text_at(@grip.qnum_xy(i)),
146
147
  width: @grip.qnum_width,
147
148
  height: @grip.height_of_cell,
148
149
  align: :right,
@@ -176,7 +177,7 @@ module Mork
176
177
  @grip.width_of_uid,
177
178
  @grip.height_of_uid,
178
179
  @grip.uround
179
- text_box i, at: [offx, 0],
180
+ text_box i, at: item_text_at([offx, 0]),
180
181
  width: @grip.width_of_uid,
181
182
  height: @grip.height_of_uid,
182
183
  align: :center,
@@ -201,13 +202,20 @@ module Mork
201
202
  @grip.height_of_cell,
202
203
  @grip.cround
203
204
  text_box l,
204
- at: [x,0],
205
+ at: item_text_at([x, 0]),
205
206
  width: @grip.width_of_cell,
206
207
  height: @grip.height_of_cell,
207
208
  align: :center,
208
209
  valign: :center
209
210
  end
210
211
 
212
+ # Prawn vertically centers the font's full ascender box. Open Sans has a
213
+ # tall ascender relative to its visible capitals and digits, so raise only
214
+ # item text while leaving the OMR geometry unchanged.
215
+ def item_text_at(position)
216
+ [position[0], position[1] + @grip.item_font_size * ITEM_TEXT_RISE_EM]
217
+ end
218
+
211
219
  def equal_choice_number?
212
220
  return @equal_choice_number unless @equal_choice_number.nil?
213
221
 
data/lib/mork/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mork
2
- VERSION = '0.18.0'
2
+ VERSION = '0.18.1'
3
3
  end
@@ -68,6 +68,18 @@ module Mork
68
68
  expect(bytes).to include 'OpenSans-Regular'
69
69
  end
70
70
 
71
+ it 'raises item labels without changing their OMR coordinates' do
72
+ pdf = SheetPDF.new({})
73
+ grid = pdf.instance_variable_get('@grip')
74
+ cell_position = grid.item_xy(0)
75
+
76
+ text_position = pdf.send(:item_text_at, cell_position)
77
+
78
+ expect(text_position[0]).to eq cell_position[0]
79
+ expect(text_position[1] - cell_position[1]).to be_within(0.001).of(1.593)
80
+ expect(grid.item_xy(0)).to eq cell_position
81
+ end
82
+
71
83
  it 'creates a minimal PDF sheet' do
72
84
  s = SheetPDF.new({})
73
85
  s.save dest 'minimal'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Bertini