Files
fluent_widgets_pyside6/qfluentwidgets/common/font.py

38 lines
770 B
Python
Raw Normal View History

2025-08-14 18:45:16 +08:00
# coding: utf-8
from PySide6.QtGui import QFont
from PySide6.QtWidgets import QWidget
def setFont(widget: QWidget, fontSize=14, weight=QFont.Normal):
""" set the font of widget
Parameters
----------
widget: QWidget
the widget to set font
fontSize: int
font pixel size
weight: `QFont.Weight`
font weight
"""
widget.setFont(getFont(fontSize, weight))
def getFont(fontSize=14, weight=QFont.Normal):
""" create font
Parameters
----------
fontSize: int
font pixel size
weight: `QFont.Weight`
font weight
"""
font = QFont()
font.setFamilies(['Segoe UI', 'Microsoft YaHei', 'PingFang SC'])
font.setPixelSize(fontSize)
font.setWeight(weight)
return font