idml 0.4.9 → 0.5.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: bf684927e9227982c1773b71a6697b40ed9d93263eb1a272e413008ba6d2009b
4
- data.tar.gz: 4fbd6e8ab4df4ba8281fb5353df9474348fe77b021703118c63c3f5d5a9f5ca1
3
+ metadata.gz: '09c5f631233897e7f1e18519b1031c1c87092a1e3ddffdc353bf2e121c47b15b'
4
+ data.tar.gz: 8c0b965da67d83e30f3b7002be6bbabe1dffec7d1a3557979fe4cdfbce99dd54
5
5
  SHA512:
6
- metadata.gz: 61d12e84a29ccefd212d6f09221eee09045b8ae18c8736bab98fea27cfdc0073151e8ffa53eadf18508af7bf104ff44e171b98f2fdd8e6d96019191792d594c9
7
- data.tar.gz: 26f5541332df26f45f169da739c7c47b13f483a1c42c690c85867e8f3151522b0440d41bc7b502e680ff79ab00ac09ad791f9308cf9a0d7d16acb3a5ae87567c
6
+ metadata.gz: 7675a8a5b799b1a2b420f74b26faec4f6630b55cbf7ca831201085f99947d9ee31d1380fe5a12039427e643988ec84228738fc92dd9d925423aa36822815a774
7
+ data.tar.gz: 266b6c589b715d727460eba5064dde878f104b079e3da2ae7a0b31c911492cd88d75d18946ff3536d358c12359bf4b4069592dba7ac0c4b5eb42a1dbebde0544
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- idml (0.4.9)
4
+ idml (0.5.0)
5
5
  bigdecimal
6
6
  lutaml-model (~> 0.8.18)
7
7
  pdfrb
@@ -183,7 +183,7 @@ CHECKSUMS
183
183
  ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
184
184
  ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
185
185
  ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
186
- idml (0.4.9)
186
+ idml (0.5.0)
187
187
  json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
188
188
  language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
189
189
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
@@ -1,15 +1,22 @@
1
1
  # TODO PDF 89: Deep audit — idml-generated PDF vs InDesign PDF
2
2
 
3
- ## Status: COMPLETE (audit); structural differences documented
3
+ ## Status: PARTIAL — font selection fixed; image bloat remains
4
4
 
5
5
  ## TL;DR
6
6
 
7
- **No** — the generated PDF is not byte-identical to the InDesign
8
- output. InDesign produces ~100KB, the idml render produces ~2.2MB
9
- (22x larger). The visual content is structurally similar but
10
- rendered through a different font pipeline, font subsetting
11
- strategy, image embedding path, and color management. Below is a
12
- side-by-side audit.
7
+ **No** — the generated PDF is still not identical to InDesign's
8
+ output, but the **font selection gap is closed** as of v0.5.0.
9
+
10
+ After the font fix (FontSetup now prefers Regular weight over
11
+ first-in-family):
12
+ - Font: `MinionPro-Regular` (matches InDesign) — was
13
+ `MinionPro-BoldCn`.
14
+ - File size: still ~2.2MB (the image bloat remains).
15
+
16
+ The remaining 88% of the file size is the embedded GenAI JPEG
17
+ (1,937,556 bytes embedded raw via DCTDecode). InDesign downsamples
18
+ to ~12KB. Closing this gap requires pure-Ruby JPEG decode + resize
19
+ + re-encode (TODO 91).
13
20
 
14
21
  ## File-level comparison (`sample-with-table-more`)
15
22
 
@@ -16,6 +16,12 @@ module Idml
16
16
  class FontSetup
17
17
  DEFAULT_FONT = Render::DEFAULT_FONT
18
18
 
19
+ # Style names treated as the "Regular" default for body text,
20
+ # in priority order. Used to pick the right font from a family
21
+ # when no per-run `AppliedFont` is specified — matches
22
+ # InDesign's default-text-font behavior.
23
+ REGULAR_STYLE_NAMES = %w[Regular Normal Book Roman].freeze
24
+
19
25
  def initialize(package:, font_search_paths: nil)
20
26
  @package = package
21
27
  @font_search_paths = font_search_paths
@@ -57,6 +63,10 @@ module Idml
57
63
  end
58
64
 
59
65
  def find_font_file(family)
66
+ regular = find_regular_font(family)
67
+ return regular if regular
68
+
69
+ # Fall back to the first non-missing font.
60
70
  family.font.each do |font|
61
71
  next unless font.post_script_name
62
72
  next if font.status == "Missing"
@@ -67,6 +77,28 @@ module Idml
67
77
  nil
68
78
  end
69
79
 
80
+ # Pick the first "Regular" / "Normal" / "Book" / "Roman" font
81
+ # in the family. This matches InDesign's default body-text
82
+ # behavior, which prefers Regular weight over the first font
83
+ # listed in the family.
84
+ def find_regular_font(family)
85
+ family.font.each do |font|
86
+ next unless font.post_script_name
87
+ next if font.status == "Missing"
88
+ next unless regular_style?(font.font_style_name)
89
+
90
+ path = resolver.find_by_ps_name(font.post_script_name)
91
+ return path if path
92
+ end
93
+ nil
94
+ end
95
+
96
+ def regular_style?(style_name)
97
+ return false unless style_name
98
+
99
+ REGULAR_STYLE_NAMES.any?(style_name)
100
+ end
101
+
70
102
  def resolver
71
103
  @resolver ||= Pdfrb::FontResolver.new(
72
104
  search_paths: @font_search_paths || Pdfrb::FontResolver::DEFAULT_SEARCH_PATHS,
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.4.9"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose