Implement native letterspaced fonts and virtual glyph placement
This commit is contained in:
1 parent
6675ab639a
commit
f66a5a7e20
13 files changed
+337
-35
No files matched your search
@@ -401,6 +401,7 @@ impl Executor {
|
||||
| Readline
|
||||
| Font
|
||||
| Fontdimen
|
||||
| Letterspacefont
|
||||
| Hyphenchar
|
||||
| Lpcode
|
||||
| Rpcode
|
||||
|
||||
@@ -1,5 +1,49 @@
|
||||
use super::*;
|
||||
impl Executor {
|
||||
pub(super) fn define_letterspaced_font(
|
||||
&mut self,
|
||||
global: bool,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
let name = self.command(files)?;
|
||||
self.define_traced(name.clone(), Meaning::Font(FontId::NULL), global, files)?;
|
||||
self.optional_equals(files)?;
|
||||
let base = self.font_identifier(files)?;
|
||||
let amount = self.integer(files)?.clamp(-1000, 1000);
|
||||
let no_ligatures = self.keyword("nolig", files)?;
|
||||
let defaults = self.font_defaults();
|
||||
let from = self.sources[self.current.source].name.clone();
|
||||
let (font, zero_quad) = self
|
||||
.state
|
||||
.fonts
|
||||
.letterspace(
|
||||
files,
|
||||
&from,
|
||||
base,
|
||||
amount,
|
||||
no_ligatures,
|
||||
name.clone(),
|
||||
defaults,
|
||||
)
|
||||
.map_err(|e| self.error(e, self.current))?;
|
||||
if zero_quad {
|
||||
files
|
||||
.observe_diagnostic(
|
||||
WriteDestination::TerminalAndLog,
|
||||
"\npdfTeX warning (\\letterspacefont): font has zero em size (\\fontdimen6)\n",
|
||||
)
|
||||
.map_err(|e| self.error(e, self.current))?;
|
||||
}
|
||||
self.define_traced(name, Meaning::Font(font), global, files)
|
||||
}
|
||||
|
||||
pub(super) fn font_defaults(&mut self) -> FontIntegers {
|
||||
FontIntegers {
|
||||
hyphen: self.read_parameter(Parameter::Defaulthyphenchar).width(),
|
||||
skew: self.read_parameter(Parameter::Defaultskewchar).width(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn font_dimension_target(
|
||||
&mut self,
|
||||
files: &mut impl SourceProvider,
|
||||
@@ -54,7 +98,7 @@ impl Executor {
|
||||
let t = self.expanded_non_space(files)?.token;
|
||||
let font = match self.meaning(&t) {
|
||||
Meaning::Font(f) => f,
|
||||
Meaning::Primitive(Primitive::Font) => {
|
||||
Meaning::Primitive(Primitive::Font | Primitive::Letterspacefont) => {
|
||||
self.reads.insert(Dependency::TextFont);
|
||||
self.state.text_font()
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ impl Executor {
|
||||
| Delcode | Count | Countdef | Dimen | Dimendef | Skip | Skipdef | Muskip
|
||||
| Muskipdef | Toks | Toksdef | Advance | Multiply | Divide | Read | Readline
|
||||
| Font | Fontdimen | Hyphenchar | Skewchar | Lpcode | Rpcode | Efcode | Pdffontexpand
|
||||
| Textfont | Scriptfont
|
||||
| Letterspacefont | Textfont | Scriptfont
|
||||
| Scriptscriptfont | Endlinechar | Newlinechar | Escapechar | Globaldefs | Time
|
||||
| Day | Month | Year | BeginGroup | EndGroup | Relax | Message | Errmessage
|
||||
| Endinput | Showbox | Show | Showthe | Discretionary | DiscretionaryHyphen
|
||||
|
||||
@@ -635,10 +635,7 @@ impl Executor {
|
||||
crate::tfm::FontSize::Design
|
||||
};
|
||||
self.reads.insert(Dependency::FontResources);
|
||||
let defaults = FontIntegers {
|
||||
hyphen: self.read_parameter(Parameter::Defaulthyphenchar).width(),
|
||||
skew: self.read_parameter(Parameter::Defaultskewchar).width(),
|
||||
};
|
||||
let defaults = self.font_defaults();
|
||||
let from = self.sources[self.current.source].name.clone();
|
||||
let font = self
|
||||
.state
|
||||
|
||||
Reference in new issue
Block a user