fontisan 0.4.49-x86_64-linux → 0.4.50-x86_64-linux

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: 88988861e7bc9dae788dc06e722eb09603ba7cf826e8beef040e7dd942606e82
4
- data.tar.gz: e23ee3c9b2b7bf9832f59c2414e490b414c169b7ad972c3bfeba328359a78da4
3
+ metadata.gz: f63da10caee80d837c8df7a6853c48954c5729ad6eead580f33523255c7706e4
4
+ data.tar.gz: ba59e3653733ec897c105b8fd7a51d0d3f72dc7a6124c26b118b9a041e87974e
5
5
  SHA512:
6
- metadata.gz: 90047a1bbeada65b227e7d123a2ebc86fea95a4f6af872f0fe327aa88c1eee7103da22354579008defc9d140fdc6e172dec31ed32ef8dabf3346d2848da58ef9
7
- data.tar.gz: 1847feda8008faacb8f9e68a409e155576468dfb5e707ca7bfefec68a5240e4ec0cefc6af4c3a89d0f30e7146cc4f11657aad98aa3b1fafd5a1ae58de11d4f30
6
+ metadata.gz: d32ec508a1e2f94d7a9e1a869e4251dab643775dfe3bd7c69170ecf721dcb4ab2523bb3ca3be8f70e700f0c41a6343408955fdd37ab510ef56411de7017d2f0e
7
+ data.tar.gz: 1cf2d21d39f0aeab0585b6a53e0b06269b0e3f0b624255a2ceb15b58475073224632cb15a712a77ba6ab9ad3f81e8a59507b30dda90e09473f97e88020e4115f
@@ -44,22 +44,22 @@ end
44
44
  ### Parse SVG Content
45
45
 
46
46
  ```ruby
47
- require 'nokogiri'
47
+ require 'moxml'
48
48
 
49
49
  svg = font.tables['SVG']
50
50
  doc = svg.documents[42] # SVG for glyph 42
51
51
 
52
- parsed = Nokogiri::XML(doc)
52
+ parsed = Moxml.parse(doc)
53
53
 
54
54
  # Find elements
55
- paths = parsed.css('path')
55
+ paths = parsed.root.css('path')
56
56
  puts "Paths: #{paths.length}"
57
57
 
58
- rects = parsed.css('rect')
58
+ rects = parsed.root.css('rect')
59
59
  puts "Rectangles: #{rects.length}"
60
60
 
61
61
  # Find gradients
62
- gradients = parsed.css('linearGradient', 'radialGradient')
62
+ gradients = parsed.root.css('linearGradient, radialGradient')
63
63
  puts "Gradients: #{gradients.length}"
64
64
  ```
65
65
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "moxml"
4
4
 
5
5
  module Fontisan
6
6
  module Export
@@ -40,21 +40,35 @@ module Fontisan
40
40
  def generate(options = {})
41
41
  table_list = options[:tables] || :all
42
42
 
43
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
44
- xml.ttFont(
45
- "sfntVersion" => format_sfnt_version(to_int(@font.header.sfnt_version)),
46
- "ttLibVersion" => "4.0",
47
- ) do
48
- generate_glyph_order(xml)
49
-
50
- tables_to_generate = select_tables(table_list)
51
- tables_to_generate.each do |tag|
52
- generate_table(xml, tag)
53
- end
43
+ # The ttFont body lambda is created here (method context) so
44
+ # its self stays this generator: moxml's #build block is
45
+ # instance_eval'd against the builder, which would turn bare
46
+ # helper calls into tag names. The zero-indent context keeps
47
+ # the builder markup flat so the pretty reparse in
48
+ # format_output owns all indentation (reindenting
49
+ # already-indented mixed content glues sibling tags together).
50
+ context = Moxml.new { |config| config.default_indent = 0 }
51
+ builder = Moxml::Builder.new(context)
52
+ sfnt_version = format_sfnt_version(to_int(@font.header.sfnt_version))
53
+ root_body = -> {
54
+ generate_glyph_order(builder)
55
+
56
+ tables_to_generate = select_tables(table_list)
57
+ tables_to_generate.each do |tag|
58
+ generate_table(builder, tag)
54
59
  end
60
+ }
61
+ builder.build do
62
+ declaration(version: "1.0", encoding: "UTF-8")
63
+ create_tag("ttFont",
64
+ { "sfntVersion" => sfnt_version,
65
+ "ttLibVersion" => "4.0" },
66
+ block: root_body)
55
67
  end
