From The Compiler, 1 Year ago, written in Python.
Embed
  1. import sys
  2. from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel
  3. from PyQt5.QtGui import QFont, QFontDatabase
  4.  
  5. app = QApplication(sys.argv)
  6. widget = QWidget()
  7. layout = QVBoxLayout(widget)
  8.  
  9. font1 = QFont()
  10. font1.setStyleHint(QFont.Monospace)
  11. fam1 = font1.defaultFamily()
  12. font1.setFamily(fam1)
  13.  
  14. font2 = QFont()
  15. font2.setStyleHint(QFont.TypeWriter)
  16. fam2 = font2.defaultFamily()
  17. font2.setFamily(fam1)
  18.  
  19. font3 = QFontDatabase.systemFont(QFontDatabase.FixedFont)
  20. fam3 = font3.family()
  21.  
  22. label1 = QLabel()
  23. label1.setText(fam1)
  24. label1.setFont(font1)
  25. layout.addWidget(label1)
  26.  
  27. label2 = QLabel()
  28. label2.setText(fam2)
  29. label2.setFont(font2)
  30. layout.addWidget(label2)
  31.  
  32. label3 = QLabel()
  33. label3.setText(fam3)
  34. label3.setFont(font3)
  35. layout.addWidget(label3)
  36.  
  37. widget.show()
  38. app.exec_()
  39.  

Replies to fonttest.py rss

Title Name Language When
Re: fonttest.py Dmitry Shachnev text 9 Months ago.