mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix some documentation 🚧
This commit is contained in:
parent
0274e93810
commit
c4eb4ee362
@ -24,7 +24,7 @@ pub struct Page {
|
|||||||
pub actions: Vec<TextAction>,
|
pub actions: Vec<TextAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A series of text layouting actions.
|
/// A text layouting action.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TextAction {
|
pub enum TextAction {
|
||||||
/// Move from the _start_ of the current line by an (x, y) offset.
|
/// Move from the _start_ of the current line by an (x, y) offset.
|
||||||
|
16
src/font.rs
16
src/font.rs
@ -395,8 +395,8 @@ impl<'p> FontLoader<'p> {
|
|||||||
}
|
}
|
||||||
drop(state);
|
drop(state);
|
||||||
|
|
||||||
// The outermost loop goes over the families because we want to serve
|
// The outermost loop goes over the families because we want to serve the font that matches
|
||||||
// the font that matches the first possible family.
|
// the first possible family.
|
||||||
for family in &query.families {
|
for family in &query.families {
|
||||||
// For each family now go over all font infos from all font providers.
|
// For each family now go over all font infos from all font providers.
|
||||||
for (provider, infos) in self.providers.iter().zip(&self.provider_fonts) {
|
for (provider, infos) in self.providers.iter().zip(&self.provider_fonts) {
|
||||||
@ -405,9 +405,9 @@ impl<'p> FontLoader<'p> {
|
|||||||
if Self::matches(&query, family, info) {
|
if Self::matches(&query, family, info) {
|
||||||
let mut state = self.state.borrow_mut();
|
let mut state = self.state.borrow_mut();
|
||||||
|
|
||||||
// Check if we have already loaded this font before, otherwise, we will
|
// Check if we have already loaded this font before, otherwise, we will load
|
||||||
// load it from the provider. Anyway, have it stored and find out its
|
// it from the provider. Anyway, have it stored and find out its internal
|
||||||
// internal index.
|
// index.
|
||||||
let index = if let Some(&index) = state.info_cache.get(info) {
|
let index = if let Some(&index) = state.info_cache.get(info) {
|
||||||
index
|
index
|
||||||
} else if let Some(mut source) = provider.get(info) {
|
} else if let Some(mut source) = provider.get(info) {
|
||||||
@ -469,9 +469,9 @@ impl<'p> FontLoader<'p> {
|
|||||||
|
|
||||||
/// Move the whole list of fonts out.
|
/// Move the whole list of fonts out.
|
||||||
pub fn into_fonts(self) -> Vec<Font> {
|
pub fn into_fonts(self) -> Vec<Font> {
|
||||||
// Sort the fonts by external index so that they are in the correct order.
|
// Sort the fonts by external index so that they are in the correct order. All fonts that
|
||||||
// All fonts that were cached but not used by the outside are sorted to the back
|
// were cached but not used by the outside are sorted to the back and are removed in the
|
||||||
// and are removed in the next step.
|
// next step.
|
||||||
let mut fonts = self.state.into_inner().fonts;
|
let mut fonts = self.state.into_inner().fonts;
|
||||||
fonts.sort_by_key(|&(maybe_index, _)| match maybe_index {
|
fonts.sort_by_key(|&(maybe_index, _)| match maybe_index {
|
||||||
Some(index) => index,
|
Some(index) => index,
|
||||||
|
@ -80,6 +80,7 @@ pub struct LayoutContext<'a, 'p> {
|
|||||||
pub text_style: TextStyle,
|
pub text_style: TextStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A space to layout in.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct LayoutDimensions {
|
pub struct LayoutDimensions {
|
||||||
/// Horizontal extent.
|
/// Horizontal extent.
|
||||||
|
@ -140,8 +140,6 @@ impl<'p> Typesetter<'p> {
|
|||||||
let tree = self.parse(src)?;
|
let tree = self.parse(src)?;
|
||||||
let (layout, fonts) = self.layout(&tree)?;
|
let (layout, fonts) = self.layout(&tree)?;
|
||||||
let document = layout.into_document(fonts);
|
let document = layout.into_document(fonts);
|
||||||
println!("fonts = {}", document.fonts.len());
|
|
||||||
println!("document = {:?}", document.pages);
|
|
||||||
Ok(document)
|
Ok(document)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user