56
68
 
57
- format_output(builder.to_xml)
69
+ # expand_empty: false keeps the Nokogiri shape (empty elements
70
+ # self-close, e.g. <GlyphID id="0" name=".notdef"/>).
71
+ format_output(builder.doc.to_xml(expand_empty: false))
58
72
  end
59
73
 
60
74
  private
@@ -69,7 +83,7 @@ module Fontisan
69
83
 
70
84
  # Generate GlyphOrder section (required first)
71
85
  #
72
- # @param xml [Nokogiri::XML::Builder] XML builder
86
+ # @param xml [Moxml::Builder] XML builder
73
87
  # @return [void]
74
88
  def generate_glyph_order(xml)
75
89
  xml.GlyphOrder do
@@ -83,7 +97,7 @@ module Fontisan
83
97
 
84
98
  # Generate individual table XML
85
99
  #
86
- # @param xml [Nokogiri::XML::Builder] XML builder
100
+ # @param xml [Moxml::Builder] XML builder
87
101
  public
88
102
 
89
103
  # Per-tag emitter dispatch table. Adding a new table's TTX
@@ -138,7 +152,7 @@ module Fontisan
138
152
 
139
153
  # Generate head table XML
140
154
  #
141
- # @param xml [Nokogiri::XML::Builder] XML builder
155
+ # @param xml [Moxml::Builder] XML builder
142
156
  # @param table [Tables::Head] Head table
143
157
  # @return [void]
144
158
  def generate_head_table(xml, table)
@@ -167,7 +181,7 @@ module Fontisan
167
181
 
168
182
  # Generate hhea table XML
169
183
  #
170
- # @param xml [Nokogiri::XML::Builder] XML builder
184
+ # @param xml [Moxml::Builder] XML builder
171
185
  # @param table [Tables::Hhea] Hhea table
172
186
  # @return [void]
173
187
  def generate_hhea_table(xml, table)
@@ -194,7 +208,7 @@ module Fontisan
194
208
 
195
209
  # Generate maxp table XML
196
210
  #
197
- # @param xml [Nokogiri::XML::Builder] XML builder
211
+ # @param xml [Moxml::Builder] XML builder
198
212
  # @param table [Tables::Maxp] Maxp table
199
213
  # @return [void]
200
214
  def generate_maxp_table(xml, table)
@@ -224,7 +238,7 @@ module Fontisan
224
238
 
225
239
  # Generate post table XML
226
240
  #
227
- # @param xml [Nokogiri::XML::Builder] XML builder
241
+ # @param xml [Moxml::Builder] XML builder
228
242
  # @param table [Tables::Post] Post table
229
243
  # @return [void]
230
244
  def generate_post_table(xml, table)
@@ -243,7 +257,7 @@ module Fontisan
243
257
 
244
258
  # Generate name table XML
245
259
  #
246
- # @param xml [Nokogiri::XML::Builder] XML builder
260
+ # @param xml [Moxml::Builder] XML builder
247
261
  # @param table [Tables::Name] Name table
248
262
  # @return [void]
249
263
  def generate_name_table(xml, table)
@@ -263,7 +277,7 @@ module Fontisan
263
277
 
264
278
  # Generate OS/2 table XML
265
279
  #
266
- # @param xml [Nokogiri::XML::Builder] XML builder
280
+ # @param xml [Moxml::Builder] XML builder
267
281
  # @param table [Tables::Os2] OS/2 table
268
282
  # @return [void]
269
283
  def generate_os2_table(xml, table)
@@ -274,10 +288,10 @@ module Fontisan
274
288
 
275
289
  # Helper to add element with value attribute
276
290
  #
277
- # @param parent [Nokogiri::XML::Element] Parent element
291
+ # @param parent [Moxml::Element] Parent element
278
292
  # @param name [String] Element name
279
293
  # @param value [Object] Value
280
- # @param doc [Nokogiri::XML::Document] Document
294
+ # @param doc [Moxml::Document] Document
281
295
  # @return [void]
282
296
  def add_element_with_value(parent, name, value, doc)
283
297
  elem = doc.create_element(name)
@@ -287,7 +301,7 @@ module Fontisan
287
301
 
