-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exporter::svg): layout and shape text in browser (#416)
* feat: properly visualize text selection * dev(exporter::svg): apply additional scale to text * feat(exporter::svg): impl text shaping v1 * dev(exporter::svg): set content hint * dev(exporter::svg): update svg utils * build: sanitize content-hint changes * dev(core): more robust way to calculating rev_cmap * dev(core): fix both typst-preview and ci * build: lock content-hint features * dev: option to disable browser side text layout
- Loading branch information
1 parent
e9f6295
commit acfaa92
Showing
35 changed files
with
1,252 additions
and
525 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use comemo::{Track, TrackedMut}; | ||
use typst::{ | ||
diag::SourceResult, | ||
eval::{Module, Route, Tracer}, | ||
World, | ||
}; | ||
|
||
/// Compile a source file into a module. | ||
/// | ||
/// - Returns `Ok(document)` if there were no fatal errors. | ||
/// - Returns `Err(errors)` if there were fatal errors. | ||
/// | ||
/// Requires a mutable reference to a tracer. Such a tracer can be created with | ||
/// `Tracer::new()`. Independently of whether compilation succeeded, calling | ||
/// `tracer.warnings()` after compilation will return all compiler warnings. | ||
pub fn evaluate(world: &dyn World, tracer: &mut Tracer) -> SourceResult<Module> { | ||
let route = Route::default(); | ||
|
||
// Call `track` just once to keep comemo's ID stable. | ||
let world = world.track(); | ||
let mut tracer = tracer.track_mut(); | ||
|
||
// Try to evaluate the source file into a module. | ||
typst::eval::eval( | ||
world, | ||
route.track(), | ||
TrackedMut::reborrow_mut(&mut tracer), | ||
&world.main(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.