asciidoctor-ldl 0.1.1 → 0.1.2

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: 719e75b23cf670612dd2d6248301fdb0e9cf5f4ed4de0a5a8cd4f4f09c05d07d
4
- data.tar.gz: 4796262bbe18bf6029bff035d8552fdb4436e3990bd6bb571dcf7974bef27293
3
+ metadata.gz: 20802d92a457bdb984de019c20d9d44f26a325c0c511704c2d574e5f201fa4c3
4
+ data.tar.gz: 2572f3ff4960d43f228854f35005877f5cd28e6f6f57c621746b8fa3750f905d
5
5
  SHA512:
6
- metadata.gz: 7a2d2626dc179498d8e3bc634eaef11f9398456f112bed6839ed227ed96266becb34dff4d55581f6c2835541c036f7302526019ee4ab1af6c4c96865fddd8082
7
- data.tar.gz: e1725021eed0b25fa9a8605399f935a63e7f3164902f0fc354b19cbab6774c91a14039fb23b2380ef9370605c75534c263138df204fa9994e88c1a1cc71f2698
6
+ metadata.gz: 0cb60bae5692c098502337f8cc4aaec5c69ada73b6df5b9d5a614a32b3a0a4653e39b60e78ca03101f68bf45778c0a322aa4eb9299fa1726d943b43c34a8a5c8
7
+ data.tar.gz: a4b1228d7ce234a33fd7b18b48a54739791de5d2089736d70d5b84e184b8ccd355f7e9b34195824d1e177fdc4a353e49d6cc24254721df6a4b6a1c5ec2162020
data/CHANGELOG.md CHANGED
@@ -6,6 +6,21 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.2] - 2026-07-23
10
+
11
+ ### Added
12
+
13
+ - `font-family` / `ldl-font-family` attribute controlling the font used for
14
+ diagram text, and a cross-platform default
15
+ (`DejaVu Sans, Bitstream Vera Sans, Liberation Sans, Arial, sans-serif`).
16
+
17
+ ### Fixed
18
+
19
+ - Gate/comparator glyphs `−` (U+2212) and `≥` (U+2265) no longer disappear in
20
+ asciidoctor-pdf. The renderer's generic `sans-serif` was mapped by prawn-svg
21
+ to the built-in Helvetica, which lacks those glyphs; the new default names
22
+ real fonts first (register one — e.g. DejaVu Sans — in your PDF theme).
23
+
9
24
  ## [0.1.1] - 2026-07-23
10
25
 
11
26
  ### Added
@@ -31,6 +46,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
31
46
  - Content-addressed caching with a digest sidecar so unchanged diagrams are not
32
47
  re-rendered.
33
48
 
34
- [Unreleased]: https://github.com/OpenPowerShift/asciidoctor-ldl/compare/v0.1.1...HEAD
49
+ [Unreleased]: https://github.com/OpenPowerShift/asciidoctor-ldl/compare/v0.1.2...HEAD
50
+ [0.1.2]: https://github.com/OpenPowerShift/asciidoctor-ldl/compare/v0.1.1...v0.1.2
35
51
  [0.1.1]: https://github.com/OpenPowerShift/asciidoctor-ldl/compare/v0.1.0...v0.1.1
36
52
  [0.1.0]: https://github.com/OpenPowerShift/asciidoctor-ldl/releases/tag/v0.1.0
data/README.adoc CHANGED
@@ -181,6 +181,13 @@ header or on the command line (`-a ldl-format=png`).
181
181
  | `true`
182
182
  | Draw `.Name`/`.Description` labels.
183
183
 
184
+ | font-family
185
+ | ldl-font-family
186
+ | _(see below)_
187
+ | Font family for diagram text. Defaults to a cross-platform stack
188
+ (`DejaVu Sans, Bitstream Vera Sans, Liberation Sans, Arial, sans-serif`). Set
189
+ to `sans-serif` (or `none`) to keep the renderer's plain generic family.
190
+
184
191
  | target
185
192
  | —
186
193
  | _(hash)_
@@ -261,6 +268,29 @@ For `asciidoctor-pdf`, prefer `svg`: it keeps PDFs small and crisp. If you must
261
268
  raster for PDF, `png` with `scale=2` or higher gives good print quality at the
262
269
  cost of size.
263
270
 
