proper font file name for HTTP (amending dc9a39c3f75d);
authorwenzelm
Wed, 28 Nov 2018 15:11:21 +0100
changeset 69364 91dbade9a5fa
parent 69363 0675481ce575
child 69365 c5b3860d29ef
proper font file name for HTTP (amending dc9a39c3f75d); clarified Entry content;
src/Pure/General/http.scala
src/Pure/System/isabelle_fonts.scala
--- a/src/Pure/General/http.scala	Wed Nov 28 14:51:24 2018 +0100
+++ b/src/Pure/General/http.scala	Wed Nov 28 15:11:21 2018 +0100
@@ -154,14 +154,18 @@
 
   /* fonts */
 
-  private lazy val html_fonts: List[(String, Bytes)] =
-    Isabelle_Fonts.fonts(html = true).map(entry => (entry.name -> entry.bytes))
+  private lazy val html_fonts: List[Isabelle_Fonts.Entry] = Isabelle_Fonts.fonts(html = true)
 
   def fonts(root: String = "/fonts"): Handler =
     get(root, arg =>
       {
         val uri_name = arg.uri.toString
-        if (uri_name == root) Some(Response.text(cat_lines(html_fonts.map(_._1))))
-        else html_fonts.collectFirst({ case (a, b) if uri_name == root + "/" + a => Response(b) })
+        if (uri_name == root) {
+          Some(Response.text(cat_lines(html_fonts.map(entry => entry.path.base_name))))
+        }
+        else {
+          html_fonts.collectFirst(
+            { case entry if uri_name == root + "/" + entry.path.base_name => Response(entry.bytes) })
+        }
       })
 }
--- a/src/Pure/System/isabelle_fonts.scala	Wed Nov 28 14:51:24 2018 +0100
+++ b/src/Pure/System/isabelle_fonts.scala	Wed Nov 28 15:11:21 2018 +0100
@@ -36,9 +36,9 @@
 
   sealed case class Entry(path: Path, html: Boolean = false)
   {
-    def bytes: Bytes = Bytes.read(path)
+    lazy val bytes: Bytes = Bytes.read(path)
+    lazy val font: Font = Font.createFont(Font.TRUETYPE_FONT, path.file)
 
-    lazy val font: Font = Font.createFont(Font.TRUETYPE_FONT, path.file)
     def family: String = font.getFamily
     def name: String = font.getFontName
     def style: Int =