288
302
  # Generate binary table as hexdata
289
303
  #
290
- # @param xml [Nokogiri::XML::Builder] XML builder
304
+ # @param xml [Moxml::Builder] XML builder
291
305
  # @param tag [String] Table tag
292
306
  # @param table [Object] Table object
293
307
  # @return [void]
@@ -302,7 +316,7 @@ module Fontisan
302
316
 
303
317
  # Generate binary table from raw data
304
318
  #
305
- # @param xml [Nokogiri::XML::Builder] XML builder
319
+ # @param xml [Moxml::Builder] XML builder
306
320
  # @param tag [String] Table tag
307
321
  # @param data [String] Raw binary data
308
322
  # @return [void]
@@ -318,7 +332,7 @@ module Fontisan
318
332
 
319
333
  # Generate cmap table XML (simplified for now)
320
334
  #
321
- # @param xml [Nokogiri::XML::Builder] XML builder
335
+ # @param xml [Moxml::Builder] XML builder
322
336
  # @param table [Object] Cmap table
323
337
  # @return [void]
324
338
  def generate_cmap_table(xml, table)
@@ -327,7 +341,7 @@ module Fontisan
327
341
 
328
342
  # Generate loca table XML
329
343
  #
330
- # @param xml [Nokogiri::XML::Builder] XML builder
344
+ # @param xml [Moxml::Builder] XML builder
331
345
  # @param table [Object] Loca table
332
346
  # @return [void]
333
347
  def generate_loca_table(xml, _table)
@@ -338,7 +352,7 @@ module Fontisan
338
352
 
339
353
  # Generate glyf table XML (simplified for now)
340
354
  #
341
- # @param xml [Nokogiri::XML::Builder] XML builder
355
+ # @param xml [Moxml::Builder] XML builder
342
356
  # @param table [Object] Glyf table
343
357
  # @return [void]
344
358
  def generate_glyf_table(xml, table)
@@ -347,7 +361,7 @@ module Fontisan
347
361
 
348
362
  # Generate CFF table XML (simplified for now)
349
363
  #
350
- # @param xml [Nokogiri::XML::Builder] XML builder
364
+ # @param xml [Moxml::Builder] XML builder
351
365
  # @param table [Object] CFF table
352
366
  # @return [void]
353
367
  def generate_cff_table(xml, table)
@@ -356,7 +370,7 @@ module Fontisan
356
370
 
357
371
  # Generate hmtx table XML (simplified for now)
358
372
  #
359
- # @param xml [Nokogiri::XML::Builder] XML builder
373
+ # @param xml [Moxml::Builder] XML builder
360
374
  # @param table [Object] Hmtx table
361
375
  # @return [void]
362
376
  def generate_hmtx_table(xml, table)
@@ -365,7 +379,7 @@ module Fontisan
365
379
 
366
380
  # Generate fvar table XML
367
381
  #
368
- # @param xml [Nokogiri::XML::Builder] XML builder
382
+ # @param xml [Moxml::Builder] XML builder
369
383
  # @param table [Tables::Fvar] Fvar table
370
384
  # @return [void]
371
385
  def generate_fvar_table(xml, table)
@@ -376,10 +390,12 @@ module Fontisan
376
390
  table.axes.each do |axis|
377
391
  xml.Axis do
378
392
  xml.AxisTag axis.axis_tag
379
- xml.MinValue to_int(axis.min_value) / 65536.0
380
- xml.DefaultValue to_int(axis.default_value) / 65536.0
381
- xml.MaxValue to_int(axis.max_value) / 65536.0
382
- xml.AxisNameID to_int(axis.axis_name_id)
393
+ # moxml builder text content must be a String (Nokogiri
394
+ # stringified any value); .to_s keeps the same bytes.
395
+ xml.MinValue (to_int(axis.min_value) / 65536.0).to_s
396
+ xml.DefaultValue (to_int(axis.default_value) / 65536.0).to_s
397
+ xml.MaxValue (to_int(axis.max_value) / 65536.0).to_s
398
+ xml.AxisNameID to_int(axis.axis_name_id).to_s
383
399
  end
384
400
  end
385
401
  end
@@ -387,7 +403,7 @@ module Fontisan
387
403
 
388
404
  # Generate variation table XML (gvar, cvar, HVAR, etc.)
389
405
  #
