diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-19 12:59:39 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-19 12:59:39 +0200 |
| commit | 5a7c901f2195a746e0982723b959c07431844077 (patch) | |
| tree | 02058fb875cb87979fa930b5dc97a94b309459be | |
| parent | 3965e10281ea3c8754a1877c9f7e71c1930bf4c3 (diff) | |
Switch to New Computer Modern Math
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | NOTICE | 2 | ||||
| -rw-r--r-- | fonts/LatinModernMath.otf | bin | 733736 -> 0 bytes | |||
| -rw-r--r-- | fonts/NewCMMath-Regular.otf | bin | 0 -> 1229208 bytes | |||
| -rw-r--r-- | src/library/math/mod.rs | 2 | ||||
| -rw-r--r-- | src/library/math/rex.rs | 27 | ||||
| -rw-r--r-- | tests/ref/graphics/transform.png | bin | 56525 -> 56071 bytes | |||
| -rw-r--r-- | tests/ref/math/basic.png | bin | 5949 -> 6554 bytes | |||
| -rw-r--r-- | tests/ref/text/font.png | bin | 21070 -> 19390 bytes | |||
| -rw-r--r-- | tests/typ/graphics/transform.typ | 2 | ||||
| -rw-r--r-- | tests/typ/math/basic.typ | 4 | ||||
| -rw-r--r-- | tests/typ/text/font.typ | 5 |
12 files changed, 25 insertions, 19 deletions
@@ -862,7 +862,7 @@ dependencies = [ [[package]] name = "rex" version = "0.1.2" -source = "git+https://github.com/laurmaedje/ReX#b44e59bfa68cc4b0288bd2be80e093ed3b279af5" +source = "git+https://github.com/laurmaedje/ReX#7362b0cbb229211d6206198d80382a9b23eda993" dependencies = [ "font", "unicode-math", @@ -460,6 +460,8 @@ The GUST Font License Version 1.0 applies to: * Latin Modern fonts in fonts/LatinModern*.otf (http://www.gust.org.pl/projects/e-foundry/lm-math) +* NewComputerModern fonts in fonts/NewCM*.otf + % This is version 1.0, dated 22 June 2009, of the GUST Font License. % (GUST is the Polish TeX Users Group, http://www.gust.org.pl) % diff --git a/fonts/LatinModernMath.otf b/fonts/LatinModernMath.otf Binary files differdeleted file mode 100644 index 0e4642e9..00000000 --- a/fonts/LatinModernMath.otf +++ /dev/null diff --git a/fonts/NewCMMath-Regular.otf b/fonts/NewCMMath-Regular.otf Binary files differnew file mode 100644 index 00000000..82221fb8 --- /dev/null +++ b/fonts/NewCMMath-Regular.otf diff --git a/src/library/math/mod.rs b/src/library/math/mod.rs index ce41bd49..b1dabbe5 100644 --- a/src/library/math/mod.rs +++ b/src/library/math/mod.rs @@ -20,7 +20,7 @@ pub struct MathNode { impl MathNode { /// The math font family. #[property(referenced)] - pub const FAMILY: FontFamily = FontFamily::new("Latin Modern Math"); + pub const FAMILY: FontFamily = FontFamily::new("NewComputerModernMath"); /// The spacing above display math. #[property(resolve, shorthand(around))] pub const ABOVE: Option<BlockSpacing> = Some(Ratio::one().into()); diff --git a/src/library/math/rex.rs b/src/library/math/rex.rs index 43e2c015..addf56b6 100644 --- a/src/library/math/rex.rs +++ b/src/library/math/rex.rs @@ -1,8 +1,8 @@ +use rex::error::{Error, LayoutError}; use rex::font::{FontContext, MathFont}; use rex::layout::{LayoutSettings, Style}; use rex::parser::color::RGBA; use rex::render::{Backend, Cursor, Renderer}; -use rex::error::{Error, LayoutError}; use crate::font::FaceId; use crate::library::prelude::*; @@ -27,30 +27,33 @@ impl Layout for RexNode { styles: StyleChain, ) -> TypResult<Vec<Arc<Frame>>> { // Load the font. - let face_id = match ctx.fonts.select(self.family.as_str(), variant(styles)) { - Some(id) => id, - None => return Ok(vec![]), - }; + let span = self.tex.span; + let face_id = ctx + .fonts + .select(self.family.as_str(), variant(styles)) + .ok_or("failed to find math font") + .at(span)?; // Prepare the font. let data = ctx.fonts.get(face_id).buffer(); - let font = match MathFont::parse(data) { - Ok(font) => font, - Err(_) => return Ok(vec![]), - }; + let font = MathFont::parse(data) + .map_err(|_| "failed to parse math font") + .at(span)?; + + let ctx = FontContext::new(&font).ok_or("failed to parse math font").at(span)?; // Layout the formula. - let ctx = FontContext::new(&font); let em = styles.get(TextNode::SIZE); let style = if self.display { Style::Display } else { Style::Text }; let settings = LayoutSettings::new(&ctx, em.to_pt(), style); let renderer = Renderer::new(); - let layout = renderer.layout(&self.tex.v, settings) + let layout = renderer + .layout(&self.tex.v, settings) .map_err(|err| match err { Error::Parse(err) => err.to_string(), Error::Layout(LayoutError::Font(err)) => err.to_string(), }) - .at(self.tex.span)?; + .at(span)?; // Determine the metrics. let (x0, y0, x1, y1) = renderer.size(&layout); diff --git a/tests/ref/graphics/transform.png b/tests/ref/graphics/transform.png Binary files differindex 65d94758..1cb8efcd 100644 --- a/tests/ref/graphics/transform.png +++ b/tests/ref/graphics/transform.png diff --git a/tests/ref/math/basic.png b/tests/ref/math/basic.png Binary files differindex 42723bc5..ce959662 100644 --- a/tests/ref/math/basic.png +++ b/tests/ref/math/basic.png diff --git a/tests/ref/text/font.png b/tests/ref/text/font.png Binary files differindex cce4897b..65badc0a 100644 --- a/tests/ref/text/font.png +++ b/tests/ref/text/font.png diff --git a/tests/typ/graphics/transform.typ b/tests/typ/graphics/transform.typ index 5d2a1729..2dde626b 100644 --- a/tests/typ/graphics/transform.typ +++ b/tests/typ/graphics/transform.typ @@ -23,7 +23,7 @@ [X] } -#set text("Latin Modern Math", size) +#set text("Latin Modern Roman", size) Neither #tex, \ nor #xetex! diff --git a/tests/typ/math/basic.typ b/tests/typ/math/basic.typ index 33246261..051dbaf3 100644 --- a/tests/typ/math/basic.typ +++ b/tests/typ/math/basic.typ @@ -12,6 +12,10 @@ Prove by induction: $[ \sum_{k=0}^n k = \frac{n(n+1)}{2} ]$ --- +// Test that blackboard style looks nice. +$[ f: \mathbb{N} \rightarrow \mathbb{R} ]$ + +--- // Error: 1-10 expected '}' found EOF $\sqrt{x$ diff --git a/tests/typ/text/font.typ b/tests/typ/text/font.typ index bfec3e1c..e57fedbd 100644 --- a/tests/typ/text/font.typ +++ b/tests/typ/text/font.typ @@ -24,9 +24,6 @@ // Emoji. Emoji: 🐪, 🌋, 🏞 -// Math. -#text("Latin Modern Math")[∫ 𝛼 + 3𝛽 d𝑡] - // Colors. [ #set text(fill: eastern) @@ -34,7 +31,7 @@ Emoji: 🐪, 🌋, 🏞 ] // Disable font fallback beyond the user-specified list. -// Without disabling, Latin Modern Math would come to the rescue. +// Without disabling, NewComputerModernMath would come to the rescue. #set text("PT Sans", "Twitter Color Emoji", fallback: false) 2π = 𝛼 + 𝛽. ✅ |
