Initial texrra engine
Rename the crate, binary, core crate, font families, env vars, and internal commands from texcraft/tex-engine to texrra. Serve the separately versioned texrra-web frontend from TEXRRA_WEB_DIR, ../web, or ./web instead of embedding index.html. Add starred section heading support and an arXiv template conformance fixture.
This commit is contained in:
commit
bb1d9e0561
147 files changed
+66719
No files matched your search
@@ -0,0 +1,54 @@
|
||||
/// Layout primitives whose scanning semantics are independent of a runtime VM.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum LayoutPrimitive {
|
||||
ParagraphBreak,
|
||||
LineBreak,
|
||||
PageBreak,
|
||||
Penalty,
|
||||
Kern,
|
||||
HorizontalSkip,
|
||||
VerticalSkip,
|
||||
}
|
||||
|
||||
/// Typed effect produced after a layout primitive has scanned its operands.
|
||||
pub enum LayoutEffect<Dimension, Glue> {
|
||||
ParagraphBreak,
|
||||
LineBreak,
|
||||
PageBreak,
|
||||
Penalty(i32),
|
||||
Kern(Dimension),
|
||||
HorizontalGlue(Glue),
|
||||
VerticalGlue(Glue),
|
||||
}
|
||||
|
||||
/// Input and output boundary supplied by a compiler adapter.
|
||||
pub trait LayoutPrimitiveInput {
|
||||
type Error;
|
||||
type Dimension;
|
||||
type Glue;
|
||||
|
||||
fn scan_integer(&mut self) -> Result<i32, Self::Error>;
|
||||
fn scan_dimension(&mut self) -> Result<Self::Dimension, Self::Error>;
|
||||
fn scan_glue(&mut self) -> Result<Self::Glue, Self::Error>;
|
||||
fn emit(
|
||||
&mut self,
|
||||
effect: LayoutEffect<Self::Dimension, Self::Glue>,
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
/// Execute one layout primitive by scanning its operands and emitting one event.
|
||||
pub fn execute<S: LayoutPrimitiveInput>(
|
||||
primitive: LayoutPrimitive,
|
||||
input: &mut S,
|
||||
) -> Result<(), S::Error> {
|
||||
let effect = match primitive {
|
||||
LayoutPrimitive::ParagraphBreak => LayoutEffect::ParagraphBreak,
|
||||
LayoutPrimitive::LineBreak => LayoutEffect::LineBreak,
|
||||
LayoutPrimitive::PageBreak => LayoutEffect::PageBreak,
|
||||
LayoutPrimitive::Penalty => LayoutEffect::Penalty(input.scan_integer()?),
|
||||
LayoutPrimitive::Kern => LayoutEffect::Kern(input.scan_dimension()?),
|
||||
LayoutPrimitive::HorizontalSkip => LayoutEffect::HorizontalGlue(input.scan_glue()?),
|
||||
LayoutPrimitive::VerticalSkip => LayoutEffect::VerticalGlue(input.scan_glue()?),
|
||||
};
|
||||
input.emit(effect)
|
||||
}
|
||||
Reference in new issue
Block a user