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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eed940fe5d30af46cc24f8945771cfa2ae1b4ccafaf5574a343b0b361241c7fb
|
|
4
|
+
data.tar.gz: f072e8063bfd37d5f1547bec70e72fcc3cac33a2ae0fdfff5a85e035885a4ab2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a202d8da9feef0a2f2908780873dab759090e74fc6c5bd9c313e443f3e33659a871b2492122fd9b39b37528e4f5f05f30e4439b88e72646c370a0045a66b2ecc
|
|
7
|
+
data.tar.gz: 56d7264d3167c6367a753254a4815e42e3ed029cc1a39ae0d1d85f2baebf1fde14a0cf2a1b0008981a1196474632eafcc1c763cfac72ff8913e10dcb5096154f
|
data/lib/ea/fonts/metrics.rb
CHANGED
|
@@ -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
|
-
#
|
|
32
|
-
|
|
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
|
-
|
|
50
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
60
|
-
|
|
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
|
|
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
|
-
# (
|
|
56
|
-
#
|
|
57
|
-
|
|
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,
|
|
21
|
-
HeaderLineProvider::Name.display_name(classifier
|
|
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)
|
|
140
|
-
#
|
|
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
|
-
#
|
|
152
|
-
#
|
|
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
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.
|
|
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-
|
|
11
|
+
date: 2026-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|