390
- # @param xml [Nokogiri::XML::Builder] XML builder
406
+ # @param xml [Moxml::Builder] XML builder
391
407
  # @param tag [String] Table tag
392
408
  # @param table [Object] Variation table
393
409
  # @return [void]
@@ -514,8 +530,10 @@ module Fontisan
514
530
  # @return [String] Formatted XML
515
531
  def format_output(xml)
516
532
  if @pretty
517
- doc = Nokogiri::XML(xml)
518
- doc.to_xml(indent: @indent)
533
+ doc = Moxml.parse(xml)
534
+ # expand_empty: false keeps the Nokogiri shape (empty
535
+ # elements self-close).
536
+ doc.to_xml(indent: @indent, expand_empty: false)
519
537
  else
520
538
  # Remove extra whitespace for compact format
521
539
  xml.gsub(/>\s+</, "><").gsub(/\n\s*/, "")
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "moxml"
4
4
 
5
5
  module Fontisan
6
6
  module Export
@@ -19,7 +19,7 @@ module Fontisan
19
19
  # @param ttx_xml [String] TTX XML content
20
20
  # @return [Hash] Parsed font data structure
21
21
  def parse(ttx_xml)
22
- doc = Nokogiri::XML(ttx_xml)
22
+ doc = Moxml.parse(ttx_xml)
23
23
  ttfont = doc.at_xpath("/ttFont")
24
24
  raise "No ttFont root element found" unless ttfont
25
25
 
@@ -51,7 +51,7 @@ module Fontisan
51
51
 
52
52
  # Parse GlyphOrder section
53
53
  #
54
- # @param ttfont [Nokogiri::XML::Element] Root element
54
+ # @param ttfont [Moxml::Element] Root element
55
55
  # @return [Array<Hash>] Array of glyph entries
56
56
  def parse_glyph_order(ttfont)
57
57
  glyph_order = ttfont.at_xpath("GlyphOrder")
@@ -67,7 +67,7 @@ module Fontisan
67
67
 
68
68
  # Parse all tables
69
69
  #
70
- # @param ttfont [Nokogiri::XML::Element] Root element
70
+ # @param ttfont [Moxml::Element] Root element
71
71
  # @return [Hash] Hash of table data by tag
72
72
  def parse_tables(ttfont)
73
73
  tables = {}
@@ -88,7 +88,7 @@ module Fontisan
88
88
 
89
89
  # Parse head table
90
90
  #
91
- # @param ttfont [Nokogiri::XML::Element] Root element
91
+ # @param ttfont [Moxml::Element] Root element
92
92
  # @param tables [Hash] Tables hash
93
93
  # @return [void]
94
94
  def parse_head_table(ttfont, tables)
@@ -118,7 +118,7 @@ module Fontisan
118
118
 
119
119
  # Parse hhea table
120
120
  #
121
- # @param ttfont [Nokogiri::XML::Element] Root element
121
+ # @param ttfont [Moxml::Element] Root element
122
122
  # @param tables [Hash] Tables hash
123
123
  # @return [void]
124
124
  def parse_hhea_table(ttfont, tables)
@@ -144,7 +144,7 @@ module Fontisan
144
144
 
145
145
  # Parse maxp table
146
146
  #
147
- # @param ttfont [Nokogiri::XML::Element] Root element
147
+ # @param ttfont [Moxml::Element] Root element
148
148
  # @param tables [Hash] Tables hash
149
149
  # @return [void]
150
150
  def parse_maxp_table(ttfont, tables)
@@ -169,7 +169,7 @@ module Fontisan
169
169
 
170
170
  # Parse name table
171
171
  #
172
- # @param ttfont [Nokogiri::XML::Element] Root element
172
+ # @param ttfont [Moxml::Element] Root element
173
173
  # @param tables [Hash] Tables hash
174
174
  # @return [void]
175
175
  def parse_name_table(ttfont, tables)
@@ -191,7 +191,7 @@ module Fontisan
191
191
 
192
192
  # Parse OS/2 table (stub)
193
193
  #
194
- # @param ttfont [Nokogiri::XML::Element] Root element
194
+ # @param ttfont [Moxml::Element] Root element
195
195
  # @param tables [Hash] Tables hash
196
196
  # @return [void]
197
197
  def parse_os2_table(ttfont, tables)
@@ -204,7 +204,7 @@ module Fontisan
204
204
 
