auto-hinting of original DejaVu fonts, but not Isabelle symbols;
authorwenzelm
Sun Feb 10 18:04:48 2019 +0100 (9 days ago)
changeset 697954791988fcbc4
parent 69794 a19fdf64726c
child 69796 04c50000fad1
auto-hinting of original DejaVu fonts, but not Isabelle symbols;
src/Pure/Admin/build_fonts.scala
     1.1 --- a/src/Pure/Admin/build_fonts.scala	Fri Feb 08 14:42:28 2019 +0100
     1.2 +++ b/src/Pure/Admin/build_fonts.scala	Sun Feb 10 18:04:48 2019 +0100
     1.3 @@ -172,6 +172,17 @@
     1.4    }
     1.5  
     1.6  
     1.7 +  /* auto-hinting */
     1.8 +  // see https://www.freetype.org/ttfautohint/doc/ttfautohint.html
     1.9 +
    1.10 +  def auto_hint(source: Path, target: Path)
    1.11 +  {
    1.12 +    Isabelle_System.bash("ttfautohint -i " +
    1.13 +      File.bash_path(source) + " " + File.bash_path(target)).check
    1.14 +  }
    1.15 +
    1.16 +
    1.17 +
    1.18    /* build fonts */
    1.19  
    1.20    private def find_file(dirs: List[Path], name: String): Path =
    1.21 @@ -220,24 +231,29 @@
    1.22          val target_file = target_dir + target_names.ttf
    1.23  
    1.24          progress.echo("Font " + target_file.toString + " ...")
    1.25 -        Fontforge.execute(
    1.26 -          Fontforge.commands(
    1.27 -            Fontforge.open(isabelle_file),
    1.28 -            Fontforge.select(Range.isabelle_font),
    1.29 -            Fontforge.copy,
    1.30 -            Fontforge.close,
    1.31 +        Isabelle_System.with_tmp_file("font", "ttf")(tmp_file =>
    1.32 +        {
    1.33 +          auto_hint(source_file, tmp_file)
    1.34  
    1.35 -            Fontforge.open(source_file),
    1.36 -            Fontforge.select(Range.base_font),
    1.37 -            Fontforge.select_invert,
    1.38 -            Fontforge.clear,
    1.39 -            Fontforge.select(Range.isabelle_font),
    1.40 -            Fontforge.paste,
    1.41 +          Fontforge.execute(
    1.42 +            Fontforge.commands(
    1.43 +              Fontforge.open(isabelle_file),
    1.44 +              Fontforge.select(Range.isabelle_font),
    1.45 +              Fontforge.copy,
    1.46 +              Fontforge.close,
    1.47  
    1.48 -            target_names.set,
    1.49 -            Fontforge.generate(target_file),
    1.50 -            Fontforge.close)
    1.51 -        ).check
    1.52 +              Fontforge.open(tmp_file),
    1.53 +              Fontforge.select(Range.base_font),
    1.54 +              Fontforge.select_invert,
    1.55 +              Fontforge.clear,
    1.56 +              Fontforge.select(Range.isabelle_font),
    1.57 +              Fontforge.paste,
    1.58 +
    1.59 +              target_names.set,
    1.60 +              Fontforge.generate(target_file),
    1.61 +              Fontforge.close)
    1.62 +          ).check
    1.63 +        })
    1.64  
    1.65          (target_file, index)
    1.66        }