www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit d26a67f220e7652d018fde37e3f0bd4779a0c0f8
parent 86115b8fce98c45911000009a5c39513626d0fd7
Author: Martin von Gagern <gagern@ma.tum.de>
Date:   Thu,  9 Jul 2015 17:25:35 +0200

Avoid non-determinisms related to font metric generation

We had some duplicate mappings in mappings to start with.  Now we have some
code to complain loudly about these, and all currently existing duplicates
have been dealt with.

We also had a problem where in some Python dict, existing stuff was using
strings as keys while new data would use numeric indices, thus not
overwriting the previous value.  Now we always use strings as keys.

Along the road, the italic dotless i and j symbols were changed
so that they now are taken from cmmi10 instead of cmti10.

Diffstat:
Mmetrics/extract_ttfs.py | 2+-
Mmetrics/mapping.pl | 25+++++++++++++------------
Msrc/fontMetricsData.json | 8++++----
3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/metrics/extract_ttfs.py b/metrics/extract_ttfs.py @@ -84,7 +84,7 @@ def main(): italic = 0 skew = 0 - start_json[font][ord(char)] = { + start_json[font][str(ord(char))] = { "height": height / fontInfo.em, "depth": depth / fontInfo.em, "italic": italic, diff --git a/metrics/mapping.pl b/metrics/mapping.pl @@ -135,8 +135,6 @@ $map{cmmi10} = { 0x2E => 0x25B9, # \triangleright 0x2F => 0x25C3, # \triangleleft - 0x3A => 0x2E, # . - 0x3B => 0x2C, # , 0x3C => 0x3C, # < 0x3D => 0x2215, # / 0x3E => 0x3E, # > @@ -148,16 +146,19 @@ $map{cmmi10} = { 0x5F => 0x2322, # \frown 0x60 => 0x2113, # \ell - 0x7B => 0x131, # \imath - 0x7C => 0x237, # \jmath 0x7D => 0x2118, # \wp 0x7E => [0x20D7,-653,0],# \vec + ], + + "Main-Italic" => [ + 0x7B => 0x131, # \imath + 0x7C => 0x237, # \jmath ] }; $map{cmsy10} = { "Main-Regular" => [ - [0,1] => 0x2212, # - + 0 => 0x2212, # - 1 => 0x22C5, # \cdot 2 => 0xD7, # \times 3 => 0x2217, # \ast @@ -425,8 +426,6 @@ $map{cmti10} = { [7,8] => 0x3A5, # \Upsilon, \Phi [9,0xA] => 0x3A8, # \Psi, \Omega - 0x10 => 0x131, # \imath (roman) - 0x11 => 0x237, # \jmath (roman) 0x12 => [0x300,-511,0], # \grave (combining) 0x13 => [0x301,-511,0], # \acute (combining) 0x14 => [0x30C,-511,0], # \check (combining) @@ -557,8 +556,6 @@ $map{cmmib10} = { 0x2E => 0x25B9, # \triangleright 0x2F => 0x25C3, # \triangleleft - 0x3A => 0x2E, # . - 0x3B => 0x2C, # , 0x3C => 0x3C, # < 0x3D => 0x2215, # / 0x3E => 0x3E, # > @@ -571,8 +568,6 @@ $map{cmmib10} = { 0x60 => 0x2113, # \ell 0x68 => 0x210F, # \hbar (bar added below) - 0x7B => 0x131, # \imath - 0x7C => 0x237, # \jmath 0x7D => 0x2118, # \wp 0x7E => [0x20D7,-729,0],# \vec ], @@ -580,7 +575,7 @@ $map{cmmib10} = { $map{cmbsy10} = { "Main-Bold" => [ - [0,1] => 0x2212, # - + 0 => 0x2212, # - 1 => 0x22C5, # \cdot 2 => 0xD7, # \times 3 => 0x2217, # \ast @@ -973,6 +968,12 @@ sub add_to_output { "yshift" => $yshift }; + if (defined($output{$mjfont}{$to})) { + print STDERR "Duplicate mapping $to for $mjfont: " . + $output{$mjfont}{$to}{font} . ":" . + $output{$mjfont}{$to}{char} . " vs. $cmfont:$from\n"; + die "Duplicate mapping!"; # disable this line to see all of them + } $output{$mjfont}{$to} = $data; } diff --git a/src/fontMetricsData.json b/src/fontMetricsData.json @@ -599,8 +599,8 @@ "122": {"depth": 0.0, "height": 0.43056, "italic": 0.12292, "skew": 0.0}, "126": {"depth": 0.35, "height": 0.31786, "italic": 0.11585, "skew": 0.0}, "163": {"depth": 0.0, "height": 0.69444, "italic": 0.0, "skew": 0.0}, - "305": {"depth": 0.0, "height": 0.43056, "italic": 0.07671, "skew": 0.0}, - "567": {"depth": 0.19444, "height": 0.43056, "italic": 0.03736, "skew": 0.0}, + "305": {"depth": 0.0, "height": 0.43056, "italic": 0.0, "skew": 0.02778}, + "567": {"depth": 0.19444, "height": 0.43056, "italic": 0.0, "skew": 0.08334}, "768": {"depth": 0.0, "height": 0.69444, "italic": 0.0, "skew": 0.0}, "769": {"depth": 0.0, "height": 0.69444, "italic": 0.09694, "skew": 0.0}, "770": {"depth": 0.0, "height": 0.69444, "italic": 0.06646, "skew": 0.0}, @@ -736,8 +736,8 @@ "180": {"depth": 0.0, "height": 0.69444, "italic": 0.0, "skew": 0.0}, "215": {"depth": 0.08333, "height": 0.58333, "italic": 0.0, "skew": 0.0}, "247": {"depth": 0.08333, "height": 0.58333, "italic": 0.0, "skew": 0.0}, - "305": {"depth": 0.0, "height": 0.43056, "italic": 0.0, "skew": 0.02778}, - "567": {"depth": 0.19444, "height": 0.43056, "italic": 0.0, "skew": 0.08334}, + "305": {"depth": 0.0, "height": 0.43056, "italic": 0.0, "skew": 0.0}, + "567": {"depth": 0.19444, "height": 0.43056, "italic": 0.0, "skew": 0.0}, "710": {"depth": 0.0, "height": 0.69444, "italic": 0.0, "skew": 0.0}, "711": {"depth": 0.0, "height": 0.62847, "italic": 0.0, "skew": 0.0}, "713": {"depth": 0.0, "height": 0.56778, "italic": 0.0, "skew": 0.0},