Browse Source

标题最大长度

rambo 3 tháng trước cách đây
mục cha
commit
4587f09811

+ 16 - 7
python/custom_plugins/plugins/detail_template/huilima/detail_huilima4.py

@@ -84,19 +84,28 @@ class DetailPicGet(DetailBase):
                 "text": "标题",
                 "default": self.get_text_value("商品标题"),
                 "pos": (89, 224),
+                "max": 6,
+            },
+            {
+                "text": "副标题",
+                "default": "百搭舒适,型走随心",
+                "pos": (89, 345),
+                "max": 6,
             },
-            {"text": "副标题", "default": "百搭舒适,型走随心", "pos": (89, 345)},
         ]
         for text_data in text_list:
             text = self.get_text_value(text_data["text"])
             if not text:
                 text = text_data["default"]
-            _pp = PictureProcessing().get_text_image_advanced(
-                font=font_1,
-                text=text,
-                fill=(0, 0, 0),
-                return_mode="min_image",
-            )
+                if text_data["max"] > 0 and text:
+                    text = text[:text_data["max"]]
+            if text:
+                _pp = PictureProcessing().get_text_image_advanced(
+                    font=font_1,
+                    text=text,
+                    fill=(0, 0, 0),
+                    return_mode="min_image",
+                )
             pp_bg_1 = pp_bg_1.paste_img(top_img=_pp, value=text_data["pos"], base="nw")
         detailed_images.append(pp_bg_1)