diff --git a/common/src/app/common/types/text.cljc b/common/src/app/common/types/text.cljc index bb6749417c..b96afa80f3 100644 --- a/common/src/app/common/types/text.cljc +++ b/common/src/app/common/types/text.cljc @@ -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)))))))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index d5a72a0063..13441cae57 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -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]]})))) diff --git a/common/test/common_tests/logic/text_override_sync_test.cljc b/common/test/common_tests/logic/text_override_sync_test.cljc index 640f8a6806..4de6aebc0a 100644 --- a/common/test/common_tests/logic/text_override_sync_test.cljc +++ b/common/test/common_tests/logic/text_override_sync_test.cljc @@ -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