MCPcopy
hub / github.com/tonquer/JMComic-qt / SetFont

Method SetFont

src/qt_owner.py:325–360  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

323
324 @staticmethod
325 def SetFont():
326 try:
327 from tools.log import Log
328 from config.setting import Setting
329 from PySide6.QtGui import QFont
330 f = QFont()
331 from tools.langconv import Converter
332 if Converter('zh-hans').convert(Setting.FontName.value) == "默认":
333 Setting.FontName.InitValue("", "FontName")
334
335 if not Setting.FontName.value and sys.platform == "win32":
336 Setting.FontName.InitValue("微软雅黑", "FontName")
337
338 if Converter('zh-hans').convert(str(Setting.FontSize.value)) == "默认":
339 Setting.FontSize.InitValue("", "FontSize")
340
341 if Converter('zh-hans').convert(str(Setting.FontStyle.value)) == "默认":
342 Setting.FontStyle.InitValue(0, "FontStyle")
343
344 if not Setting.FontName.value and not Setting.FontSize.value and not Setting.FontStyle.value:
345 return
346
347 if Setting.FontName.value:
348 f = QFont(Setting.FontName.value)
349
350 if Setting.FontSize.value and Setting.FontSize.value != "Defalut":
351 f.setPointSize(int(Setting.FontSize.value))
352
353 if Setting.FontStyle.value:
354 fontStyleList = [QFont.Light, QFont.Normal, QFont.DemiBold, QFont.Bold, QFont.Black]
355 f.setWeight(fontStyleList[Setting.FontStyle.value - 1])
356
357 QtOwner().app.setFont(f)
358
359 except Exception as es:
360 Log.Error(es)
361
362 # def ShowMsg(self, data):
363 # return self.owner.msgForm.ShowMsg(data)

Callers 1

start.pyFile · 0.80

Calls 5

ConverterClass · 0.90
QtOwnerClass · 0.85
convertMethod · 0.80
InitValueMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected