forked from 1b-agent/opencadstudio-upstream
fix(pdfshxtext): .shx-only font resolution, oversized-object rule, mean text height
A listed font is compared only from its .shx file or the embedded stroke font of that name; no TrueType or alias stand-in. Objects with a diagonal over five times the selection's mean diagonal join no group. The created MTEXT height is the mean of the character sizes. Text styles look a bare font name up as .shx first, and a missing .shx name never draws with a TrueType face. TXT2MTXT measures TEXT to its last inked stroke. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2eb60f333f
commit
416ec43c38
6 files changed
+110
-45
No files matched your search
+19
-2
@@ -524,15 +524,32 @@ pub fn is_builtin(name: &str) -> bool {
|
||||
|
||||
/// An alias names a real font (ISOCPEUR is a TrueType face): an installed
|
||||
/// copy of exactly that font draws it, Cyrillic included, where the LFF
|
||||
/// stand-in has no such glyphs (#1764).
|
||||
/// stand-in has no such glyphs (#1764). A name written as an `.shx` file
|
||||
/// never means the TrueType face: a missing `isocpeur.shx` or `swiss.shx`
|
||||
/// draws with the stroke substitute, not the installed `.ttf` (measured).
|
||||
fn installed_alias(stem: &str, name: &str) -> bool {
|
||||
use crate::scene::text::sysfont;
|
||||
ALIASES.iter().any(|(alias, _)| *alias == stem)
|
||||
!is_shx_name(name)
|
||||
&& ALIASES.iter().any(|(alias, _)| *alias == stem)
|
||||
&& (sysfont::family_for_file(name).is_some()
|
||||
|| sysfont::canonical_family_name(stem)
|
||||
.is_some_and(|family| family.eq_ignore_ascii_case(stem)))
|
||||
}
|
||||
|
||||
/// Whether `name` is written as an `.shx` file name.
|
||||
pub fn is_shx_name(name: &str) -> bool {
|
||||
name.trim().to_ascii_lowercase().ends_with(".shx")
|
||||
}
|
||||
|
||||
/// Whether an embedded font is that very font (its own stem, as `simplex`
|
||||
/// or `romans.shx`), not a stand-in reached through an alias (`txt` draws
|
||||
/// with `standard`).
|
||||
pub fn is_embedded_font(name: &str) -> bool {
|
||||
let key = name.trim().to_ascii_lowercase();
|
||||
let stem = key.strip_suffix(".shx").unwrap_or(&key);
|
||||
FONTS_SRC.iter().any(|(s, _)| *s == stem)
|
||||
}
|
||||
|
||||
pub fn get_font(name: &str) -> &'static Font {
|
||||
let map = fonts_map();
|
||||
let key = name.trim().to_ascii_uppercase();
|
||||
|
||||
Reference in new issue
Block a user