PDF import: text outlined for a second glyph of a character says so

A line of type in a font the file carries is kept as outlines when it
uses a different glyph for a character than the rest of the file does in
that font, because the font kept with the document holds one glyph per
character. That line got the warning for scripts whose letters join, so
a Latin document reported Indic-style reshaping. It now gets its own
warning, which is also one of the warnings on outlines that a layered
.ai drops when no outlines are left. Type kept as outlines because it
would reshape keeps the old warning.
This commit is contained in:
dotCooCoo committed 2026-12-05 03:16:41 -08:00
1 parent 7e58b453aa
commit 641b0145e4
5 files changed
+33 -9

No files matched your search

+2 -2
View File
@@ -42,8 +42,8 @@ pub(crate) use cid::replacement;
#[cfg(test)]
pub(crate) use cid::{CidText, font_chars, identify_glyph, unify_radical};
pub use entry::{
INVISIBLE_TEXT_NOTE, OFF_ARTBOARD_NOTE, OUTLINED_TEXT_NOTE, PAST_PAGE_NOTE, RESHAPED_TEXT_NOTE, UNMATCHED_GLYPHS_NOTE, UNNAMED_CHARACTERS_NOTE,
holds_outlines, import, import_opened, import_with_report, is_glyph_outlines, is_outlines_note,
CONFLICTING_GLYPHS_NOTE, INVISIBLE_TEXT_NOTE, OFF_ARTBOARD_NOTE, OUTLINED_TEXT_NOTE, PAST_PAGE_NOTE, RESHAPED_TEXT_NOTE, UNMATCHED_GLYPHS_NOTE,
UNNAMED_CHARACTERS_NOTE, holds_outlines, import, import_opened, import_with_report, is_glyph_outlines, is_outlines_note,
};
#[cfg(test)]
pub(crate) use entry::{TEST_MAX_OBJECTS, import_with_reader_options, read};
+10 -4
View File
@@ -1,7 +1,7 @@
use super::cid::{CidText, FontInfo, comparable, font_chars, identify_glyph, matching_face, replacement, unify_radical};
use super::entry::{
MAX_NESTED, OVERPRINT_UNREAD, OVERPRINT_ZERO_MODE, PATTERN_REUSE, RESHAPED_TEXT_NOTE, TEXT_OUTLINES, TOO_MANY_OBJECTS, UNMATCHED_GLYPHS_NOTE,
UNNAMED_CHARACTERS_NOTE, max_objects,
CONFLICTING_GLYPHS_NOTE, MAX_NESTED, OVERPRINT_UNREAD, OVERPRINT_ZERO_MODE, PATTERN_REUSE, RESHAPED_TEXT_NOTE, TEXT_OUTLINES, TOO_MANY_OBJECTS,
UNMATCHED_GLYPHS_NOTE, UNNAMED_CHARACTERS_NOTE, max_objects,
};
use super::reshaped;
use super::state::{
@@ -801,7 +801,13 @@ impl<'p> Builder<'p> {
// A line with a glyph the file's font can't keep (another glyph for the same character)
// is kept as outlines too, so each glyph draws as the file does.
let conflict = line_conflict && !glyphs.is_empty() && !line_type3;
if conflict || (checked && reshaped::reshapes(&t.plain_text()) && !reshaped::draws_as(&t, &facts.ink)) {
// The warning names why: the glyph conflict, else type that reshapes as it is set.
let note = if conflict {
Some(CONFLICTING_GLYPHS_NOTE)
} else {
(checked && reshaped::reshapes(&t.plain_text()) && !reshaped::draws_as(&t, &facts.ink)).then_some(RESHAPED_TEXT_NOTE)
};
if let Some(note) = note {
outlined = true;
if self.mask.is_some() {
self.flush_glyphs();
@@ -834,7 +840,7 @@ impl<'p> Builder<'p> {
self.flush_masked();
}
}
self.warn(RESHAPED_TEXT_NOTE);
self.warn(note);
} else {
let mut n = Node::new(self.id(), NodeKind::Text(Box::new(t)));
n.opacity = opacity;
+9 -1
View File
@@ -180,16 +180,24 @@ pub const UNMATCHED_GLYPHS_NOTE: &str = "text whose glyphs differ from the insta
pub const RESHAPED_TEXT_NOTE: &str =
"text that would not look as it does in the file if set as type (a script whose letters join) was kept as outlines";
/// Warning: type in a font the file carries that draws a character with a different glyph than
/// the rest of the file does in that font (an alternate letter) was kept as outlines: the font kept
/// with the document has one glyph per character ([`crate::import_fonts`]).
pub const CONFLICTING_GLYPHS_NOTE: &str =
"text that uses a different glyph for a character than the rest of its font (such as an alternate letter) was kept as outlines";
/// The end of the warning that glyphs whose characters the file doesn't name were kept as
/// outlines, after "text in" and the font's name.
pub const UNNAMED_CHARACTERS_NOTE: &str = "whose characters the file doesn't name (U+FFFD) was kept as outlines";
/// Is `note` one of the warnings that glyphs were kept as outlines ([`OUTLINED_TEXT_NOTE`],
/// [`UNMATCHED_GLYPHS_NOTE`], [`RESHAPED_TEXT_NOTE`], [`UNNAMED_CHARACTERS_NOTE`])?
/// [`UNMATCHED_GLYPHS_NOTE`], [`RESHAPED_TEXT_NOTE`], [`CONFLICTING_GLYPHS_NOTE`],
/// [`UNNAMED_CHARACTERS_NOTE`])?
pub fn is_outlines_note(note: &str) -> bool {
note == OUTLINED_TEXT_NOTE
|| note == UNMATCHED_GLYPHS_NOTE
|| note == RESHAPED_TEXT_NOTE
|| note == CONFLICTING_GLYPHS_NOTE
|| note.starts_with("text in ") && note.ends_with(UNNAMED_CHARACTERS_NOTE)
}
+2 -2
View File
@@ -79,8 +79,8 @@ pub use editing::{EDITING_FILE, Editing, LEGACY_EDITING_FILE, editing, editing_w
pub use export::{check_page_sizes, export, export_with_report, page_areas};
pub use file_info::{FileInfo, MAX_TEMPLATE_BYTES, file_info, metadata_template, read_template};
pub use import::{
INVISIBLE_TEXT_NOTE, OFF_ARTBOARD_NOTE, OUTLINED_TEXT_NOTE, PAST_PAGE_NOTE, RESHAPED_TEXT_NOTE, UNMATCHED_GLYPHS_NOTE, UNNAMED_CHARACTERS_NOTE,
holds_outlines, import, import_opened, import_with_report, is_glyph_outlines, is_outlines_note,
CONFLICTING_GLYPHS_NOTE, INVISIBLE_TEXT_NOTE, OFF_ARTBOARD_NOTE, OUTLINED_TEXT_NOTE, PAST_PAGE_NOTE, RESHAPED_TEXT_NOTE, UNMATCHED_GLYPHS_NOTE,
UNNAMED_CHARACTERS_NOTE, holds_outlines, import, import_opened, import_with_report, is_glyph_outlines, is_outlines_note,
};
#[cfg(any(test, feature = "read-count"))]
pub use import::{form_content_of, function_evaluations_of, imports_of};
+10
View File
@@ -275,6 +275,16 @@ fn two_glyphs_for_one_character_both_survive_import() {
close(&glyph_ink(db, &imported), "imported");
}
/// The line kept as outlines for its other glyph of `a` is Latin type: the warning names the glyph
/// conflict, not a script whose letters join, and is one of the warnings on outlines (which a `.ai`
/// read from its layers drops when no outlines are left).
#[test]
fn a_line_kept_as_outlines_for_another_glyph_names_the_glyph_conflict() {
let warnings = import(&two_glyphs_pdf()).warnings;
assert!(warnings.iter().any(|w| w == CONFLICTING_GLYPHS_NOTE && is_outlines_note(w)), "{warnings:?}");
assert!(warnings.iter().all(|w| !is_outlines_note(w) || w == CONFLICTING_GLYPHS_NOTE), "{warnings:?}");
}
/// The license flags (OS/2 `fsType`) of the font a PDF carries go with the font the document keeps:
/// a restricted font (0x0002) still draws its type, and a PDF saved from the document draws that
/// type as outlines with the license warning instead of embedding the font again.