From 762a883b399938b076020932f1ee74acaf741ec1 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 4 Sep 2024 13:52:48 +0200 Subject: [PATCH] :bug: Fix problem with font weight and style --- frontend/src/app/plugins/text.cljs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/plugins/text.cljs b/frontend/src/app/plugins/text.cljs index bdcc67b04..d2343310a 100644 --- a/frontend/src/app/plugins/text.cljs +++ b/frontend/src/app/plugins/text.cljs @@ -175,7 +175,12 @@ :set (fn [self value] (let [font (fonts/get-font-data (obj/get self "fontId")) - variant (fonts/find-variant font {:weight (dm/str value)})] + weight (dm/str value) + style (obj/get self "fontStyle") + variant + (or + (fonts/find-variant font {:style style :weight weight}) + (fonts/find-variant font {:weight weight}))] (cond (nil? variant) (u/display-not-valid :fontWeight (dm/str "Font weight '" value "' not supported for the current font")) @@ -193,7 +198,12 @@ :set (fn [self value] (let [font (fonts/get-font-data (obj/get self "fontId")) - variant (fonts/find-variant font {:style (dm/str value)})] + style (dm/str value) + weight (obj/get self "fontWeight") + variant + (or + (fonts/find-variant font {:weight weight :style style}) + (fonts/find-variant font {:style style}))] (cond (nil? variant) (u/display-not-valid :fontStyle (dm/str "Font style '" value "' not supported for the current font")) @@ -439,7 +449,12 @@ (fn [self value] (let [id (obj/get self "$id") font (fonts/get-font-data (obj/get self "fontId")) - variant (fonts/find-variant font {:weight (dm/str value)})] + weight (dm/str value) + style (obj/get self "fontStyle") + variant + (or + (fonts/find-variant font {:style style :weight weight}) + (fonts/find-variant font {:weight weight}))] (cond (nil? variant) (u/display-not-valid :fontWeight (dm/str "Font weight '" value "' not supported for the current font")) @@ -456,7 +471,12 @@ (fn [self value] (let [id (obj/get self "$id") font (fonts/get-font-data (obj/get self "fontId")) - variant (fonts/find-variant font {:style (dm/str value)})] + style (dm/str value) + weight (obj/get self "fontWeight") + variant + (or + (fonts/find-variant font {:weight weight :style style}) + (fonts/find-variant font {:style style}))] (cond (nil? variant) (u/display-not-valid :fontStyle (dm/str "Font style '" value "' not supported for the current font"))