New default fonts

This commit is contained in:
Laurenz 2021-09-30 22:46:03 +02:00
parent 30f302f7ff
commit 2818ceee44
78 changed files with 58 additions and 54 deletions

13
NOTICE
View File

@ -3,13 +3,14 @@ Licenses for third party components used by this project can be found below.
================================================================================
The SIL Open Font License Version 1.1 applies to:
* EB Garamond fonts in fonts/EBGaramond-*.ttf
Copyright 2017 The EB Garamond Project Authors
(https://github.com/octaviopardo/EBGaramond12)
* IBM Plex fonts in fonts/IBMPlex-*.ttf
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
(https://github.com/IBM/plex)
* Inconsolata fonts in fonts/Inconsolata-*.ttf
Copyright 2006 The Inconsolata Project Authors
(https://github.com/cyrealtype/Inconsolata)
* Noto fonts in fonts/Noto-*.ttf
Copyright 2018 The Noto Project Authors
(https://github.com/googlefonts/noto-fonts)
(https://github.com/googlefonts/noto-cjk)
* PT Sans fonts in fonts/PTSans-*.ttf
Copyright (c) 2010, ParaType Ltd. (http://www.paratype.com/public),

View File

@ -10,14 +10,12 @@ use typst::source::{SourceFile, SourceId};
use typst::Context;
const SRC: &str = include_str!("bench.typ");
const FONT: &[u8] = include_bytes!("../fonts/IBMPlexSans-Regular.ttf");
fn context() -> (Context, SourceId) {
let font = include_bytes!("../fonts/EBGaramond-Regular.ttf");
let loader = MemLoader::new()
.with(Path::new("EBGaramond-Regular.ttf"), &font[..])
.wrap();
let loader = MemLoader::new().with(Path::new("font.ttf"), FONT).wrap();
let mut ctx = Context::new(loader);
let id = ctx.sources.provide(Path::new(""), SRC.to_string());
let id = ctx.sources.provide(Path::new("src.typ"), SRC.to_string());
(ctx, id)
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
fonts/IBMPlexSans-Bold.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -110,8 +110,8 @@ pub struct ParState {
impl Default for ParState {
fn default() -> Self {
Self {
par_spacing: Relative::new(1.0).into(),
line_spacing: Relative::new(0.5).into(),
par_spacing: Relative::new(1.2).into(),
line_spacing: Relative::new(0.65).into(),
}
}
}
@ -235,12 +235,12 @@ pub struct FamilyState {
impl Default for FamilyState {
fn default() -> Self {
Self {
list: Rc::new(vec![FontFamily::Serif]),
serif: Rc::new(vec!["eb garamond".into()]),
sans_serif: Rc::new(vec!["pt sans".into()]),
monospace: Rc::new(vec!["inconsolata".into()]),
list: Rc::new(vec![FontFamily::SansSerif]),
serif: Rc::new(vec!["ibm plex serif".into()]),
sans_serif: Rc::new(vec!["ibm plex sans".into()]),
monospace: Rc::new(vec!["ibm plex mono".into()]),
base: Rc::new(vec![
"eb garamond".into(),
"ibm plex sans".into(),
"latin modern math".into(),
"twitter color emoji".into(),
]),

View File

@ -157,12 +157,12 @@ mod tests {
paths.sort();
assert_eq!(paths, [
Path::new("fonts/EBGaramond-Bold.ttf"),
Path::new("fonts/EBGaramond-BoldItalic.ttf"),
Path::new("fonts/EBGaramond-Italic.ttf"),
Path::new("fonts/EBGaramond-Regular.ttf"),
Path::new("fonts/Inconsolata-Bold.ttf"),
Path::new("fonts/Inconsolata-Regular.ttf"),
Path::new("fonts/IBMPlexMono-Regular.ttf"),
Path::new("fonts/IBMPlexSans-Bold.ttf"),
Path::new("fonts/IBMPlexSans-BoldItalic.ttf"),
Path::new("fonts/IBMPlexSans-Italic.ttf"),
Path::new("fonts/IBMPlexSans-Regular.ttf"),
Path::new("fonts/IBMPlexSerif-Regular.ttf"),
Path::new("fonts/LatinModernMath.otf"),
Path::new("fonts/NotoSansArabic-Regular.ttf"),
Path::new("fonts/NotoSerifCJKsc-Regular.otf"),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 B

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 593 B

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

After

Width:  |  Height:  |  Size: 805 B

View File

@ -14,10 +14,10 @@
]
// Block body.
// Should output `[1st, 2nd, 3rd, 4th, 5th]`.
// Should output `[1st, 2nd, 3rd, 4th]`.
{
"["
for v in (1, 2, 3, 4, 5) {
for v in (1, 2, 3, 4) {
if v > 1 [, ]
[#v]
if v == 1 [st]

View File

@ -1,6 +1,8 @@
// Test include statements.
---
#page(width: 200pt)
= Document
// Include a file

View File

@ -5,9 +5,9 @@
#grid(
columns: 2,
gutter-rows: 3 * (8pt,),
[Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
[Lorem ipsum dolor sit amet.
Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis.],
Aenean commodo ligula eget dolor. Aenean massa. Penatibus et magnis.],
[Text that is rather short],
[Fireflies],
[Critical],
@ -71,7 +71,7 @@
[foo],
rect(height: 100%, width: 100%, fill: rgb("fc0030"))[Still no height],
[bar],
[The nature of being itself is in question. Am I One? Am I Many? What is being alive?],
[The nature of being itself is in question. Am I One? What is being alive?],
[baz],
[The answer],
[42],

View File

@ -25,4 +25,4 @@ L #align(right)[R] \ L
---
// FIXME: There should be a line break opportunity on alignment change.
LLLLLLLLLLLLL#align(center)[CCCC]
LLLLLLLLLLLLLLLLL#align(center)[CCCC]

View File

@ -1,7 +1,7 @@
// Test simple text.
---
#page(width: 250pt, height: 110pt)
#page(width: 250pt, height: 120pt)
But, soft! what light through yonder window breaks? It is the east, and Juliet
is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and

View File

@ -3,7 +3,7 @@
---
// Test reordering with different top-level paragraph directions.
#let text = [Text טֶקסט]
#font("EB Garamond", "Noto Serif Hebrew")
#font(serif, "Noto Serif Hebrew")
#lang("he") {text}
#lang("de") {text}
@ -11,7 +11,7 @@
// Test that consecutive, embedded LTR runs stay LTR.
// Here, we have two runs: "A" and italic "B".
#let text = [أنت A_B_مطرC]
#font("EB Garamond", "Noto Sans Arabic")
#font(serif, "Noto Sans Arabic")
#lang("ar") {text}
#lang("de") {text}
@ -19,32 +19,32 @@
// Test that consecutive, embedded RTL runs stay RTL.
// Here, we have three runs: "גֶ", bold "שֶׁ", and "ם".
#let text = [Aגֶ*שֶׁ*םB]
#font("EB Garamond", "Noto Serif Hebrew")
#font(serif, "Noto Serif Hebrew")
#lang("he") {text}
#lang("de") {text}
---
// Test embedding up to level 4 with isolates.
#font("EB Garamond", "Noto Serif Hebrew", "Twitter Color Emoji")
#font(serif, "Noto Serif Hebrew", "Twitter Color Emoji")
#lang(dir: rtl)
א\u{2066}A\u{2067}Bב\u{2069}?
---
// Test hard line break (leads to two paragraphs in unicode-bidi).
#font("Noto Sans Arabic", "EB Garamond")
#font("Noto Sans Arabic", serif)
#lang("ar")
Life المطر هو الحياة \
الحياة تمطر is rain.
---
// Test spacing.
#font("EB Garamond", "Noto Serif Hebrew")
#font(serif, "Noto Serif Hebrew")
L #h(1cm) ריווחR \
יווח #h(1cm) R
---
// Test inline object.
#font("Noto Serif Hebrew", "EB Garamond")
#font("Noto Serif Hebrew", serif)
#lang("he")
קרנפיםRh#image("../../res/rhino.png", height: 11pt)inoחיים

View File

@ -2,9 +2,9 @@
---
// Set same font size in three different ways.
#font(22pt)[A]
#font(20pt)[A]
#font(200%)[A]
#font(size: 16.5pt + 50%)[A]
#font(size: 15pt + 50%)[A]
// Do nothing.
#font()[Normal]
@ -19,7 +19,7 @@
#font(stretch: 50%)[Condensed]
// Set family.
#font(family: "PT Sans")[Sans serif]
#font(family: serif)[Serif]
// Emoji.
Emoji: 🐪, 🌋, 🏞
@ -48,7 +48,9 @@ Emoji: 🐪, 🌋, 🏞
---
// Test top and bottom edge.
#page(width: 170pt)
#page(width: 150pt)
#font(size: 8pt)
#let try(top, bottom) = rect(fill: conifer)[
#font(top-edge: top, bottom-edge: bottom)
`From `#top` to `#bottom

View File

@ -2,7 +2,7 @@
---
// Test overlong word that is not directly after a hard break.
This is a spaceexceedinglylongishy.
This is a spaceexceedinglylongy.
---
// Test two overlong words in a row.
@ -10,7 +10,7 @@ Supercalifragilisticexpialidocious Expialigoricmetrioxidation.
---
// Test that there are no unwanted line break opportunities on run change.
This is partly emph_as_ized.
This is partly emp_has_ized.
---
Hard \ break.

View File

@ -1,7 +1,8 @@
// Test configuring paragraph properties.
---
#par(spacing: 10pt, leading: 25%)
#par(spacing: 100%, leading: 0pt)
But, soft! what light through yonder window breaks? It is the east, and Juliet
is the sun.
But, soft! what light through yonder window breaks?
It is the east, and Juliet is the sun.

View File

@ -20,7 +20,7 @@ Le fira
---
// Test font fallback.
#font("EB Garamond", "Noto Sans Arabic", "Twitter Color Emoji")
#font(sans-serif, "Noto Sans Arabic", "Twitter Color Emoji")
// Font fallback for emoji.
A😀B

View File

@ -30,11 +30,11 @@ A #for _ in (none,) {"B"}C
---
// Test that a run consisting only of whitespace isn't trimmed.
A[#font("PT Sans") ]B
A[#font(serif) ]B
---
// Test font change after space.
Left [#font("PT Sans")Right].
Left [#font(serif)Right].
---
// Test that space at start of line is not trimmed.
@ -42,4 +42,4 @@ A{"\n"} B
---
// Test that trailing space does not force a line break.
LLLLLLLLLLLLLL R _L_
LLLLLLLLLLLLLLLLLL R _L_

View File

@ -62,9 +62,9 @@ fn main() {
// We want to have "unbounded" pages, so we allow them to be infinitely
// large and fit them to match their content.
let mut state = State::default();
let page = state.page_mut();
page.size = Size::new(Length::pt(120.0), Length::inf());
page.margins = Sides::splat(Some(Length::pt(10.0).into()));
state.page_mut().size = Size::new(Length::pt(120.0), Length::inf());
state.page_mut().margins = Sides::splat(Some(Length::pt(10.0).into()));
state.font_mut().size = Length::pt(10.0);
// Hook up an assert function into the global scope.
let mut std = typst::library::new();