Merge pull request #10 from fchangjun/feat/20260409_add_font_node

Allow negative line spacing in preview node
This commit is contained in:
方长君
2026-04-13 19:24:50 +08:00
committed by GitHub
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -157,7 +157,7 @@ Parameters:
- `font_size_mode`: `fixed` uses the exact font size, `fit` scales text to the canvas
- `font_size`: base font size or max fitting size
- `char_spacing`: character spacing in pixels
- `line_spacing`: line spacing in pixels; `0` keeps the automatic spacing rule
- `line_spacing`: line spacing in pixels; `0` keeps the automatic spacing rule, positive values increase spacing, negative values pull lines closer together
- `bold`: prefer bold font variants, otherwise use a fallback bold draw mode
- `italic`: prefer italic font variants, otherwise use a fallback italic transform
- `background_color`: preview background color
@@ -400,7 +400,7 @@ Baidu Meux ComfyTools 是一组用于 ComfyUI 的自定义节点,服务于百
- `font_size_mode`:`fixed` 使用固定字号,`fit` 自动适配画布
- `font_size`:基础字号,或自动适配时的最大字号
- `char_spacing`:字符间距,单位为像素
- `line_spacing`:行间距,单位为像素;`0` 表示继续使用自动行间距规则
- `line_spacing`:行间距,单位为像素;`0` 表示继续使用自动行间距规则,正数拉开行距,负数压缩行距
- `bold`:优先匹配粗体字体,没有时走伪粗体回退
- `italic`:优先匹配斜体字体,没有时走伪斜体回退
- `background_color`:预览背景颜色
+2 -2
View File
@@ -40,7 +40,7 @@ class MeuxArtisticTextPreview:
"font_size_mode": (["fixed", "fit"], {"default": "fixed"}),
"font_size": ("INT", {"default": 128, "min": 8, "max": 1024, "step": 1}),
"char_spacing": ("INT", {"default": 0, "min": -20, "max": 200, "step": 1}),
"line_spacing": ("INT", {"default": 0, "min": 0, "max": 512, "step": 1}),
"line_spacing": ("INT", {"default": 0, "min": -512, "max": 512, "step": 1}),
"bold": ("BOOLEAN", {"default": False}),
"italic": ("BOOLEAN", {"default": False}),
"background_color": ("STRING", {"default": "#000000"}),
@@ -295,7 +295,7 @@ class MeuxArtisticTextPreview:
return width, height
def _resolve_line_spacing(self, font, line_spacing):
if int(line_spacing) > 0:
if int(line_spacing) != 0:
return int(line_spacing)
return max(6, font.size // 5 if hasattr(font, "size") else 6)