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 +4 -4
- data/Gemfile.lock +2 -2
- data/TODO.pdf/89-deep-audit-idml-vs-indesign.md +14 -7
- data/lib/idml/render/font_setup.rb +32 -0
- data/lib/idml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09c5f631233897e7f1e18519b1031c1c87092a1e3ddffdc353bf2e121c47b15b'
|
|
4
|
+
data.tar.gz: 8c0b965da67d83e30f3b7002be6bbabe1dffec7d1a3557979fe4cdfbce99dd54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
+
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.
|
|
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:
|
|
3
|
+
## Status: PARTIAL — font selection fixed; image bloat remains
|
|
4
4
|
|
|
5
5
|
## TL;DR
|
|
6
6
|
|
|
7
|
-
**No** — the generated PDF is not
|
|
8
|
-
output
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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