 #-----------------------------------------------------------------------------------------------------------
 @save_otjsfont = ( path, otjsfont ) ->
   # FS.writeFileSync path, buffer = otjsfont.toBuffer() # deprecated
-  FS.writeFileSync path, buffer = Buffer.from otjsfont.toArrayBuffer()
+  # buffer = Buffer.from otjsfont.toArrayBuffer()
+  buffer = Buffer.from @_otjsfont_toArrayBuffer otjsfont
+  FS.writeFileSync path, buffer
   return buffer.length
+
+@_otjsfont_toArrayBuffer = ( otjsfont ) ->
+  sfntTable = otjsfont.toTables();
+  bytes     = sfntTable.encode();
+  buffer    = new ArrayBuffer(bytes.length);
+  intArray  = new Uint8Array(buffer);
+  ```
+  for (let i = 0; i < bytes.length; i++) {
+      intArray[i] = bytes[i];
+  }
+  ```
+  return buffer;
 
 #-----------------------------------------------------------------------------------------------------------
 @list_glyphs_in_otjsfont = ( otjsfont ) ->

  return "<!-- #{cid_hex} #{glyph} --><path d='#{pathdata}'/>"

#-----------------------------------------------------------------------------------------------------------
@glyph_and_pathdata_from_cid = ( otjsfont, cid ) ->
  XXXXX_metrics       = @new_metrics()
  validate.positive_integer cid
  fglyph              = otjsfont.charToGlyph String.fromCodePoint cid
  return null unless fglyph.unicode?
  path_obj            = fglyph.getPath 0, 0, XXXXX_metrics.font_size
  pathdata            = path_obj.toPathData path_precision
  return null if pathdata.length is 0
  svg_path            = new SvgPath pathdata
  global_glyph_scale  = XXXXX_metrics.global_glyph_scale ? 1
  scale_factor        = XXXXX_metrics.scale_factor * global_glyph_scale
  svg_path            = svg_path.scale scale_factor, -scale_factor
  return { glyph: fglyph, pathdata: svg_path.toString(), }


#-----------------------------------------------------------------------------------------------------------
@get_fallback_glyph = ( me, shape = 'square' ) ->
  # validate.svgttf_metrics me
  '❶❷❸❹❺❻❼❽❾❿'
  validate.nonempty_text shape
  #.........................................................................................................
  width         = 3 * me.em_size // 4
