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_getIconButton,
D_getcolorbutton, D_getcolorbutton,
getcolorbutton, getcolorbutton,
getboxlayout,
D_getsimpleswitch, D_getsimpleswitch,
selectcolor, selectcolor,
FocusFontCombo, FocusFontCombo,
@ -179,7 +178,7 @@ def createinternalfontsettings(self, forml, group, _type):
lineW.setValue(dd[key]) lineW.setValue(dd[key])
lineW.valueChanged.connect(functools.partial(dd.__setitem__, key)) lineW.valueChanged.connect(functools.partial(dd.__setitem__, key))
forml.addRow( forml.addRow(
name, _TR(name),
lineW, lineW,
) )

View File

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

View File

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

View File

@ -13,6 +13,21 @@ class QGraphicsDropShadowEffect_multi(QGraphicsDropShadowEffect):
class TextLine(TextLabel_0): 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): def usingcolor(self):
return QColor(self.config["fillcolor"]) return QColor(self.config["fillcolor"])
@ -29,6 +44,6 @@ class TextLine(TextLabel_0):
font = self.font() font = self.font()
self.setShadow_internal( self.setShadow_internal(
self.basecolor, self.basecolor,
font.pointSizeF() * self.config["shadowR"], font.pointSizeF() * self.config["shadowR"] + self.config["shadowR_ex"],
self.config["shadowforce"], self.config["shadowforce"],
) )

View File

@ -59,7 +59,7 @@
let ntimes = "" let ntimes = ""
for (let i = 0; i < styleargs.shadowforce; i++) { 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) if (i == styleargs.shadowforce - 1)
ntimes += ";" ntimes += ";"
else else
@ -93,7 +93,7 @@
let style = document.createElement('style') let style = document.createElement('style')
style.innerHTML = ` style.innerHTML = `
#${_id} .stroken{ #${_id} .stroken{
-webkit-text-stroke: ${styleargs.width}px ${c1}; -webkit-text-stroke: ${args.fontSize * styleargs.width_rate + styleargs.width}px ${c1};
position: relative; position: relative;
} }
#${_id} .stroken::after { #${_id} .stroken::after {

View File

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

View File

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