mirror of
https://github.com/typst/typst
synced 2025-08-24 19:54:14 +08:00
Compare commits
6 Commits
87cb8f5094
...
70399a94fd
Author | SHA1 | Date | |
---|---|---|---|
|
70399a94fd | ||
|
d4be7c4ca5 | ||
|
f162c37101 | ||
|
87c5686560 | ||
|
899de6d5d5 | ||
|
24293a6c12 |
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -786,9 +786,9 @@ checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "font-types"
|
name = "font-types"
|
||||||
version = "0.8.4"
|
version = "0.9.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fa6a5e5a77b5f3f7f9e32879f484aa5b3632ddfbe568a16266c904a6f32cdaf"
|
checksum = "02a596f5713680923a2080d86de50fe472fb290693cf0f701187a1c8b36996b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
@ -1367,8 +1367,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla"
|
name = "krilla"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/LaurenzV/krilla?rev=20c14fe#20c14fefee5002566b3d6668b338bbe2168784e7"
|
||||||
checksum = "69ee6128ebf52d7ce684613b6431ead2959f2be9ff8cf776eeaaad0427c953e9"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
@ -1396,8 +1395,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla-svg"
|
name = "krilla-svg"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/LaurenzV/krilla?rev=20c14fe#20c14fefee5002566b3d6668b338bbe2168784e7"
|
||||||
checksum = "3462989578155cf620ef8035f8921533cc95c28e2a0c75de172f7219e6aba84e"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
@ -2106,9 +2104,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "read-fonts"
|
name = "read-fonts"
|
||||||
version = "0.28.0"
|
version = "0.30.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "600e807b48ac55bad68a8cb75cc3c7739f139b9248f7e003e01e080f589b5288"
|
checksum = "192735ef611aac958468e670cb98432c925426f3cb71521fda202130f7388d91"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"font-types",
|
"font-types",
|
||||||
@ -2434,9 +2432,9 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "skrifa"
|
name = "skrifa"
|
||||||
version = "0.30.0"
|
version = "0.32.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fa1e5622e4f7b98877e8a19890efddcac1230cec6198bd9de91ec0e00010dc8"
|
checksum = "e6d632b5a73f566303dbeabd344dc3e716fd4ddc9a70d6fc8ea8e6f06617da97"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"read-fonts",
|
"read-fonts",
|
||||||
|
@ -73,8 +73,8 @@ image = { version = "0.25.5", default-features = false, features = ["png", "jpeg
|
|||||||
indexmap = { version = "2", features = ["serde"] }
|
indexmap = { version = "2", features = ["serde"] }
|
||||||
infer = { version = "0.19.0", default-features = false }
|
infer = { version = "0.19.0", default-features = false }
|
||||||
kamadak-exif = "0.6"
|
kamadak-exif = "0.6"
|
||||||
krilla = { version = "0.4.0", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
krilla = { git = "https://github.com/LaurenzV/krilla", rev = "20c14fe", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
||||||
krilla-svg = "0.1.0"
|
krilla-svg = { git = "https://github.com/LaurenzV/krilla", rev = "20c14fe" }
|
||||||
kurbo = "0.11"
|
kurbo = "0.11"
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
lipsum = "0.9"
|
lipsum = "0.9"
|
||||||
|
@ -148,7 +148,7 @@ pub struct Library {
|
|||||||
/// The default style properties (for page size, font selection, and
|
/// The default style properties (for page size, font selection, and
|
||||||
/// everything else configurable via set and show rules).
|
/// everything else configurable via set and show rules).
|
||||||
pub styles: Styles,
|
pub styles: Styles,
|
||||||
/// The standard library as a value. Used to provide the `std` variable.
|
/// The standard library as a value. Used to provide the `std` module.
|
||||||
pub std: Binding,
|
pub std: Binding,
|
||||||
/// In-development features that were enabled.
|
/// In-development features that were enabled.
|
||||||
pub features: Features,
|
pub features: Features,
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
|
use icu_properties::maps::CodePointMapData;
|
||||||
|
use icu_properties::CanonicalCombiningClass;
|
||||||
|
use icu_provider::AsDeserializingBufferProvider;
|
||||||
|
use icu_provider_blob::BlobDataProvider;
|
||||||
|
|
||||||
use crate::diag::bail;
|
use crate::diag::bail;
|
||||||
use crate::foundations::{cast, elem, func, Content, NativeElement, SymbolElem};
|
use crate::foundations::{cast, elem, func, Content, NativeElement, SymbolElem};
|
||||||
use crate::layout::{Length, Rel};
|
use crate::layout::{Length, Rel};
|
||||||
@ -81,17 +88,22 @@ impl Accent {
|
|||||||
Self(Self::combine(c).unwrap_or(c))
|
Self(Self::combine(c).unwrap_or(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of bottom accents. Currently just a list of ones included in the
|
|
||||||
/// Unicode math class document.
|
|
||||||
const BOTTOM: &[char] = &[
|
|
||||||
'\u{0323}', '\u{032C}', '\u{032D}', '\u{032E}', '\u{032F}', '\u{0330}',
|
|
||||||
'\u{0331}', '\u{0332}', '\u{0333}', '\u{033A}', '\u{20E8}', '\u{20EC}',
|
|
||||||
'\u{20ED}', '\u{20EE}', '\u{20EF}',
|
|
||||||
];
|
|
||||||
|
|
||||||
/// Whether this accent is a bottom accent or not.
|
/// Whether this accent is a bottom accent or not.
|
||||||
pub fn is_bottom(&self) -> bool {
|
pub fn is_bottom(&self) -> bool {
|
||||||
Self::BOTTOM.contains(&self.0)
|
static COMBINING_CLASS_DATA: LazyLock<CodePointMapData<CanonicalCombiningClass>> =
|
||||||
|
LazyLock::new(|| {
|
||||||
|
icu_properties::maps::load_canonical_combining_class(
|
||||||
|
&BlobDataProvider::try_new_from_static_blob(typst_assets::icu::ICU)
|
||||||
|
.unwrap()
|
||||||
|
.as_deserializing(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
|
||||||
|
matches!(
|
||||||
|
COMBINING_CLASS_DATA.as_borrowed().get(self.0),
|
||||||
|
CanonicalCombiningClass::Below
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,25 +225,21 @@ pub struct OutlineElem {
|
|||||||
/// to just specifying `{2em}`.
|
/// to just specifying `{2em}`.
|
||||||
///
|
///
|
||||||
/// ```example
|
/// ```example
|
||||||
/// #set heading(numbering: "1.a.")
|
/// >>> #show heading: none
|
||||||
|
/// #set heading(numbering: "I-I.")
|
||||||
|
/// #set outline(title: none)
|
||||||
///
|
///
|
||||||
/// #outline(
|
/// #outline()
|
||||||
/// title: [Contents (Automatic)],
|
/// #line(length: 100%)
|
||||||
/// indent: auto,
|
/// #outline(indent: 3em)
|
||||||
/// )
|
|
||||||
///
|
///
|
||||||
/// #outline(
|
/// = Software engineering technologies
|
||||||
/// title: [Contents (Length)],
|
/// == Requirements
|
||||||
/// indent: 2em,
|
/// == Tools and technologies
|
||||||
/// )
|
/// === Code editors
|
||||||
///
|
/// == Analyzing alternatives
|
||||||
/// = About ACME Corp.
|
/// = Designing software components
|
||||||
/// == History
|
/// = Testing and integration
|
||||||
/// === Origins
|
|
||||||
/// #lorem(10)
|
|
||||||
///
|
|
||||||
/// == Products
|
|
||||||
/// #lorem(10)
|
|
||||||
/// ```
|
/// ```
|
||||||
pub indent: Smart<OutlineIndent>,
|
pub indent: Smart<OutlineIndent>,
|
||||||
}
|
}
|
||||||
@ -450,8 +446,9 @@ impl OutlineEntry {
|
|||||||
/// at the same level are aligned.
|
/// at the same level are aligned.
|
||||||
///
|
///
|
||||||
/// If the outline's indent is a fixed value or a function, the prefixes are
|
/// If the outline's indent is a fixed value or a function, the prefixes are
|
||||||
/// indented, but the inner contents are simply inset from the prefix by the
|
/// indented, but the inner contents are simply offset from the prefix by
|
||||||
/// specified `gap`, rather than aligning outline-wide.
|
/// the specified `gap`, rather than aligning outline-wide. For a visual
|
||||||
|
/// explanation, see [`outline.indent`]($outline.indent).
|
||||||
#[func(contextual)]
|
#[func(contextual)]
|
||||||
pub fn indented(
|
pub fn indented(
|
||||||
&self,
|
&self,
|
||||||
|
@ -79,6 +79,36 @@ use crate::text::TextElem;
|
|||||||
/// reference: `[@intro[Chapter]]`.
|
/// reference: `[@intro[Chapter]]`.
|
||||||
///
|
///
|
||||||
/// # Customization
|
/// # Customization
|
||||||
|
/// When you only ever need to reference pages of a figure/table/heading/etc. in
|
||||||
|
/// a document, the default `form` field value can be changed to `{"page"}` with
|
||||||
|
/// a set rule. If you prefer a short "p." supplement over "page", the
|
||||||
|
/// [`page.supplement`]($page.supplement) field can be used for changing this:
|
||||||
|
///
|
||||||
|
/// ```example
|
||||||
|
/// #set page(
|
||||||
|
/// numbering: "1",
|
||||||
|
/// supplement: "p.",
|
||||||
|
/// >>> margin: (bottom: 3em),
|
||||||
|
/// >>> footer-descent: 1.25em,
|
||||||
|
/// )
|
||||||
|
/// #set ref(form: "page")
|
||||||
|
///
|
||||||
|
/// #figure(
|
||||||
|
/// stack(
|
||||||
|
/// dir: ltr,
|
||||||
|
/// spacing: 1em,
|
||||||
|
/// circle(),
|
||||||
|
/// square(),
|
||||||
|
/// ),
|
||||||
|
/// caption: [Shapes],
|
||||||
|
/// ) <shapes>
|
||||||
|
///
|
||||||
|
/// #pagebreak()
|
||||||
|
///
|
||||||
|
/// See @shapes for examples
|
||||||
|
/// of different shapes.
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// If you write a show rule for references, you can access the referenced
|
/// If you write a show rule for references, you can access the referenced
|
||||||
/// element through the `element` field of the reference. The `element` may
|
/// element through the `element` field of the reference. The `element` may
|
||||||
/// be `{none}` even if it exists if Typst hasn't discovered it yet, so you
|
/// be `{none}` even if it exists if Typst hasn't discovered it yet, so you
|
||||||
@ -91,16 +121,13 @@ use crate::text::TextElem;
|
|||||||
/// #show ref: it => {
|
/// #show ref: it => {
|
||||||
/// let eq = math.equation
|
/// let eq = math.equation
|
||||||
/// let el = it.element
|
/// let el = it.element
|
||||||
/// if el != none and el.func() == eq {
|
/// // Skip all other references.
|
||||||
/// // Override equation references.
|
/// if el == none or el.func() != eq { return it }
|
||||||
/// link(el.location(),numbering(
|
/// // Override equation references.
|
||||||
/// el.numbering,
|
/// link(el.location(), numbering(
|
||||||
/// ..counter(eq).at(el.location())
|
/// el.numbering,
|
||||||
/// ))
|
/// ..counter(eq).at(el.location())
|
||||||
/// } else {
|
/// ))
|
||||||
/// // Other references as usual.
|
|
||||||
/// it
|
|
||||||
/// }
|
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// = Beginnings <beginning>
|
/// = Beginnings <beginning>
|
||||||
|
@ -34,8 +34,7 @@ pub(crate) fn embed_files(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
let data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(embed.data.clone());
|
let data: Arc<dyn AsRef<[u8]> + Send + Sync> = Arc::new(embed.data.clone());
|
||||||
// TODO: update when new krilla version lands (https://github.com/LaurenzV/krilla/pull/203)
|
let compress = should_compress(&embed.data);
|
||||||
let compress = should_compress(&embed.data).unwrap_or(true);
|
|
||||||
|
|
||||||
let file = EmbeddedFile {
|
let file = EmbeddedFile {
|
||||||
path,
|
path,
|
||||||
|
@ -137,6 +137,59 @@
|
|||||||
In addition to the functions listed below, the `calc` module also defines
|
In addition to the functions listed below, the `calc` module also defines
|
||||||
the constants `pi`, `tau`, `e`, and `inf`.
|
the constants `pi`, `tau`, `e`, and `inf`.
|
||||||
|
|
||||||
|
- name: std
|
||||||
|
title: Standard library
|
||||||
|
category: foundations
|
||||||
|
path: ["std"]
|
||||||
|
details: |
|
||||||
|
A module that contains all globally accessible items.
|
||||||
|
|
||||||
|
# Using "shadowed" definitions
|
||||||
|
The `std` module is useful whenever you overrode a name from the global
|
||||||
|
scope (this is called _shadowing_). For instance, you might have used the
|
||||||
|
name `text` for a parameter. To still access the `text` element, write
|
||||||
|
`std.text`.
|
||||||
|
|
||||||
|
```example
|
||||||
|
>>> #set page(margin: (left: 3em))
|
||||||
|
#let par = [My special paragraph.]
|
||||||
|
#let special(text) = {
|
||||||
|
set std.text(style: "italic")
|
||||||
|
set std.par.line(numbering: "1")
|
||||||
|
text
|
||||||
|
}
|
||||||
|
|
||||||
|
#special(par)
|
||||||
|
|
||||||
|
#lorem(10)
|
||||||
|
```
|
||||||
|
|
||||||
|
# Conditional access
|
||||||
|
You can also use this in combination with the [dictionary
|
||||||
|
constructor]($dictionary) to conditionally access global definitions. This
|
||||||
|
can, for instance, be useful to use new or experimental functionality when
|
||||||
|
it is available, while falling back to an alternative implementation if
|
||||||
|
used on an older Typst version. In particular, this allows us to create
|
||||||
|
[polyfills](https://en.wikipedia.org/wiki/Polyfill_(programming)).
|
||||||
|
|
||||||
|
This can be as simple as creating an alias to prevent warning messages, for
|
||||||
|
example, conditionally using `pattern` in Typst version 0.12, but using
|
||||||
|
[`tiling`] in newer versions. Since the parameters accepted by the `tiling`
|
||||||
|
function match those of the older `pattern` function, using the `tiling`
|
||||||
|
function when available and falling back to `pattern` otherwise will unify
|
||||||
|
the usage across all versions. Note that, when creating a polyfill,
|
||||||
|
[`sys.version`]($category/foundations/sys) can also be very useful.
|
||||||
|
|
||||||
|
```typ
|
||||||
|
#let tiling = if "tiling" in dictionary(std) {
|
||||||
|
tiling
|
||||||
|
} else {
|
||||||
|
pattern
|
||||||
|
}
|
||||||
|
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
- name: sys
|
- name: sys
|
||||||
title: System
|
title: System
|
||||||
category: foundations
|
category: foundations
|
||||||
|
@ -37,7 +37,7 @@ static GROUPS: LazyLock<Vec<GroupData>> = LazyLock::new(|| {
|
|||||||
let mut groups: Vec<GroupData> =
|
let mut groups: Vec<GroupData> =
|
||||||
yaml::from_str(load!("reference/groups.yml")).unwrap();
|
yaml::from_str(load!("reference/groups.yml")).unwrap();
|
||||||
for group in &mut groups {
|
for group in &mut groups {
|
||||||
if group.filter.is_empty() {
|
if group.filter.is_empty() && group.name != "std" {
|
||||||
group.filter = group
|
group.filter = group
|
||||||
.module()
|
.module()
|
||||||
.scope()
|
.scope()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user