205
205
  # Parse post table (stub)
206
206
  #
207
- # @param ttfont [Nokogiri::XML::Element] Root element
207
+ # @param ttfont [Moxml::Element] Root element
208
208
  # @param tables [Hash] Tables hash
209
209
  # @return [void]
210
210
  def parse_post_table(ttfont, tables)
@@ -222,7 +222,7 @@ module Fontisan
222
222
 
223
223
  # Parse binary tables (fallback)
224
224
  #
225
- # @param ttfont [Nokogiri::XML::Element] Root element
225
+ # @param ttfont [Moxml::Element] Root element
226
226
  # @param tables [Hash] Tables hash
227
227
  # @return [void]
228
228
  def parse_binary_tables(ttfont, tables)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "lutaml/model"
4
+ require "moxml"
4
5
 
5
6
  module Fontisan
6
7
  module Models
@@ -17,24 +18,28 @@ module Fontisan
17
18
  # Custom serialization since we need dynamic root element
18
19
  # based on table tag
19
20
  def to_xml(options = {})
20
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
21
- xml.public_send(tag.to_sym) do
22
- xml.hexdata do
23
- xml.text("\n #{format_hexdata(hexdata)}\n ")
24
- end
25
- end
26
- end
21
+ builder = Moxml::Builder.new(Moxml.new)
22
+ table_tag = tag
23
+ body = -> {
24
+ builder.create_tag(table_tag, block: -> {
25
+ builder.create_tag(
26
+ "hexdata",
27
+ text_content: "\n #{format_hexdata(hexdata)}\n ",
28
+ )
29
+ })
30
+ }
31
+ builder.build(&body)
27
32
 
28
33
  if options[:pretty]
29
34
  builder.doc.root.to_xml(indent: options.fetch(:indent, 2))
30
35
  else
31
- builder.to_xml
36
+ builder.doc.to_xml(expand_empty: false)
32
37
  end
33
38
  end
34
39
 
35
40
  # Parse from XML
36
41
  def self.from_xml(xml_string, tag)
37
- doc = Nokogiri::XML(xml_string)
42
+ doc = Moxml.parse(xml_string)
38
43
  table_elem = doc.at_xpath("//#{tag}")
39
44
  return nil unless table_elem
40
45
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "moxml"
4
4
 
5
5
  module Fontisan
6
6
  module SvgToGlyf
@@ -13,7 +13,7 @@ module Fontisan
13
13
 
14
14
  # @param xml [String] raw SVG XML
15
15
  def self.from_xml(xml)
16
- new(Nokogiri::XML(xml))
16
+ new(Moxml.parse(xml))
17
17
  end
18
18
 
19
19
  # @param path [String] file path to an .svg file
@@ -21,7 +21,7 @@ module Fontisan
21
21
  from_xml(File.read(path))
22
22
  end
23
23
 
24
- # @param doc [Nokogiri::XML::Document]
24
+ # @param doc [Moxml::Document]
25
25
  def initialize(doc)
26
26
  @doc = doc
27
27
  @source = doc
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "moxml"
4
4
 
5
5
  module Fontisan
6
6
  module Ufo
@@ -110,27 +110,39 @@ module Fontisan
110
110
  # @param xml [String] the .glif XML body
111
111
  # @return [Glyph] parsed glyph
112
112
  def self.from_glif(xml)
113
- doc = Nokogiri::XML(xml)
113
+ doc = Moxml.parse(xml)
114
114
  root = doc.root
115
115
  new(name: root["name"]).tap { |g| g.read_from(root) }
116
116
  end
117
117
 
118
118
  # Render this glyph back to .glif XML.
119
+ #
120
+ # The glyph body block is created here (method context) so its
121
+ # self stays this glyph: moxml's #build block is instance_eval'd
122
+ # against the builder, which would turn bare helper calls into
123
+ # tag names.
119
124
  # @return [String] XML text
120
125
  def to_glif
121
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
122
- xml.glyph(name: @name, format: "2") do
123
- emit_advance(xml)
124
- emit_unicodes(xml)
125
- emit_outline(xml)
126
- emit_lib(xml)
127
- emit_note(xml)
128
- end
126
+ builder = Moxml::Builder.new(Moxml.new)
127
+ body = -> {
128
+ emit_advance(builder)
129
+ emit_unicodes(builder)
130
+ emit_outline(builder)
131
+ emit_lib(builder)
132
+ emit_note(builder)
133
+ }
134
+ name = @name
135
+ builder.build do
136
+ declaration(version: "1.0", encoding: "UTF-8")
137
+ create_tag("glyph", { "name" => name, "format" => "2" },
138
+ block: body)
129
139
  end
