avoid loading of font file, to eliminate "Illegal reflective access by com.lowagie.text.pdf.MappedRandomAccessFile$1 (iText-2.1.5.jar) to method java.nio.DirectByteBuffer.cleaner()" -- due to com.lowagie.text.pdf.TrueTypeFont.process() / RandomAccessFileOrArray;
authorwenzelm
Wed, 28 Nov 2018 15:38:18 +0100
changeset 69365 c5b3860d29ef
parent 69364 91dbade9a5fa
child 69366 b6dacf6eabe3
avoid loading of font file, to eliminate "Illegal reflective access by com.lowagie.text.pdf.MappedRandomAccessFile$1 (iText-2.1.5.jar) to method java.nio.DirectByteBuffer.cleaner()" -- due to com.lowagie.text.pdf.TrueTypeFont.process() / RandomAccessFileOrArray;
src/Pure/General/bytes.scala
src/Pure/General/graphics_file.scala
--- a/src/Pure/General/bytes.scala	Wed Nov 28 15:11:21 2018 +0100
+++ b/src/Pure/General/bytes.scala	Wed Nov 28 15:38:18 2018 +0100
@@ -139,6 +139,13 @@
 
   lazy val sha1_digest: SHA1.Digest = SHA1.digest(bytes)
 
+  def array: Array[Byte] =
+  {
+    val a = new Array[Byte](length)
+    System.arraycopy(bytes, offset, a, 0, length)
+    a
+  }
+
   def text: String =
     UTF8.decode_chars(s => s, bytes, offset, offset + length).toString
 
--- a/src/Pure/General/graphics_file.scala	Wed Nov 28 15:11:21 2018 +0100
+++ b/src/Pure/General/graphics_file.scala	Wed Nov 28 15:38:18 2018 +0100
@@ -48,6 +48,7 @@
       val params = new DefaultFontMapper.BaseFontParameters(File.platform_path(entry.path))
       params.encoding = BaseFont.IDENTITY_H
       params.embedded = true
+      params.ttfAfm = entry.bytes.array
       mapper.putName(entry.name, params)
     }
     mapper