idml 0.8.2 → 0.8.3

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: 27df11baaefb3de6bfc6198404a9b3ad10b54b53de8a44cbe58658afdfdf4d4b
4
- data.tar.gz: 4274cf4d1869bab1457da1427d8ba96d27cf64ced0140174923b7492ee283dd8
3
+ metadata.gz: 0672dfcc5cf9d3116f38dd98904f2d2ba10a8373d04814d6fa936f0bffcf93c0
4
+ data.tar.gz: a3e3d982c061380e4201490366bac05c066bec85829b397378f933a6fea27d27
5
5
  SHA512:
6
- metadata.gz: '02936232be8a99effaf2f417d765281700c8f6b89004bab18e462d29d8b60b12259a715780fd0c2c1b68d41e5f82cd087b2933753551c72f3235d5cfbe3e3640'
7
- data.tar.gz: e92764f18f109a4ae66dabb4ebfcb3a991cd2926c22e7836de42e99d7c1b45e931cd0aa4f22678193564fb82bdbf24eeccd593405a1ada0322cda7f5ce54f32d
6
+ metadata.gz: fac32a9ec144ccf1970834c0724e1eb33667f140955f2b10fad3168823c55f64826b33ccb5b4aa781ecd53b6478515cac62809603d290706a4c433784b10b266
7
+ data.tar.gz: ed671dd23f413602e93506584114efb806a294d2970ccd0c17571b786dba9b64323dcfb03411cf8cd0571aaf9696eda7792e4eac8eee4197100797b37eed3c43
@@ -1,6 +1,10 @@
1
1
  # TODO PDF 113: Multi-column text frames (TextColumnCount, TextColumnGutter)
2
2
 
3
- ## Status: OPENgap identified in 2026-08-10 audit
3
+ ## Status: DONEengine_render detects TextColumnCount > 1 and
4
+ splits the frame into N column-specific Frame structs. Text flows
5
+ column 1 → column 2 → ... → chain to next frame via StoryChainController.
6
+ Each column acts as a mini-frame with the same height/insets but a
7
+ narrower width. TextColumnGutter honored as the gap between columns.
4
8
 
5
9
  ## Problem
6
10
 
@@ -158,7 +158,22 @@ module Idml
158
158
  # next frame in the chain.
159
159
  def self.engine_render(canvas, state, context, box, font)
160
160
  layout_frame = layout_frame(context.item, box)
161
- top_y = box[:y] + box[:height] - (layout_frame.inset_top || 0)
161
+ col_count = text_column_count(context)
162
+
163
+ if col_count && col_count > 1
164
+ engine_render_multi_column(canvas, state, context, layout_frame,
165
+ font, col_count)
166
+ else
167
+ engine_render_single_column(canvas, state, context, layout_frame,
168
+ font)
169
+ end
170
+ end
171
+ private_class_method :engine_render
172
+
173
+ def self.engine_render_single_column(canvas, state, context,
174
+ layout_frame, font)
175
+ top_y = layout_frame.y + layout_frame.height -
176
+ (layout_frame.inset_top || 0)
162
177
  bottom_limit = TextEngine::VerticalLayout.bottom_limit(layout_frame)
163
178
  cursor_y = vertical_justify_top(top_y, bottom_limit, state, context)
164
179
  char_cursor = state.char_cursor
@@ -174,7 +189,87 @@ module Idml
174
189
  consume_paragraphs(canvas, state, context, layout_frame, font,
175
190
  cursor_y, bottom_limit, char_cursor)
176
191
  end
177
- private_class_method :engine_render
192
+ private_class_method :engine_render_single_column
193
+
194
+ # Renders text across N columns within a single frame. Text
195
+ # flows column 1 → column 2 → ... → chain to next frame. Each
196
+ # column acts as a mini-frame with the same height but a
197
+ # narrower width. The chain state threads across columns
198
+ # transparently.
199
+ def self.engine_render_multi_column(canvas, state, context,
200
+ layout_frame, font, col_count)
201
+ gutter = text_column_gutter(context) || 0
202
+ col_frames = build_column_frames(layout_frame, col_count, gutter)
203
+
204
+ col_frames.each do |col_frame|
205
+ break if state_empty?(state)
206
+
207
+ render_column(canvas, state, context, col_frame, font)
208
+ end
209
+ end
210
+ private_class_method :engine_render_multi_column
211
+
212
+ def self.render_column(canvas, state, context, col_frame, font)
213
+ top_y = col_frame.y + col_frame.height - (col_frame.inset_top || 0)
214
+ bottom_limit = TextEngine::VerticalLayout.bottom_limit(col_frame)
215
+ cursor_y = top_y
216
+ char_cursor = state.char_cursor
217
+
218
+ if state.current_paragraph
219
+ cursor_y, char_cursor = resume_paragraph(
220
+ canvas, state, context, col_frame, font,
221
+ cursor_y, bottom_limit, char_cursor
222
+ )
223
+ return if state.current_paragraph
224
+ end
225
+
226
+ consume_paragraphs(canvas, state, context, col_frame, font,
227
+ cursor_y, bottom_limit, char_cursor)
228
+ end
229
+ private_class_method :render_column
230
+
231
+ def self.state_empty?(state)
232
+ state.paragraphs.empty? && state.current_paragraph.nil?
233
+ end
234
+ private_class_method :state_empty?
235
+
236
+ def self.text_column_count(context)
237
+ pref = context.item&.text_frame_preference&.first
238
+ pref&.text_column_count
239
+ end
240
+ private_class_method :text_column_count
241
+
242
+ def self.text_column_gutter(context)
243
+ pref = context.item&.text_frame_preference&.first
244
+ pref&.text_column_gutter
245
+ end
246
+ private_class_method :text_column_gutter
247
+
248
+ # Builds N column-specific Frame structs from the parent
249
+ # layout frame. Each column has the same y/height/insets but
250
+ # a different x and width so VerticalLayout's geometry math
251
+ # produces correct per-column results.
252
+ def self.build_column_frames(layout_frame, col_count, gutter)
253
+ inset_left = layout_frame.inset_left || 0
254
+ inset_right = layout_frame.inset_right || 0
255
+ content_width = layout_frame.width - inset_left - inset_right
256
+ col_width = (content_width - ((col_count - 1) * gutter)) / col_count
257
+
258
+ Array.new(col_count) do |i|
259
+ col_left = layout_frame.x + inset_left + (i * (col_width + gutter))
260
+ TextEngine::Frame.new(
261
+ x: col_left - inset_left,
262
+ y: layout_frame.y,
263
+ width: col_width + inset_left + inset_right,
264
+ height: layout_frame.height,
265
+ inset_top: layout_frame.inset_top,
266
+ inset_bottom: layout_frame.inset_bottom,
267
+ inset_left: inset_left,
268
+ inset_right: inset_right,
269
+ )
270
+ end
271
+ end
272
+ private_class_method :build_column_frames
178
273
 
179
274
  # Computes the starting cursor_y for vertical justification.
180
275
  # IDML's TextFramePreference.VerticalJustification can be:
data/lib/idml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Idml
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-13 00:00:00.000000000 Z
11
+ date: 2026-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal