Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
684d7059
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
12 个月 前同步成功
通知
1779
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
684d7059
编写于
12月 24, 2022
作者:
A
AUTOMATIC1111
提交者:
GitHub
12月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5808 from stysmmaker/patch/fix-fnt-size
Prevent overlapping in X/Y plot by changing font size
上级
55f3ef87
b7c478c3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
7 deletion
+16
-7
modules/images.py
modules/images.py
+16
-7
未找到文件。
modules/images.py
浏览文件 @
684d7059
...
@@ -136,8 +136,19 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
...
@@ -136,8 +136,19 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
lines
.
append
(
word
)
lines
.
append
(
word
)
return
lines
return
lines
def
draw_texts
(
drawing
,
draw_x
,
draw_y
,
lines
):
def
get_font
(
fontsize
):
try
:
return
ImageFont
.
truetype
(
opts
.
font
or
Roboto
,
fontsize
)
except
Exception
:
return
ImageFont
.
truetype
(
Roboto
,
fontsize
)
def
draw_texts
(
drawing
,
draw_x
,
draw_y
,
lines
,
initial_fnt
,
initial_fontsize
):
for
i
,
line
in
enumerate
(
lines
):
for
i
,
line
in
enumerate
(
lines
):
fnt
=
initial_fnt
fontsize
=
initial_fontsize
while
drawing
.
multiline_textsize
(
line
.
text
,
font
=
fnt
)[
0
]
>
line
.
allowed_width
and
fontsize
>
0
:
fontsize
-=
1
fnt
=
get_font
(
fontsize
)
drawing
.
multiline_text
((
draw_x
,
draw_y
+
line
.
size
[
1
]
/
2
),
line
.
text
,
font
=
fnt
,
fill
=
color_active
if
line
.
is_active
else
color_inactive
,
anchor
=
"mm"
,
align
=
"center"
)
drawing
.
multiline_text
((
draw_x
,
draw_y
+
line
.
size
[
1
]
/
2
),
line
.
text
,
font
=
fnt
,
fill
=
color_active
if
line
.
is_active
else
color_inactive
,
anchor
=
"mm"
,
align
=
"center"
)
if
not
line
.
is_active
:
if
not
line
.
is_active
:
...
@@ -148,10 +159,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
...
@@ -148,10 +159,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
fontsize
=
(
width
+
height
)
//
25
fontsize
=
(
width
+
height
)
//
25
line_spacing
=
fontsize
//
2
line_spacing
=
fontsize
//
2
try
:
fnt
=
get_font
(
fontsize
)
fnt
=
ImageFont
.
truetype
(
opts
.
font
or
Roboto
,
fontsize
)
except
Exception
:
fnt
=
ImageFont
.
truetype
(
Roboto
,
fontsize
)
color_active
=
(
0
,
0
,
0
)
color_active
=
(
0
,
0
,
0
)
color_inactive
=
(
153
,
153
,
153
)
color_inactive
=
(
153
,
153
,
153
)
...
@@ -178,6 +186,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
...
@@ -178,6 +186,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
for
line
in
texts
:
for
line
in
texts
:
bbox
=
calc_d
.
multiline_textbbox
((
0
,
0
),
line
.
text
,
font
=
fnt
)
bbox
=
calc_d
.
multiline_textbbox
((
0
,
0
),
line
.
text
,
font
=
fnt
)
line
.
size
=
(
bbox
[
2
]
-
bbox
[
0
],
bbox
[
3
]
-
bbox
[
1
])
line
.
size
=
(
bbox
[
2
]
-
bbox
[
0
],
bbox
[
3
]
-
bbox
[
1
])
line
.
allowed_width
=
allowed_width
hor_text_heights
=
[
sum
([
line
.
size
[
1
]
+
line_spacing
for
line
in
lines
])
-
line_spacing
for
lines
in
hor_texts
]
hor_text_heights
=
[
sum
([
line
.
size
[
1
]
+
line_spacing
for
line
in
lines
])
-
line_spacing
for
lines
in
hor_texts
]
ver_text_heights
=
[
sum
([
line
.
size
[
1
]
+
line_spacing
for
line
in
lines
])
-
line_spacing
*
len
(
lines
)
for
lines
in
ver_text_heights
=
[
sum
([
line
.
size
[
1
]
+
line_spacing
for
line
in
lines
])
-
line_spacing
*
len
(
lines
)
for
lines
in
...
@@ -194,13 +203,13 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
...
@@ -194,13 +203,13 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
x
=
pad_left
+
width
*
col
+
width
/
2
x
=
pad_left
+
width
*
col
+
width
/
2
y
=
pad_top
/
2
-
hor_text_heights
[
col
]
/
2
y
=
pad_top
/
2
-
hor_text_heights
[
col
]
/
2
draw_texts
(
d
,
x
,
y
,
hor_texts
[
col
])
draw_texts
(
d
,
x
,
y
,
hor_texts
[
col
]
,
fnt
,
fontsize
)
for
row
in
range
(
rows
):
for
row
in
range
(
rows
):
x
=
pad_left
/
2
x
=
pad_left
/
2
y
=
pad_top
+
height
*
row
+
height
/
2
-
ver_text_heights
[
row
]
/
2
y
=
pad_top
+
height
*
row
+
height
/
2
-
ver_text_heights
[
row
]
/
2
draw_texts
(
d
,
x
,
y
,
ver_texts
[
row
])
draw_texts
(
d
,
x
,
y
,
ver_texts
[
row
]
,
fnt
,
fontsize
)
return
result
return
result
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录