mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-21 09:54:09 +01:00
Merge feat/retype-tracking into feat/retype-area-text
This commit is contained in:
2 files changed
+13
-1
No files matched your search
@@ -500,7 +500,9 @@ impl Line {
|
||||
// (tracking is added after the glyph and after the space): the seed then places the spaces
|
||||
// from the extra less one space, shared by the two. It goes last, so a reading that fits
|
||||
// without it is kept (an untracked "a b c" has no such tracking).
|
||||
let spaced_seed = lower.map(|e| (e - space) / 2.0);
|
||||
// Where untracked type already draws the whole line, a space and a tracking of half its
|
||||
// advance less draw it too: that reading is not tried.
|
||||
let spaced_seed = lower.filter(|_| plain_miss.is_some()).map(|e| (e - space) / 2.0);
|
||||
let mut tries = vec![];
|
||||
for seed in [lower, median(extra, true), spaced_seed].into_iter().flatten() {
|
||||
let Some(measured) = measure(seed) else { continue };
|
||||
|
||||
@@ -1055,6 +1055,16 @@ fn a_word_space_between_kerned_letters_is_read_as_a_space() {
|
||||
assert_same_places(&before, &text_of(&s, r["ids"][0].as_u64().unwrap()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_untracked_word_is_not_read_as_spaced_letters_in_tight_tracking() {
|
||||
// Letters, each followed by a space, at tracking of minus half a space, sit where the word's
|
||||
// letters do.
|
||||
let mut s = session();
|
||||
let (_, r) = retyped(&mut s, json!({"x": 40, "y": 100, "text": "Third", "size": 24}), &[]);
|
||||
assert_eq!(r["texts"], json!(["Third"]), "{r}");
|
||||
assert_eq!(r["fonts"][0]["tracking"], json!(0.0), "{r}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glyphs_barely_ahead_of_each_other_stay_one_line() {
|
||||
let mut s = session();
|
||||
|
||||
Reference in new issue
Block a user