ea 0.6.16 → 0.6.17

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: a8c5868e2f18d7a28583d8e862f15f7f3f46703012ba58914d273a12f390b357
4
- data.tar.gz: 61024b7e2ddb30066b9daafcad0ba9b324451e70d2344db82ab2106fc16e53e5
3
+ metadata.gz: 23adcefba5c783bfccc47f9cbb8d8cdf327431629857a4a7b46b67bbef529b21
4
+ data.tar.gz: ad21177acd96ceaa4e4c0e30cf47073e6ae333639a8673ebc9771ee6ddd8d2d3
5
5
  SHA512:
6
- metadata.gz: 76574a19dbc1a01c1add8adca00fad58dc18b436ba28869564e5bab050609fc701b5cc0874d6693d9553e670120bd19582d91477a41981e7a2ed8812dd2b45a5
7
- data.tar.gz: cfe049c8be3f068b1dedc0f65dff2fb2b856b0eee9eafa63efd2fdd088ab0a71bd7894ce86693cb06d574baae6c686a7aa5afca2f507f1c60ff0e8e8d36e6b5c
6
+ metadata.gz: 6a8b2a05a0ab5dd288494d62b24f7911a40e823db514a20a6ed6ee9897c2290b997b3b85d5580d6ba4bad516ed8da96f4b44f4eb69a69b064b38c50e8193faea
7
+ data.tar.gz: f66f47990a91b56ee9d25c4e714355f4bbe603fd6f77418e8bfb022b7b71e0dff4d1ebb712a1404493fbb6a1d2a21f452f789999b38bdb098081e0216fbcf6ac
@@ -99,6 +99,44 @@ module Ea
99
99
  def cp_key(ch)
100
100
  format("U+%04X", ch.ord)
101
101
  end
102
+
103
+ # Resolves the four Carlito style TTFs through the fontist gem
104
+ # (system index + downloaded formulas). Empty when fontist is
105
+ # unavailable or Carlito is not installed.
106
+ def carlito_font_files
107
+ require "fontist"
108
+ styles = %w[Regular Bold Italic BoldItalic]
109
+ Fontist::SystemFont.find("Carlito").filter_map do |path|
110
+ next unless path.downcase.end_with?(".ttf")
111
+
112
+ style = File.basename(path, ".ttf").delete_prefix("Carlito-")
113
+ match = styles.find { |s| s.casecmp?(style) }
114
+ next unless match
115
+
116
+ [match, path]
117
+ end.to_h
118
+ rescue LoadError, StandardError => e
119
+ raise if ENV['EA_FONTS_DEBUG']
120
+
121
+ {}
122
+ end
123
+
124
+ # Reads advance widths from a TTF via the fontian gem (used by
125
+ # `rake fonts:validate` to re-derive the tables).
126
+ def advances_from_font(path)
127
+ require "fontisan"
128
+ font = Fontisan::FontLoader.load(path)
129
+ hmtx = font.table("hmtx")
130
+ hmtx.parse_with_context(font.table("hhea").number_of_h_metrics,
131
+ font.table("maxp").num_glyphs)
132
+ upem = font.table("head").units_per_em
133
+ cmap = font.table("cmap").unicode_mappings
134
+ cmap.each_with_object({}) do |(cp, gid), out|
135
+ adv = hmtx.metric_for(gid)[:advance_width]
136
+ out[cp] = (adv.to_f / upem).round(4) if adv
137
+ end
138
+ end
139
+
102
140
  end
103
141
  end
104
142
  end
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.16"
7
+ VERSION = "0.6.17"
8
8
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ea/fonts/metrics"
4
+
5
+ namespace :fonts do
6
+ desc "Validate the shipped Carlito metrics against Fontist-resolved TTFs"
7
+ task :validate do
8
+ files = Ea::Fonts::Metrics.carlito_font_files
9
+ abort "Carlito not resolvable via Fontist — install it first" if files.empty?
10
+
11
+ shipped = JSON.parse(File.read(Ea::Fonts::Metrics::DATA_PATH))["advance"]
12
+ style_key = { "regular" => "regular", "bold" => "bold",
13
+ "italic" => "italic", "bold_italic" => "bold_italic",
14
+ "bolditalic" => "bold_italic" }
15
+ drift = []
16
+
17
+ files.each do |style, path|
18
+ table = shipped[style_key[style.downcase]]
19
+ actual = Ea::Fonts::Metrics.advances_from_font(path)
20
+ missing = actual.keys.count { |cp| table[format("U+%04X", cp)].nil? }
21
+ puts " (shipped table lacks #{missing} of #{actual.size} codepoints — skipped)"
22
+ actual.each do |cp, adv|
23
+ key = format("U+%04X", cp)
24
+ ours = table[key]
25
+ next if ours.nil? || (ours - adv).abs <= 0.0005
26
+
27
+ drift << format("%s %s: json=%s font=%s", style, key, ours, adv)
28
+ end
29
+ puts "#{style}: #{path} — #{actual.size} codepoints checked"
30
+ end
31
+
32
+ if drift.empty?
33
+ puts "carlito_metrics.json matches the Fontist-resolved fonts."
34
+ else
35
+ puts "DRIFT (#{drift.size} entries):"
36
+ drift.first(20).each { |line| puts " #{line}" }
37
+ exit 1
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.16
4
+ version: 0.6.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -999,6 +999,7 @@ files:
999
999
  - lib/ea/xmi/lookup_service.rb
1000
1000
  - lib/ea/xmi/parser.rb
1001
1001
  - lib/ea/xml_escape.rb
1002
+ - lib/tasks/fonts.rake
1002
1003
  - lib/tasks/svg_bench.rake
1003
1004
  - reference-docs/enterprise-architect-appearance-dialogs/appearance-1-diagram-1-themes-list.png
1004
1005
  - reference-docs/enterprise-architect-appearance-dialogs/appearance-1-diagram-1-themes.png