Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ How to write it (see AGENTS.md):

## Unreleased

## 2.2.1

### New
- DraftCraft starts on the Start page, as AutoCAD does: begin a new drawing in Metric (millimeters) or Imperial (inches), open a drawing or the sample, and choose your workspace. Your choice of units is remembered for the next New.

### Improved
- The About window says DraftCraft and its logo are trademarks of DraftCraft Engineering Ventures, the organization that makes DraftCraft.
- The status bar shows the drawing's unit as well as its format (for example "mm · Decimal" or "in · Architectural"), and its menu switches between millimeters, centimeters, meters, inches, feet and unitless.
- The window title shows the DraftCraft version with the drawing's name, for example "DraftCraft 2.2.1 Plan.dwg".

### Fixed
- The diameter sign (%%c) no longer shows as a box in text that uses a TrueType font such as Arial: it draws as the font's own Ø.

## 2.2.0

Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"]
# default-members

[workspace.package]
version = "2.2.0"
version = "2.2.1"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
Expand Down
6 changes: 3 additions & 3 deletions apps/draftcraft/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ fn main() -> eframe::Result {
app.open_path(f);
}
if app.session.docs.is_empty() {
// In the units the profile asks for (MEASUREINIT, restored above).
let metric = app.session.settings.measureinit;
app.session.new_drawing(metric);
// Nothing to open: start on the Start page, as AutoCAD does, where a new drawing
// is begun in metric or imperial units and the workspace is chosen.
app.ui.start_tab = true;
}
let ctx = cc.egui_ctx.clone();
let desktop_theme = desktop_theme::DesktopTheme::start(move || ctx.request_repaint());
Expand Down
16 changes: 15 additions & 1 deletion crates/fonts/src/ttf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,26 @@ pub(crate) fn fallback_glyph(c: char) -> Option<Arc<GlyphOutline>> {
Some(glyph(&f, c)).filter(|g| g.mapped)
}

/// The glyph of `c` in `face`, or from a fallback font when `face` lacks it.
/// Characters that draw the same sign as `c` in fonts that lack `c`, best first. The diameter
/// sign (⌀, U+2300, what `%%c` decodes to) is in almost no TrueType font, while nearly all have
/// Ø (U+00D8), which drafting uses for it; ∅ (U+2205) is the next best.
fn look_alikes(c: char) -> &'static [char] {
match c {
'\u{2300}' => &['\u{00D8}', '\u{2205}'],
_ => &[],
}
}

/// The glyph of `c` in `face`; when `face` lacks it, a look-alike in the same face (so the sign
/// matches the text around it), then `c` from a fallback font. Only then the missing-glyph box.
fn glyph_or_fallback(face: &Face, c: char) -> Arc<GlyphOutline> {
let g = glyph(face, c);
if g.mapped || c.is_whitespace() {
return g;
}
if let Some(alike) = look_alikes(c).iter().map(|&a| glyph(face, a)).find(|a| a.mapped) {
return alike;
}
fallback_glyph(c).unwrap_or(g)
}

Expand Down
39 changes: 39 additions & 0 deletions crates/fonts/tests/diameter_sign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! `%%c` (⌀, U+2300) in a TrueType text style: almost no TrueType font has U+2300, so it used to
//! come out as the font's missing-character box. It must draw the font's own Ø instead.

use std::sync::Arc;

use draftcraft_fonts::ttf;

/// A system font that has Ø but not ⌀ (most of them), or `None` where there is none.
fn a_face_without_the_diameter_sign() -> Option<ttf::Face> {
let dirs = ["/usr/share/fonts", "/System/Library/Fonts", "/Library/Fonts", "C:\\Windows\\Fonts"];
let mut stack: Vec<std::path::PathBuf> = dirs.iter().map(Into::into).collect();
while let Some(p) = stack.pop() {
let Ok(rd) = std::fs::read_dir(&p) else { continue };
for e in rd.flatten() {
let p = e.path();
if p.is_dir() {
stack.push(p);
} else if p.extension().is_some_and(|x| x.eq_ignore_ascii_case("ttf"))
&& let Ok(bytes) = std::fs::read(&p)
&& let Some(face) = ttf::Face::new(Arc::new(bytes), 0)
&& face.has_glyph('Ø')
&& !face.has_glyph('\u{2300}')
{
return Some(face);
}
}
}
None
}

#[test]
fn the_diameter_sign_draws_as_the_fonts_own_o_slash_not_a_box() {
let Some(face) = a_face_without_the_diameter_sign() else { return };
let (Some(dia), Some(slash)) = (ttf::shape(&face, "%%c25", 2.5, 1.0, 0.0), ttf::shape(&face, "Ø25", 2.5, 1.0, 0.0)) else {
panic!("the font shapes text");
};
assert_eq!(dia.glyphs, slash.glyphs, "⌀ must draw exactly like the font's Ø, not the missing-glyph box");
assert!((dia.width - slash.width).abs() < 1e-9);
}
Loading
Loading