fix: leave a family name's trailing spaces out of its fonts' Name from DOM 21

This commit is contained in:
aiongg committed 2026-10-12 13:43:24 +00:00
1 parent 0bd2db2b96
commit da4cbfa11e
3 files changed
+20 -2

No files matched your search

+10
View File
@@ -99,6 +99,16 @@ in-object string, and InDesign 3.0 has no version (`big-endian.md`).
- `Name` is the family name, a space and the style name, and `Self` is
the family's `Self`, `Fontn` and `Name` (4,464 of 4,464, taking the
family name as IDML writes it).
- A family name that ends in a space: in the 2 pairs that have one
(DOM 11, one family each), `Name` keeps the space, so it has two
spaces before the style. In one privately held DOM 21 sample (one
family with one font), `Name` drops the family's trailing space while
`Self`, `FontFamily` and `FontFamily/@Name` keep it; no stored string
has the shorter form. Two spaces inside a style name stay in `Name`
in DOM 21 (29 fonts of one corpus IDML of DOM 21.3), so spaces are
not collapsed in general. The converter drops
the family's trailing spaces in `Name` from DOM 21; DOM 12 to 20 have
no sample.
- `FontFamily/@Name`: 622 of 630. The other 8 have a technology suffix in
IDML that the INDD name lacks (`Montserrat (OTF)` 6 times, `Minion Pro
(OTF)` and `Trustpilot Display (OTF)` once each). A family whose INDD
+1
View File
@@ -55,6 +55,7 @@ Status values:
| Language list | `Language` elements | 42 | open: no field found | IDML lists only the languages in use in 42 documents and all in the others; the language objects are the same in both kinds | |
| Font families IDML drops | class 0x3E03 | 101 | open: no field found | unused families left out of `Fonts.xml`, but many other unused ones kept; no record byte differs; files up to 17.x only | `fonts.md` |
| Fonts IDML adds | `Font` | 97 | not needed | IDML adds every style of a family installed on the exporting computer | `fonts.md` |
| Family name ending in a space, DOM 12 to 20 | `Font/@Name` | 0 | open: no sample | DOM 11 keeps the space in `Name`, DOM 21 drops it (one privately held sample); the converter keeps it before DOM 21 | `fonts.md` |
| `$ID/` PostScript names | font record | 4 pairs | open: no field found | every font of one DOM 7 set | `fonts.md` |
| u16 0 and u16 1 after `SeparatorStyle` | TOC entry, chunk 0x11605 | – | open: never varies | one may be `SortAlphabet` (`false` in all 255 entries) | `objects.md`, table of contents styles |
| u16 after `Level` | TOC entry, chunk 0x11605 | – | open: no pair | 0 in every paired entry, 1 in some entries of files without a pair | `objects.md`, table of contents styles |
+9 -2
View File
@@ -453,14 +453,21 @@ impl Writer<'_> {
x.start("FontFamily")
.attr("Self", &id)
.attr("Name", &family);
// From DOM 21 a font's `Name` drops the spaces that end its
// family's name; its `Self` keeps them (fonts.md).
let named = if self.doc.version.major >= 21 {
family.trim_end()
} else {
family.as_str()
};
for font in &f.fonts {
// A font with an empty style name is named `Regular`, and
// its `Self` has the family name alone (fonts.md).
let (name, key) = if font.style.is_empty() {
(format!("{family} Regular"), base.clone())
(format!("{named} Regular"), base.clone())
} else {
(
format!("{family} {}", font.style),
format!("{named} {}", font.style),
format!("{base} {}", font.style),
)
};