130
- builder.to_xml
140
+ # expand_empty: false keeps the Nokogiri shape (empty elements
141
+ # self-close, e.g. <advance width="0"/>).
142
+ builder.doc.to_xml(expand_empty: false)
131
143
  end
132
144
 
133
- # Populate this glyph from a <glyph> Nokogiri node.
145
+ # Populate this glyph from a <glyph> Moxml node.
134
146
  def read_from(root)
135
147
  read_advance(root)
136
148
  read_unicodes(root)
@@ -325,7 +337,7 @@ module Fontisan
325
337
  @note = note_node.text if note_node
326
338
  end
327
339
 
328
- # Helper: read a <dict> Nokogiri node into a Hash. Reuses the
340
+ # Helper: read a <dict> Moxml node into a Hash. Reuses the
329
341
  # same key/value pair logic as Plist.parse but operates on the
330
342
  # inlined lib plist.
331
343
  def read_dict_to_hash(dict_node)
@@ -422,11 +434,11 @@ module Fontisan
422
434
 
423
435
  def emit_value(xml, v)
424
436
  case v
425
- when String then xml.string(v)
426
- when Integer then xml.integer(v)
427
- when Float then xml.real(v)
428
- when true then xml.__send__(true)
429
- when false then xml.__send__(false)
437
+ when String then v.empty? ? xml.string_ : xml.string(v)
438
+ when Integer then xml.integer(v.to_s)
439
+ when Float then xml.real(v.to_s)
440
+ when true then xml.true_
441
+ when false then xml.false_
430
442
  when Array then xml.array { v.each { |i| emit_value(xml, i) } }
431
443
  when Hash then emit_dict(xml, v)
432
444
  else xml.string(v.to_s)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "nokogiri"
3
+ require "moxml"
4
4
 
5
5
  module Fontisan
6
6
  module Ufo
@@ -18,10 +18,10 @@ module Fontisan
18
18
  PLIST_DTD = "-//Apple//DTD PLIST 1.0//EN"
19
19
  PLIST_NS = "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
20
20
 
21
- # @param source [String, Nokogiri::XML::Document] the XML plist
21
+ # @param source [String, Moxml::Document] the XML plist
22
22
  # @return [Object] the deserialized value
23
23
  def self.parse(source)
24
- doc = source.is_a?(Nokogiri::XML::Document) ? source : Nokogiri::XML(source)
24
+ doc = parse_document(source)
25
25
  root = doc.root
26
26
  raise ParseError, "no <plist> root element" unless root&.name == "plist"
27
27
 
@@ -33,22 +33,22 @@ module Fontisan
33
33
  # @param value [Object] the value to serialize
34
34
  # @return [String] the XML plist text
35
35
  def self.emit(value)
36
- builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
37
- create_doc_internal_subset(xml)
38
- xml.plist(version: "1.0") do
39
- emit_value(xml, value)
36
+ builder = Moxml::Builder.new(Moxml.new)
37
+ builder.build do
38
+ doctype("plist", PLIST_DTD, PLIST_NS)
39
+ plist(version: "1.0") do
40
+ Plist.emit_value(builder, value)
40
41
  end
41
42
  end
42
- builder.to_xml(
43
- save_with:
44
- Nokogiri::XML::Node::SaveOptions::AS_XML |
45
- Nokogiri::XML::Node::SaveOptions::NO_DECLARATION,
46
- )
43
+ # indent: 0 keeps the body on the single line Nokogiri's
44
+ # AS_XML produced; expand_empty: false keeps its `<string/>`
45
+ # self-closing shape for empty elements.
46
+ builder.doc.to_xml(indent: 0, expand_empty: false)
47
47
  end
48
48
 
49
- # @return [Nokogiri::XML::Document] the typed root
49
+ # @return [Moxml::Document] the typed root
50
50
  def self.parse_document(source)
51
- source.is_a?(Nokogiri::XML::Document) ? source : Nokogiri::XML(source)
51
+ source.is_a?(Moxml::Document) ? source : Moxml.parse(source)
52
52
  end
