Reject automatic expansion of bitmap fonts at PDF shipout
This commit is contained in:
1 parent
45b79fc5a5
commit
9527d3bbec
8 files changed
+211
-46
No files matched your search
@@ -23,6 +23,8 @@ pub struct NativeShipout {
|
||||
pub(super) font_overrides: BTreeMap<FontId, Arc<crate::native_font::NativeFont>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(super) virtual_glyphs: Option<crate::native_font::VirtualGlyphs>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub(super) pdf_font_map: Option<Arc<crate::native_font::PdfFontMapInput>>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub(super) pdf_color_start: Vec<Arc<PdfColorProgram>>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
@@ -60,6 +62,7 @@ impl NativeShipout {
|
||||
magnification: self.device.magnification,
|
||||
units: crate::render::DisplayUnits::TeX,
|
||||
pdf: self.device.pdf.clone(),
|
||||
pdf_font_map: self.pdf_font_map.clone(),
|
||||
pdf_links: self.pdf_links.clone(),
|
||||
pdf_text_spaces: self.pdf_text_spaces.clone(),
|
||||
pdf_resources: crate::pdf_device::page_resources::PageResources {
|
||||
|
||||
@@ -44,12 +44,14 @@ struct ShipoutFontUse {
|
||||
}
|
||||
|
||||
fn shipout_font_uses(
|
||||
b: &NativeBox, programs: &JobVirtualFonts,
|
||||
b: &NativeBox, programs: &JobVirtualFonts, fonts: &FontCatalog,
|
||||
) -> Result<Vec<ShipoutFontUse>, String> {
|
||||
let mut uses = Vec::new();
|
||||
let mut seen = BTreeSet::new();
|
||||
b.visit_shipout_font_uses(|before_output, font, slot| {
|
||||
if !programs.is_known_physical(font.id) && seen.insert((font.id, slot)) {
|
||||
if (!programs.is_known_physical(font.id) || fonts.automatic_origin(font.id).is_some())
|
||||
&& seen.insert((font.id, slot))
|
||||
{
|
||||
uses.push(ShipoutFontUse { before_output, font: font.clone(), slot });
|
||||
}
|
||||
})?;
|
||||
@@ -324,6 +326,7 @@ impl Executor {
|
||||
device,
|
||||
font_overrides,
|
||||
virtual_glyphs: None,
|
||||
pdf_font_map: self.pdf_virtual_fonts.captured_font_map(),
|
||||
pdf_color_start,
|
||||
pdf_color_steps: Vec::new(),
|
||||
pdf_graphics_steps: Vec::new(),
|
||||
@@ -364,7 +367,7 @@ impl Executor {
|
||||
};
|
||||
let mut font_uses = if device.pdf.is_some() {
|
||||
shipout.virtual_glyphs = Some(VirtualGlyphs::new());
|
||||
shipout_font_uses(b, &self.pdf_virtual_fonts).map_err(|e| self.error(e, b.span))?
|
||||
shipout_font_uses(b, &self.pdf_virtual_fonts, &self.state.fonts).map_err(|e| self.error(e, b.span))?
|
||||
} else {
|
||||
Vec::new()
|
||||
}.into_iter().peekable();
|
||||
@@ -376,7 +379,7 @@ impl Executor {
|
||||
let mut pdf_objects = Vec::new();
|
||||
for (index, output) in outputs.into_iter().enumerate() {
|
||||
while font_uses.peek().is_some_and(|usage| usage.before_output == index) {
|
||||
self.current = output.span;
|
||||
self.current = current;
|
||||
self.prepare_virtual_glyph(
|
||||
shipout.virtual_glyphs.as_mut().unwrap(), font_uses.next().unwrap(), files,
|
||||
)?;
|
||||
@@ -388,6 +391,7 @@ impl Executor {
|
||||
OutputOperation::Write { .. } | OutputOperation::PdfLiteral { shipout: true, .. }
|
||||
)
|
||||
{
|
||||
shipout.pdf_font_map = self.pdf_virtual_fonts.captured_font_map();
|
||||
shipout.pdf_text_spaces =
|
||||
Some(self.pdf_space_settings(automatic_spaces_at_start, uses_automatic_spaces));
|
||||
self.current = output.span;
|
||||
@@ -495,6 +499,7 @@ impl Executor {
|
||||
for usage in font_uses {
|
||||
self.prepare_virtual_glyph(shipout.virtual_glyphs.as_mut().unwrap(), usage, files)?;
|
||||
}
|
||||
shipout.pdf_font_map = self.pdf_virtual_fonts.captured_font_map();
|
||||
let has_space_settings = has_space_nodes || automatic_spaces_at_start;
|
||||
let probed_page = (uses_automatic_spaces || has_explicit_space)
|
||||
&& self.pdf_loaded_space_font.is_none();
|
||||
@@ -556,7 +561,9 @@ impl Executor {
|
||||
) -> Result<(), Error> {
|
||||
self.check_cancellation()?;
|
||||
let id = usage.font.id;
|
||||
if self.pdf_virtual_fonts.is_known_physical(id) {
|
||||
if self.pdf_virtual_fonts.is_known_physical(id)
|
||||
&& self.state.fonts.automatic_origin(id).is_none()
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
let defaults = self.font_defaults();
|
||||
|
||||
Reference in new issue
Block a user