Preserve the XDV text line when switching OpenType fonts
This commit is contained in:
1 parent
b22e127e93
commit
aae23d837e
3 files changed
+150
-18
No files matched your search
@@ -774,6 +774,54 @@ fn xetex_type1_widths_follow_the_encoded_glyph_program() {
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xetex_opentype_font_switch_uses_the_current_text_line_origin() {
|
||||
use lopdf::{Document, content::Content};
|
||||
use texrra_tex_core::execution::InputProfile;
|
||||
|
||||
let root = directory("xetex-opentype-font-switch");
|
||||
let mut job = request(&root);
|
||||
job.world = WorldConfig::new(&root);
|
||||
job.input_profile = InputProfile::XeTeX;
|
||||
fs::write(
|
||||
root.join("serif.ttf"),
|
||||
include_bytes!("../assets/fonts-subset/LiberationSerif-Regular.ttf"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(
|
||||
root.join("sans.ttf"),
|
||||
include_bytes!("../assets/fonts-subset/LiberationSans-Regular.ttf"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(
|
||||
root.join("main.tex"),
|
||||
br#"\catcode123=1 \catcode125=2
|
||||
\font\serif="[serif.ttf]" at 9pt
|
||||
\font\sans="[sans.ttf]" at 12pt
|
||||
\shipout\hbox{\serif AA\kern14pt\sans B\kern9pt\serif C}
|
||||
\end"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let result = NativeCompiler::default().compile(job).unwrap();
|
||||
let pdf = Document::load_mem(result.pdf.as_deref().unwrap()).unwrap();
|
||||
let page = pdf.get_page_content(pdf.get_pages()[&1]).unwrap();
|
||||
let content = Content::decode(&page).unwrap();
|
||||
let operators = content
|
||||
.operations
|
||||
.iter()
|
||||
.filter_map(|operation| match operation.operator.as_str() {
|
||||
name @ ("BT" | "ET" | "Tf" | "Tm" | "Td" | "TJ") => Some(name),
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
operators,
|
||||
["BT", "Tf", "Tm", "Td", "TJ", "Tf", "Td", "TJ", "Tf", "Td", "TJ", "ET"]
|
||||
);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xetex_unclaimed_special_warns_at_shipout_and_retains_the_whatsit() {
|
||||
use texrra_tex_core::execution::{Event, InputProfile};
|
||||
|
||||
Reference in new issue
Block a user