Write PDF interword spaces with actual device fonts
This commit is contained in:
1 parent
b93d5f55da
commit
514a2d3344
24 files changed
+664
-65
No files matched your search
@@ -0,0 +1,60 @@
|
||||
//! Interword space operations in the PDF device. These whatsits have no TeX dimensions.
|
||||
use crate::{
|
||||
execution::FontId,
|
||||
native_font::{NativeFont, NativeFontPaint},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum SpaceOperation {
|
||||
Automatic(bool),
|
||||
Explicit,
|
||||
}
|
||||
|
||||
impl SpaceOperation {
|
||||
pub(crate) fn name(self) -> &'static str {
|
||||
match self {
|
||||
Self::Automatic(true) => "pdfinterwordspaceon",
|
||||
Self::Automatic(false) => "pdfinterwordspaceoff",
|
||||
Self::Explicit => "pdffakespace",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct SpaceSettings {
|
||||
pub(crate) automatic_at_start: bool,
|
||||
pub(crate) font: SpaceFontRequest,
|
||||
pub(crate) parameters: Vec<(i32, i32)>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub(crate) struct SpaceFontRequest {
|
||||
pub name: String,
|
||||
pub from: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct ResolvedSpaceFont {
|
||||
pub font: Arc<NativeFont>,
|
||||
pub paint: Arc<NativeFontPaint>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub(crate) enum SpaceUse {
|
||||
InFont,
|
||||
Dedicated,
|
||||
}
|
||||
|
||||
/// Resolved spaces are indexed by paint order, after virtual font expansion.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct SpacePlan {
|
||||
pub(crate) before_glyph: BTreeMap<usize, SpaceUse>,
|
||||
pub(crate) in_font: BTreeSet<FontId>,
|
||||
pub(crate) dedicated: Option<ResolvedSpaceFont>,
|
||||
pub(crate) spaces_in_previous_font: bool,
|
||||
}
|
||||
Reference in new issue
Block a user