mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep a copy text's own variant when both sides show its weight
A copy text that sets its own family and weight keeps the variant id its family names for that weight. When the main later shows the same weight, the weight is equal on both sides and sync does not place it, so the family's variant ids were not given either: the copy's Roboto run took the main's "bold", a variant of another family. The family's side now gives its variants whenever the family is placed and the weight is not. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 20.095 | 0.57 | | edit-through-a-chain-of-dependents | 68.931 | 39.445 | 0.57 | | library-update-into-copies | 83.083 | 45.617 | 0.55 | | main-edit-among-many-shapes | 4.837 | 2.227 | 0.46 | | main-edit-into-10-copies | 1.79 | 0.961 | 0.54 | | main-edit-into-100-copies | 15.415 | 9.374 | 0.61 | | main-edit-into-1000-copies | 153.086 | 94.792 | 0.62 | | variant-switch-into-copies | 32.052 | 20.436 | 0.64 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
1fb421277b
commit
c13dcdd71f
@ -1047,9 +1047,10 @@
|
||||
units)]
|
||||
(if (and (empty? placed) (not drop-typo?))
|
||||
base
|
||||
;; the family's side names the variants of its family
|
||||
;; the family's side names the variants of its family, also when
|
||||
;; both sides show the same weight and it is not placed
|
||||
(let [variants (when (and (contains? placed :text-content-family)
|
||||
(not-any? #{:text-content-weight} units))
|
||||
(not (contains? placed :text-content-weight)))
|
||||
(place-unit src dst @lmap :text-content-weight
|
||||
(unit-values src :text-content-weight) false))]
|
||||
(letters->content (write-units dst placed drop-typo? variants))))))))
|
||||
|
||||
@ -996,3 +996,11 @@
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:grid-direction 0 0 0 1] [:grid-cell 0 0 0 1] [:grid-direction 0 0 15 0]
|
||||
[:edit 3 0 1 1] [:update-main 3] [:style 1 11 0 0]]}))))
|
||||
|
||||
(t/deftest generated-copy-text-with-its-own-family-and-weight-keeps-its-variant
|
||||
;; a copy text sets its own family and the weight its main then takes too;
|
||||
;; a later sync keeps the variant its own family names for that weight
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :rich-variants true
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:nest 0 0 0 0] [:text-style 0 1 1] [:duplicate 0 0 0 0]
|
||||
[:update-main 1 0 0 0] [:text-style 0 0 1]]}))))
|
||||
|
||||
@ -183,6 +183,14 @@
|
||||
[[["Hello world" {:family "Roboto" :weight 700}]]]
|
||||
[[["Hello world" {:weight 700 :color :blue}]]]))))
|
||||
|
||||
(t/deftest copy-with-its-own-family-and-weight-keeps-its-familys-variant
|
||||
;; the copy's Roboto names its bold "700"; the main turning bold as well
|
||||
;; leaves the weight equal on both sides, and the main's "bold" stays its own
|
||||
(t/is (= [[["Hello world" {:family "Roboto" :weight 700 :color :blue}]]]
|
||||
(sync-text [[["Hello world"]]]
|
||||
[[["Hello world" {:family "Roboto" :weight 700}]]]
|
||||
[[["Hello world" {:weight 700 :color :blue}]]]))))
|
||||
|
||||
(t/deftest copy-that-bolds-a-word-the-main-replaces-loses-the-bold
|
||||
;; "Goodbye" shares no stretch of 3 letters with "Hello", so it takes the
|
||||
;; style of the first shared letter after it, the regular space
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user