mirror of
https://github.com/typst/typst
synced 2025-08-24 19:54:14 +08:00
Memoize try_new
This commit is contained in:
parent
69392173eb
commit
4ad6b4fc64
@ -266,12 +266,13 @@ impl GlyphFragment {
|
|||||||
|
|
||||||
/// Try to create a new glyph out of the given string. Will return None if
|
/// Try to create a new glyph out of the given string. Will return None if
|
||||||
/// the result from shaping the string is not a single glyph or is a tofu.
|
/// the result from shaping the string is not a single glyph or is a tofu.
|
||||||
|
#[comemo::memoize]
|
||||||
pub fn try_new(
|
pub fn try_new(
|
||||||
font: &Font,
|
font: &Font,
|
||||||
styles: StyleChain,
|
styles: StyleChain,
|
||||||
str: &str,
|
str: &str,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Option<Self> {
|
) -> Option<GlyphFragment> {
|
||||||
let mut buffer = UnicodeBuffer::new();
|
let mut buffer = UnicodeBuffer::new();
|
||||||
buffer.push_str(str);
|
buffer.push_str(str);
|
||||||
buffer.set_language(language(styles));
|
buffer.set_language(language(styles));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user