53
53
 
54
54
  # ---------- private-ish (called via module_function) ----------
@@ -90,20 +90,18 @@ module Fontisan
90
90
  node.element_children.map { |child| parse_value(child) }
91
91
  end
92
92
 
93
- def self.create_doc_internal_subset(xml)
94
- xml.doc.create_internal_subset("plist", PLIST_DTD, PLIST_NS)
95
- end
96
-
97
93
  def self.emit_value(xml, value)
98
94
  case value
99
95
  when nil
100
96
  # No <nil/> in Apple's plist DTD; use a sentinel string.
101
- xml.string("")
102
- when true then xml.__send__(true)
103
- when false then xml.__send__(false)
104
- when Integer then xml.integer(value)
105
- when Float then xml.real(value)
106
- when String then xml.string(value)
97
+ xml.string_
98
+ when true then xml.true_
99
+ when false then xml.false_
100
+ when Integer then xml.integer(value.to_s)
101
+ when Float then xml.real(value.to_s)
102
+ # An empty string serializes as a self-closed <string/>, like
103
+ # Nokogiri did; moxml keeps a paired form for a text child.
104
+ when String then value.empty? ? xml.string_ : xml.string(value)
107
105
  when Symbol then xml.string(value.to_s)
108
106
  when Array then xml.array { value.each { |v| emit_value(xml, v) } }
109
107
  when Hash then xml.dict { emit_dict_body(xml, value) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fontisan
4
- VERSION = "0.4.49"
4
+ VERSION = "0.4.50"
5
5
  end
data/lib/fontisan.rb CHANGED
@@ -35,9 +35,25 @@ require "stringio"
35
35
  require "tmpdir"
36
36
  require "lutaml/model"
37
37
 
38
- # Configure lutaml-model to use Nokogiri adapter for XML serialization
38
+ # The XML engine behind lutaml-model, chosen by what actually loads on
39
+ # this machine: leptris (pure-C99, precompiled everywhere) when its
40
+ # library loads, then nokogiri if present, then REXML (stdlib). The
41
+ # probe is load-bearing: leptris's precompiled linux builds need
42
+ # glibc >= 2.34, and forcing the adapter on an older glibc would crash
43
+ # every boot — e.g. inside the rake-compiler-dock cross builds.
44
+ xml_adapter = begin
45
+ require "leptris"
46
+ :leptris
47
+ rescue LoadError
48
+ begin
49
+ require "nokogiri"
50
+ :nokogiri
51
+ rescue LoadError
52
+ :rexml
53
+ end
54
+ end
39
55
  Lutaml::Model::Config.configure do |config|
40
- config.xml_adapter_type = :nokogiri
56
+ config.xml_adapter_type = xml_adapter
41
57
  end
42
58
 
43
59
  module Fontisan
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontisan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.49
4
+ version: 0.4.50
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-19 00:00:00.000000000 Z
11
+ date: 2026-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: leptris
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.9'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.9'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: logger
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,19 +95,19 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0.8'
83
97
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
98
+ name: moxml
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '1.16'
103
+ version: '0.6'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '1.16'
110
+ version: '0.6'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: thor
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -191,7 +205,6 @@ files:
191
205
  - benchmark/corpus/tiers.rb
192
206
  - benchmark/tier_baseline.json
193
207
  - benchmark/variation_quick_bench.rb
194
- - build_mingw32_stub.rb
195
208
  - docs/.gitignore
196
209
  - docs/.vitepress/config.ts
197
210
  - docs/.vitepress/theme/components/ApiMethod.vue
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems/package"
4
-
5
- # Builds the lib-only x64-mingw32 platform stub (the parsanol-ruby
6
- # release protocol). The newest x64-mingw32 Ruby is 3.0, outside the
7
- # cross-gem ABI set (3.2+), so a native gem cannot exist for that
8
- # platform; the stub carries the pure-Ruby engine so the platform
9
- # matrix on RubyGems is complete for resolvers and installs build
10
- # nothing.
11
- spec = Gem::Specification.load("fontisan.gemspec")
12
- spec.platform = Gem::Platform.new("x64-mingw32")
13
- spec.extensions = []
14
- spec.files = spec.files.reject { |f| f.start_with?("ext/") }
15
- Gem::Package.build(spec)