This commit is contained in:
恍兮惚兮 2024-06-22 00:51:53 +08:00
parent 75e84fd22e
commit 0bed820401
7 changed files with 114 additions and 31 deletions

View File

@ -14,7 +14,6 @@ from gui.usefulwidget import (
D_getIconButton,
D_getcolorbutton,
getcolorbutton,
getboxlayout,
D_getsimpleswitch,
selectcolor,
FocusFontCombo,
@ -179,7 +178,7 @@ def createinternalfontsettings(self, forml, group, _type):
lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
forml.addRow(
name,
_TR(name),
lineW,
)

View File

@ -9,22 +9,22 @@ class TextLine(base):
def paintText(self, painter: QPainter):
self.m_outLineColor, self.m_contentColor = self.colorpair()
self.m_fontOutLineWidth = self.config["width"]
fontOutLineWidth = self.config["width"]
text = self.text()
font = self.font()
font_m = QFontMetrics(font)
path = QPainterPath()
path.addText(
self.m_fontOutLineWidth,
self.m_fontOutLineWidth + font_m.ascent(),
fontOutLineWidth,
fontOutLineWidth + font_m.ascent(),
font,
text,
)
pen = QPen(
self.m_outLineColor,
self.m_fontOutLineWidth,
fontOutLineWidth,
Qt.PenStyle.SolidLine,
Qt.PenCapStyle.RoundCap,
Qt.PenJoinStyle.RoundJoin,

View File

@ -3,28 +3,44 @@ from rendertext.textbrowser_imp.base import base
class TextLine(base):
def moveoffset(self):
font = self.font()
fontOutLineWidth = (
self.config["width"] + font.pointSizeF() * self.config["width_rate"]
)
return fontOutLineWidth, fontOutLineWidth
def extraWH(self):
font = self.font()
fontOutLineWidth = (
self.config["width"] + font.pointSizeF() * self.config["width_rate"]
)
fontOutLineWidth *= 2
return fontOutLineWidth, fontOutLineWidth
def colorpair(self):
return QColor(self.config["fillcolor"]), QColor(self.basecolor)
def paintText(self, painter: QPainter):
self.m_outLineColor, self.m_contentColor = self.colorpair()
self.m_fontOutLineWidth = self.config["width"]
text = self.text()
font = self.font()
fontOutLineWidth = (
self.config["width"] + font.pointSizeF() * self.config["width_rate"]
)
font_m = QFontMetrics(font)
path = QPainterPath()
path.addText(
self.m_fontOutLineWidth,
self.m_fontOutLineWidth + font_m.ascent(),
fontOutLineWidth,
fontOutLineWidth + font_m.ascent(),
font,
text,
)
pen = QPen(
self.m_outLineColor,
self.m_fontOutLineWidth,
fontOutLineWidth,
Qt.PenStyle.SolidLine,
Qt.PenCapStyle.RoundCap,
Qt.PenJoinStyle.RoundJoin,

View File

@ -13,6 +13,21 @@ class QGraphicsDropShadowEffect_multi(QGraphicsDropShadowEffect):
class TextLine(TextLabel_0):
def moveoffset(self):
font = self.font()
fontOutLineWidth = (
font.pointSizeF() * self.config["shadowR"] + self.config["shadowR_ex"]
)
return fontOutLineWidth, fontOutLineWidth
def extraWH(self):
font = self.font()
fontOutLineWidth = (
font.pointSizeF() * self.config["shadowR"] + self.config["shadowR_ex"]
)
fontOutLineWidth *= 2
return fontOutLineWidth, fontOutLineWidth
def usingcolor(self):
return QColor(self.config["fillcolor"])
@ -29,6 +44,6 @@ class TextLine(TextLabel_0):
font = self.font()
self.setShadow_internal(
self.basecolor,
font.pointSizeF() * self.config["shadowR"],
font.pointSizeF() * self.config["shadowR"] + self.config["shadowR_ex"],
self.config["shadowforce"],
)

View File

@ -59,7 +59,7 @@
let ntimes = ""
for (let i = 0; i < styleargs.shadowforce; i++) {
ntimes += `0px 0px ${args.fontSize * styleargs.shadowR}px ${args.color}`
ntimes += `0px 0px ${args.fontSize * styleargs.shadowR + styleargs.shadowR_ex}px ${args.color}`
if (i == styleargs.shadowforce - 1)
ntimes += ";"
else
@ -93,7 +93,7 @@
let style = document.createElement('style')
style.innerHTML = `
#${_id} .stroken{
-webkit-text-stroke: ${styleargs.width}px ${c1};
-webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
position: relative;
}
#${_id} .stroken::after {
@ -207,7 +207,7 @@
if (isshow_fenci || isfenciclick) {
let div = document.createElement('div')
div.style.display='inline-block'
div.style.display = 'inline-block'
div.id = _simpleuid()
let style = document.createElement('style')
if (isshow_fenci)

View File

@ -33,7 +33,8 @@
"args": {
"fillcolor": "#eeeeee",
"shadowforce": 5,
"shadowR": 0.4
"shadowR": 0.1,
"shadowR_ex": 3
},
"argstype": {
"fillcolor": {
@ -48,10 +49,17 @@
"step": 1
},
"shadowR": {
"name": "阴影半径_倍率",
"name": "阴影半径_字体倍率",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 10,
"step": 0.01
},
"shadowR_ex": {
"name": "阴影半径_固定值",
"type": "spin",
"min": 0,
"max": 100,
"step": 0.1
}
}
@ -70,7 +78,7 @@
"width": {
"name": "描边宽度",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 100,
"step": 0.1
}
@ -80,6 +88,7 @@
"name": "描边字体_2",
"args": {
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3
},
"argstype": {
@ -88,11 +97,18 @@
"type": "colorselect"
},
"width": {
"name": "描边宽度",
"name": "描边宽度_固定值",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 100,
"step": 0.1
},
"width_rate": {
"name": "描边宽度_字体倍率",
"type": "spin",
"min": 0,
"max": 10,
"step": 0.01
}
}
},
@ -100,6 +116,7 @@
"name": "描边字体_3",
"args": {
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3
},
"argstype": {
@ -108,11 +125,18 @@
"type": "colorselect"
},
"width": {
"name": "描边宽度",
"name": "描边宽度_固定值",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 100,
"step": 0.1
},
"width_rate": {
"name": "描边宽度_字体倍率",
"type": "spin",
"min": 0,
"max": 10,
"step": 0.01
}
}
}
@ -145,6 +169,7 @@
"name": "描边字体_2",
"args": {
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3
},
"argstype": {
@ -153,11 +178,18 @@
"type": "colorselect"
},
"width": {
"name": "描边宽度",
"name": "描边宽度_固定值",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 100,
"step": 0.1
},
"width_rate": {
"name": "描边宽度_字体倍率",
"type": "spin",
"min": 0,
"max": 10,
"step": 0.01
}
}
},
@ -165,6 +197,7 @@
"name": "描边字体_3",
"args": {
"fillcolor": "#eeeeee",
"width_rate": 0.1,
"width": 3
},
"argstype": {
@ -173,11 +206,18 @@
"type": "colorselect"
},
"width": {
"name": "描边宽度",
"name": "描边宽度_固定值",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 100,
"step": 0.1
},
"width_rate": {
"name": "描边宽度_字体倍率",
"type": "spin",
"min": 0,
"max": 10,
"step": 0.01
}
}
},
@ -186,7 +226,8 @@
"args": {
"fillcolor": "#eeeeee",
"shadowforce": 5,
"shadowR": 1
"shadowR": 1,
"shadowR_ex": 3
},
"argstype": {
"fillcolor": {
@ -201,10 +242,17 @@
"step": 1
},
"shadowR": {
"name": "阴影半径_倍率",
"name": "阴影半径_字体倍率",
"type": "spin",
"min": 0.1,
"min": 0,
"max": 10,
"step": 0.01
},
"shadowR_ex": {
"name": "阴影半径_固定值",
"type": "spin",
"min": 0,
"max": 100,
"step": 0.1
}
}

View File

@ -803,5 +803,10 @@
"按钮大小": "",
"软件显示语言": "",
"重启生效": "",
"不支持的游戏?": ""
"不支持的游戏?": "",
"填充颜色": "",
"阴影强度": "",
"阴影半径": "",
"字体倍率": "",
"固定值": ""
}