ea 0.6.9 → 0.6.10

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: a7d2aed2a05d86d6a3d22563b4b00075aefd9434ca1f35688266f4642412f084
4
- data.tar.gz: fc75e5261165acd1e12b7d9254cbff578067ab2c4f3519b591f09ab6dd7f065e
3
+ metadata.gz: eed940fe5d30af46cc24f8945771cfa2ae1b4ccafaf5574a343b0b361241c7fb
4
+ data.tar.gz: f072e8063bfd37d5f1547bec70e72fcc3cac33a2ae0fdfff5a85e035885a4ab2
5
5
  SHA512:
6
- metadata.gz: 57a363b3985d2f3035d71fcb955046a6ec15f6fce0e0984cbf98c948e6c8bfccc33f0a1d5e6c4135c705e255f8976a9e5f5592172a0c360655ffc899d1b7cd85
7
- data.tar.gz: 0dbc829885ba08e75287a92f09ec6a5ba67d68a253a4afbb7f7b3f3b79276788d54eff61b9fcba4dd024321b210a78fb2e73b1023f89749962456868e918c01d
6
+ metadata.gz: a202d8da9feef0a2f2908780873dab759090e74fc6c5bd9c313e443f3e33659a871b2492122fd9b39b37528e4f5f05f30e4439b88e72646c370a0045a66b2ecc
7
+ data.tar.gz: 56d7264d3167c6367a753254a4815e42e3ed029cc1a39ae0d1d85f2baebf1fde14a0cf2a1b0008981a1196474632eafcc1c763cfac72ff8913e10dcb5096154f
@@ -28,8 +28,10 @@ module Ea
28
28
  DEFAULT_ADVANCE = 0.25
29
29
 
30
30
  # Carlito has no CJK glyphs; EA's renderer falls back to a
31
- # full-width CJK font (~1em per glyph) for those ranges.
32
- CJK_ADVANCE = 1.0
31
+ # proportional CJK font whose advances measure ~0.709em at the
32
+ # NOMINAL size (not scaled by the per-style factors) — fitted
33
+ # from EA-published textLengths (52 mixed-script samples).
34
+ CJK_ADVANCE = 0.709
33
35
  CJK_RANGES = [
34
36
  (0x3000..0x303F), # CJK punctuation
35
37
  (0x3040..0x309F), # Hiragana
@@ -46,19 +48,28 @@ module Ea
46
48
  return nil unless supported_family?(family)
47
49
  return nil if text.nil? || text.empty?
48
50
 
49
- em = advance_em(text, weight: weight, style: style)
50
- (em * size_pt.to_f * factor_for(weight, style)).round(3)
51
+ latin, cjk_count = split_advance(text, weight: weight, style: style)
52
+ (latin * size_pt.to_f * factor_for(weight, style) +
53
+ cjk_count * CJK_ADVANCE * size_pt.to_f).round(3)
51
54
  end
52
55
 
53
56
  def supported_family?(family)
54
57
  SUPPORTED_FAMILIES.include?(family.to_s)
55
58
  end
56
59
 
57
- def advance_em(text, weight: nil, style: nil)
60
+ # Returns [latin_em (factor-scaled later), cjk_glyph_count].
61
+ def split_advance(text, weight: nil, style: nil)
58
62
  table = table_for(weight, style)
59
- text.each_char.sum do |ch|
60
- table[cp_key(ch)] || (cjk?(ch.ord) ? CJK_ADVANCE : DEFAULT_ADVANCE)
63
+ latin = 0.0
64
+ cjk = 0
65
+ text.each_char.each do |ch|
66
+ if cjk?(ch.ord)
67
+ cjk += 1
68
+ else
69
+ latin += table[cp_key(ch)] || DEFAULT_ADVANCE
70
+ end
61
71
  end
72
+ [latin, cjk]
62
73
  end
63
74
 
64
75
  def cjk?(cp)
@@ -33,8 +33,7 @@ module Ea
33
33
  end
34
34
 
35
35
  def self.wrapped_name_lines(classifier, context, weight)
36
- name = display_name(classifier, context.diagram_package_id,
37
- context.visually_nested)
36
+ name = display_name(classifier)
38
37
  unless context.bounds_width && name.include?("::") &&
39
38
  name_exceeds_bounds?(name, context.bounds_width,
40
39
  context.font_size || 9)
@@ -51,12 +50,10 @@ module Ea
51
50
  (bounds_width - QUALIFIED_WRAP_PADDING)
52
51
  end
53
52
 
54
- # EA renders the plain classifier name in element headers
55
- # (element ownership qualification is a display option the
56
- # corpus diagrams leave off - verified against EA-published
57
- # reference SVGs).
58
- def self.display_name(classifier, _diagram_package_id = nil,
59
- _visually_nested = false)
53
+ # EA renders the plain classifier name in element headers.
54
+ # (Some ISO-corpus diagrams show "Pkg::Name" headers — the
55
+ # storage of that flag is not in the QEA; render plain.)
56
+ def self.display_name(classifier, *_)
60
57
  classifier.name.to_s
61
58
  end
62
59
  end
@@ -17,8 +17,8 @@ module Ea
17
17
 
18
18
  # Delegate to the Name provider so historical callers and
19
19
  # specs that test display_name keep working.
20
- def display_name(classifier, diagram_package_id = nil, *_)
21
- HeaderLineProvider::Name.display_name(classifier, diagram_package_id)
20
+ def display_name(classifier, *_)
21
+ HeaderLineProvider::Name.display_name(classifier)
22
22
  end
23
23
  end
24
24
  end
@@ -136,21 +136,25 @@ module Ea
136
136
  end
137
137
 
138
138
  # EA centers the title over the ITEM BLOCK (icon left edge
139
- # to the right end of the widest label), not the container
140
- # box - verified against EA-published reference SVGs.
139
+ # to the right end of the widest label) by its INTEGER
140
+ # textLength and floors x - verified against EA-published
141
+ # reference SVGs.
141
142
  def title_x
142
143
  icon_left = bounds.x + ICON_X_OFFSET
143
144
  block_right = icon_left + ICON_LABEL_GAP +
144
145
  widest_item_label_width
145
146
  block_left = icon_left
146
- block_left + (block_right - block_left - title_text_width) / 2.0
147
+ (block_left + (block_right - block_left - title_text_width.round) / 2.0).floor
147
148
  end
148
149
 
149
150
  CJK_RANGE = /[\u3000-\u9fff\uff00-\uffef]/
150
151
 
151
- # CJK glyphs run ~0.82em, others ~0.612em (regressed from
152
- # EA's own textLength values on mixed-script labels).
152
+ # Real font metrics when available; legacy per-char
153
+ # estimate otherwise (families without metric tables).
153
154
  def estimated_width(text, size)
155
+ measured = Ea::Fonts::Metrics.text_length(text, size, family: family)
156
+ return measured if measured
157
+
154
158
  text.to_s.each_char.sum do |ch|
155
159
  ch.match?(CJK_RANGE) ? size * 0.70 : size * 0.612
156
160
  end
@@ -181,8 +185,7 @@ module Ea
181
185
  TextRenderer.new(
182
186
  content: content.to_s, x: tx, y: ty,
183
187
  family: family, size: size, size_unit: "pt",
184
- weight: weight, fill: label_fill,
185
- text_length: (content.to_s.length * size * 0.65).round
188
+ weight: weight, fill: label_fill
186
189
  ).to_svg
187
190
  end
188
191
 
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.9"
7
+ VERSION = "0.6.10"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-28 00:00:00.000000000 Z
11
+ date: 2026-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model