summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock64
-rw-r--r--Cargo.toml2
-rw-r--r--src/export/pdf/font.rs5
-rw-r--r--src/font/book.rs5
-rw-r--r--src/font/mod.rs31
-rw-r--r--src/library/text/mod.rs2
-rw-r--r--src/library/text/shaping.rs4
-rw-r--r--tests/ref/text/par.pngbin30131 -> 29339 bytes
-rw-r--r--tests/typ/text/par.typ2
9 files changed, 65 insertions, 50 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 898df1d6..7e45525f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -196,12 +196,11 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
-version = "0.8.11"
+version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
+checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
dependencies = [
"cfg-if",
- "once_cell",
]
[[package]]
@@ -369,23 +368,22 @@ dependencies = [
[[package]]
name = "iana-time-zone"
-version = "0.1.48"
+version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "237a0714f28b1ee39ccec0770ccb544eb02c9ef2c82bb096230eefcffa6468b0"
+checksum = "fd911b35d940d2bd0bea0f9100068e5b97b51a1cbe13d13382f132e0365257a0"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"js-sys",
- "once_cell",
"wasm-bindgen",
"winapi",
]
[[package]]
name = "image"
-version = "0.24.3"
+version = "0.24.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
+checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c"
dependencies = [
"bytemuck",
"byteorder",
@@ -503,9 +501,9 @@ dependencies = [
[[package]]
name = "libc"
-version = "0.2.132"
+version = "0.2.134"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
+checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb"
[[package]]
name = "lipsum"
@@ -628,9 +626,9 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.14.0"
+version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
+checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]]
name = "pdf-writer"
@@ -652,9 +650,9 @@ checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468"
[[package]]
name = "pixglyph"
version = "0.1.0"
-source = "git+https://github.com/typst/pixglyph#f1aae13ae622f4640a1cfac231525f02978fc305"
+source = "git+https://github.com/typst/pixglyph#131ea492ceada591c7e2d6dd2a5958ae325bd0d4"
dependencies = [
- "ttf-parser",
+ "ttf-parser 0.17.0",
]
[[package]]
@@ -677,9 +675,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "proc-macro2"
-version = "1.0.43"
+version = "1.0.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
+checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
dependencies = [
"unicode-ident",
]
@@ -787,11 +785,11 @@ dependencies = [
[[package]]
name = "rex"
version = "0.1.2"
-source = "git+https://github.com/laurmaedje/ReX#6e4bada20d2b1685940e2d752630cb9ad3d797b0"
+source = "git+https://github.com/laurmaedje/ReX#672c321a947f945e9ba936ae9fbd982c4e043f1c"
dependencies = [
"itertools",
"nom",
- "ttf-parser",
+ "ttf-parser 0.17.0",
"unicode-math",
]
@@ -822,7 +820,7 @@ dependencies = [
"bitflags",
"bytemuck",
"smallvec",
- "ttf-parser",
+ "ttf-parser 0.15.2",
"unicode-bidi-mirroring",
"unicode-ccc",
"unicode-general-category",
@@ -855,18 +853,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.144"
+version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
+checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.144"
+version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
+checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
dependencies = [
"proc-macro2",
"quote",
@@ -945,9 +943,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.100"
+version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "52205623b1b0f064a4e71182c3b18ae902267282930c6d5462c91b859668426e"
+checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2"
dependencies = [
"proc-macro2",
"quote",
@@ -986,18 +984,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.35"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c53f98874615aea268107765aa1ed8f6116782501d18e53d08b471733bea6c85"
+checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.35"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8b463991b4eab2d801e724172285ec4195c650e8ec79b149e6c2a8e6dd3f783"
+checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
@@ -1025,6 +1023,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
[[package]]
+name = "ttf-parser"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9146d2aaf37dc5334287712849dfbf6aecfbd97971f2e8d86c5e50ea550d71ae"
+
+[[package]]
name = "typed-arena"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1069,7 +1073,7 @@ dependencies = [
"svg2pdf",
"syntect",
"tiny-skia",
- "ttf-parser",
+ "ttf-parser 0.17.0",
"typed-arena",
"typst-macros",
"unicode-bidi",
diff --git a/Cargo.toml b/Cargo.toml
index 79ec772c..aa63a4a7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,7 @@ comemo = { git = "https://github.com/typst/comemo" }
# Text and font handling
hypher = "0.1"
kurbo = "0.8"
-ttf-parser = "0.15"
+ttf-parser = "0.17"
rustybuzz = "0.5"
unicode-bidi = "0.3.5"
unicode-segmentation = "1"
diff --git a/src/export/pdf/font.rs b/src/export/pdf/font.rs
index 446d36bc..3398478a 100644
--- a/src/export/pdf/font.rs
+++ b/src/export/pdf/font.rs
@@ -45,8 +45,9 @@ pub fn write_fonts(ctx: &mut PdfContext) {
// Check for the presence of CFF outlines to select the correct
// CID-Font subtype.
let subtype = match ttf
- .table_data(Tag::from_bytes(b"CFF "))
- .or(ttf.table_data(Tag::from_bytes(b"CFF2")))
+ .raw_face()
+ .table(Tag::from_bytes(b"CFF "))
+ .or(ttf.raw_face().table(Tag::from_bytes(b"CFF2")))
{
Some(_) => CidFontType::Type0,
None => CidFontType::Type2,
diff --git a/src/font/book.rs b/src/font/book.rs
index 29190516..d900d3c4 100644
--- a/src/font/book.rs
+++ b/src/font/book.rs
@@ -173,7 +173,7 @@ impl FontInfo {
pub fn from_data<'a>(data: &'a [u8]) -> impl Iterator<Item = FontInfo> + 'a {
let count = ttf_parser::fonts_in_collection(data).unwrap_or(1);
(0 .. count).filter_map(move |index| {
- let ttf = ttf_parser::Face::from_slice(data, index).ok()?;
+ let ttf = ttf_parser::Face::parse(data, index).ok()?;
Self::from_ttf(&ttf)
})
}
@@ -239,7 +239,8 @@ impl FontInfo {
// Determine whether this is a serif or sans-serif font.
if let Some(panose) = ttf
- .table_data(Tag::from_bytes(b"OS/2"))
+ .raw_face()
+ .table(Tag::from_bytes(b"OS/2"))
.and_then(|os2| os2.get(32 .. 45))
{
if matches!(panose, [2, 2 ..= 10, ..]) {
diff --git a/src/font/mod.rs b/src/font/mod.rs
index 2404ad32..7cddf1ea 100644
--- a/src/font/mod.rs
+++ b/src/font/mod.rs
@@ -10,7 +10,7 @@ use std::fmt::{self, Debug, Formatter};
use std::hash::{Hash, Hasher};
use std::sync::Arc;
-use once_cell::sync::OnceCell;
+use once_cell::unsync::OnceCell;
use rex::font::MathHeader;
use ttf_parser::{GlyphId, Tag};
@@ -33,8 +33,10 @@ struct Repr {
info: FontInfo,
/// The font's metrics.
metrics: FontMetrics,
- /// The underlying ttf-parser/rustybuzz face.
- ttf: rustybuzz::Face<'static>,
+ /// The underlying ttf-parser face.
+ ttf: ttf_parser::Face<'static>,
+ /// The underlying rustybuzz face.
+ rusty: rustybuzz::Face<'static>,
/// The parsed ReX math header.
math: OnceCell<Option<MathHeader>>,
}
@@ -51,7 +53,8 @@ impl Font {
let slice: &'static [u8] =
unsafe { std::slice::from_raw_parts(data.as_ptr(), data.len()) };
- let ttf = rustybuzz::Face::from_slice(slice, index)?;
+ let ttf = ttf_parser::Face::parse(slice, index).ok()?;
+ let rusty = rustybuzz::Face::from_slice(slice, index)?;
let metrics = FontMetrics::from_ttf(&ttf);
let info = FontInfo::from_ttf(&ttf)?;
@@ -59,8 +62,9 @@ impl Font {
data,
index,
info,
- ttf,
metrics,
+ ttf,
+ rusty,
math: OnceCell::new(),
})))
}
@@ -108,19 +112,26 @@ impl Font {
find_name(&self.0.ttf, id)
}
- /// A reference to the underlying `ttf-parser` / `rustybuzz` face.
- pub fn ttf(&self) -> &rustybuzz::Face<'_> {
- // We can't implement Deref because that would leak the internal 'static
- // lifetime.
+ /// A reference to the underlying `ttf-parser` face.
+ pub fn ttf(&self) -> &ttf_parser::Face<'_> {
+ // We can't implement Deref because that would leak the
+ // internal 'static lifetime.
&self.0.ttf
}
+ /// A reference to the underlying `rustybuzz` face.
+ pub fn rusty(&self) -> &rustybuzz::Face<'_> {
+ // We can't implement Deref because that would leak the
+ // internal 'static lifetime.
+ &self.0.rusty
+ }
+
/// Access the math header, if any.
pub fn math(&self) -> Option<&MathHeader> {
self.0
.math
.get_or_init(|| {
- let data = self.ttf().table_data(Tag::from_bytes(b"MATH"))?;
+ let data = self.ttf().raw_face().table(Tag::from_bytes(b"MATH"))?;
MathHeader::parse(data).ok()
})
.as_ref()
diff --git a/src/library/text/mod.rs b/src/library/text/mod.rs
index 934f5e15..c9bf2e57 100644
--- a/src/library/text/mod.rs
+++ b/src/library/text/mod.rs
@@ -22,7 +22,7 @@ pub use shift::*;
use std::borrow::Cow;
-use ttf_parser::Tag;
+use rustybuzz::Tag;
use crate::font::{FontMetrics, FontStretch, FontStyle, FontWeight, VerticalFontMetric};
use crate::library::prelude::*;
diff --git a/src/library/text/shaping.rs b/src/library/text/shaping.rs
index 16989acf..487b9090 100644
--- a/src/library/text/shaping.rs
+++ b/src/library/text/shaping.rs
@@ -1,7 +1,7 @@
use std::ops::Range;
use std::str::FromStr;
-use rustybuzz::{Feature, UnicodeBuffer};
+use rustybuzz::{Feature, Tag, UnicodeBuffer};
use super::*;
use crate::font::{Font, FontVariant};
@@ -407,7 +407,7 @@ fn shape_segment<'a>(
});
// Shape!
- let buffer = rustybuzz::shape(font.ttf(), &ctx.tags, buffer);
+ let buffer = rustybuzz::shape(font.rusty(), &ctx.tags, buffer);
let infos = buffer.glyph_infos();
let pos = buffer.glyph_positions();
diff --git a/tests/ref/text/par.png b/tests/ref/text/par.png
index 471437a0..16622cc2 100644
--- a/tests/ref/text/par.png
+++ b/tests/ref/text/par.png
Binary files differ
diff --git a/tests/typ/text/par.typ b/tests/typ/text/par.typ
index 3c465ca8..08202ef5 100644
--- a/tests/typ/text/par.typ
+++ b/tests/typ/text/par.typ
@@ -39,8 +39,6 @@ Hello
fn main() {}
```
-$ x + y = z $
-
- List
Paragraph