summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-19 12:59:39 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-19 12:59:39 +0200
commit5a7c901f2195a746e0982723b959c07431844077 (patch)
tree02058fb875cb87979fa930b5dc97a94b309459be
parent3965e10281ea3c8754a1877c9f7e71c1930bf4c3 (diff)
Switch to New Computer Modern Math
-rw-r--r--Cargo.lock2
-rw-r--r--NOTICE2
-rw-r--r--fonts/LatinModernMath.otfbin733736 -> 0 bytes
-rw-r--r--fonts/NewCMMath-Regular.otfbin0 -> 1229208 bytes
-rw-r--r--src/library/math/mod.rs2
-rw-r--r--src/library/math/rex.rs27
-rw-r--r--tests/ref/graphics/transform.pngbin56525 -> 56071 bytes
-rw-r--r--tests/ref/math/basic.pngbin5949 -> 6554 bytes
-rw-r--r--tests/ref/text/font.pngbin21070 -> 19390 bytes
-rw-r--r--tests/typ/graphics/transform.typ2
-rw-r--r--tests/typ/math/basic.typ4
-rw-r--r--tests/typ/text/font.typ5
12 files changed, 25 insertions, 19 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 1472a2a0..fef4b844 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -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",
diff --git a/NOTICE b/NOTICE
index 05f36189..4444cccd 100644
--- a/NOTICE
+++ b/NOTICE
@@ -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
deleted file mode 100644
index 0e4642e9..00000000
--- a/fonts/LatinModernMath.otf
+++ /dev/null
Binary files differ
diff --git a/fonts/NewCMMath-Regular.otf b/fonts/NewCMMath-Regular.otf
new file mode 100644
index 00000000..82221fb8
--- /dev/null
+++ b/fonts/NewCMMath-Regular.otf
Binary files differ
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
index 65d94758..1cb8efcd 100644
--- a/tests/ref/graphics/transform.png
+++ b/tests/ref/graphics/transform.png
Binary files differ
diff --git a/tests/ref/math/basic.png b/tests/ref/math/basic.png
index 42723bc5..ce959662 100644
--- a/tests/ref/math/basic.png
+++ b/tests/ref/math/basic.png
Binary files differ
diff --git a/tests/ref/text/font.png b/tests/ref/text/font.png
index cce4897b..65badc0a 100644
--- a/tests/ref/text/font.png
+++ b/tests/ref/text/font.png
Binary files differ
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π = 𝛼 + 𝛽. ✅