271
+ === Fonts (asciidoctor-pdf)
272
+
273
+ Gate and comparator symbols use `−` (U+2212) and `≥` (U+2265). In
274
+ `asciidoctor-pdf`, `prawn-svg` maps the generic `sans-serif` family to the
275
+ built-in Helvetica, which lacks those glyphs — so by default this extension
276
+ names real fonts first (see `font-family` above). For them to take effect in a
277
+ PDF, *register a matching font in your theme* and it will be used automatically:
278
+
279
+ [source,yaml]
280
+ ----
281
+ # in your -theme.yml (font files under a directory on :pdf-fontsdir:)
282
+ font:
283
+ catalog:
284
+ merge: true
285
+ DejaVu Sans:
286
+ normal: DejaVuSans.ttf
287
+ bold: DejaVuSans-Bold.ttf
288
+ italic: DejaVuSans-Oblique.ttf
289
+ bold_italic: DejaVuSans-BoldOblique.ttf
290
+ ----
291
+
292
+ HTML and PNG output already resolve the glyphs without any setup.
293
+
264
294
  == Styling with roles
265
295
 
266
296
  Every generated image is tagged with roles so it can be targeted from CSS or an
@@ -35,6 +35,7 @@ module Asciidoctor
35
35
  theme: attr(attrs, doc, 'theme', 'ldl-theme', 'light'),
36
36
  show_ids: attr(attrs, doc, 'show-ids', 'ldl-show-ids', nil),
37
37
  show_labels: attr(attrs, doc, 'show-labels', 'ldl-show-labels', nil),
38
+ font_family: attr(attrs, doc, 'font-family', 'ldl-font-family', nil),
38
39
  node: doc.attr('ldl-node', 'node'),
39
40
  package_dir: doc.attr('ldl-package-dir') || doc.attr('ldl-node-modules'),
40
41
  out_dir: image_output_dir(doc),
@@ -64,6 +64,7 @@ function parseArgs(argv) {
64
64
  showLabels: true,
65
65
  out: null,
66
66
  packageDir: null,
67
+ fontFamily: null,
67
68
  };
68
69
  for (let i = 0; i < argv.length; i++) {
69
70
  const arg = argv[i];
@@ -78,6 +79,7 @@ function parseArgs(argv) {
78
79
  case '--no-show-labels': opts.showLabels = false; break;
79
80
  case '--out': opts.out = next(); break;
80
81
  case '--package-dir': opts.packageDir = next(); break;
82
+ case '--font-family': opts.fontFamily = next(); break;
81
83
  default:
82
84
  throw new Error(`unknown argument: ${arg}`);
83
85
  }
@@ -150,6 +152,18 @@ function sizeFromViewBox(svg) {
150
152
  return { width: parseFloat(m[1]), height: parseFloat(m[2]) };
151
153
  }
152
154
 
155
+ // The renderer tags diagram text with font-family="sans-serif". Some consumers
156
+ // map that generic family to a glyph-poor built-in font (e.g. prawn-svg in
157
+ // asciidoctor-pdf uses Helvetica, which lacks − U+2212 and ≥ U+2265). Rewriting
158
+ // it to a named font that the consumer has registered fixes those glyphs.
159
+ function applyFontFamily(svg, family) {
160
+ if (!family) return svg;
161
+ const q = family.replace(/"/g, '&quot;');
162
+ return svg
163
+ .replace(/font-family="sans-serif"/g, `font-family="${q}"`)
164
+ .replace(/font-family:\s*sans-serif/g, `font-family:${family}`);
165
+ }
166
+
153
167
  function applySvgScale(svg, scale) {
154
168
  const size = sizeFromViewBox(svg);
155
169
  if (!size) return { svg, size };
@@ -184,7 +198,7 @@ async function main() {
184
198
  renderOptions.showLabels = opts.showLabels;
185
199
  const theme = opts.theme === 'dark' ? DARK_DIAGRAM : LIGHT_DIAGRAM;
186
200
 
187
- let svg = renderDiagram(diagram, renderOptions, theme);
201
+ let svg = applyFontFamily(renderDiagram(diagram, renderOptions, theme), opts.fontFamily);
188
202
  const scaled = applySvgScale(svg, opts.scale);
189
203
  svg = scaled.svg;
190
204
  const size = scaled.size || { width: 0, height: 0 };
@@ -201,7 +215,7 @@ async function main() {
201
215
  const { Resvg } = await loadResvg(opts.packageDir);
202
216
  // Rasterise from the *unscaled* viewBox using resvg's own zoom, so the scale
203
217
  // multiplies device pixels crisply rather than baking a size into the SVG.
204
- const base = renderDiagram(diagram, renderOptions, theme);
218
+ const base = applyFontFamily(renderDiagram(diagram, renderOptions, theme), opts.fontFamily);
205
219
  const resvg = new Resvg(base, {
206
220
  fitTo: { mode: 'zoom', value: opts.scale },
207
221
  background: 'white',
Binary file
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Ldl
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-ldl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Mulholland