Answer the question
In order to leave comments, you need to log in
What causes the CreateFontIndirect failed for family error?
PyQt application, with a QTableWidget table, QTextBrowser and other forms (I just don't know what specifically caused the error).
There is a list of several thousand elements, each element is checked and a row is added to the table.
Actually, if you check 1000 at a time, then everything works fine.
I also tried 2000, 3000, 4000, but errors have already appeared on 5000:
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'MS Shell Dlg 2' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'MS Shell Dlg 2' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'Arial' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'MS UI Gothic' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'SimSun' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'Arial Unicode MS' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'Segoe UI Emoji' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
QWindowsFontDatabase::createEngine: CreateFontIndirect failed (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: CreateFontIndirect failed for family 'Segoe UI Symbol' (Операция успешно завершена.)
QWindowsFontEngine::QWindowsFontEngine: GetTextMetrics failed (Неверный дескриптор.)
OpenType support missing for "Segoe UI", script 20
OpenType support missing for "MS Shell Dlg 2", script 20
OpenType support missing for "Arial", script 20
OpenType support missing for "MS UI Gothic", script 20
OpenType support missing for "SimSun", script 20
OpenType support missing for "Arial Unicode MS", script 20
OpenType support missing for "Segoe UI Emoji", script 20
OpenType support missing for "Segoe UI Symbol", script 20
OpenType support missing for "Nirmala UI", script 20
import sys
from PyQt5 import QtWidgets, QtGui, QtCore, Qt
from time import sleep
import threading
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1479, 781)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
MainWindow.setMinimumSize(QtCore.QSize(1479, 781))
MainWindow.setMaximumSize(QtCore.QSize(1479, 781))
font = QtGui.QFont()
font.setPointSize(9)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setMinimumSize(QtCore.QSize(1479, 781))
self.centralwidget.setMaximumSize(QtCore.QSize(1479, 781))
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(0, 0, 61, 16))
self.label.setObjectName("label")
self.all_accounts = QtWidgets.QTextBrowser(self.centralwidget)
self.all_accounts.setGeometry(QtCore.QRect(0, 20, 791, 521))
self.all_accounts.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
self.all_accounts.setReadOnly(False)
self.all_accounts.setAcceptRichText(False)
self.all_accounts.setObjectName("all_accounts")
self.del_duplicate_accs = QtWidgets.QPushButton(self.centralwidget)
self.del_duplicate_accs.setGeometry(QtCore.QRect(660, 550, 131, 23))
font = QtGui.QFont()
font.setPointSize(8)
self.del_duplicate_accs.setFont(font)
self.del_duplicate_accs.setObjectName("del_duplicate_accs")
self.count_accs = QtWidgets.QLabel(self.centralwidget)
self.count_accs.setGeometry(QtCore.QRect(430, 0, 91, 16))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(True)
font.setWeight(75)
self.count_accs.setFont(font)
self.count_accs.setObjectName("count_accs")
self.retranslateUi(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Check"))
self.label.setText(_translate("MainWindow", "Аккаунты:"))
self.del_duplicate_accs.setText(_translate("MainWindow", "Удалить дубли по лог."))
self.count_accs.setText(_translate("MainWindow", "0"))
class ExampleApp(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.logins = []
self.accounts = []
self.max_threads = 200
self.dupl_log = []
self.thr = 0
self.all_accounts.textChanged.connect(self.all_accounts_f)
self.del_duplicate_accs.clicked.connect(self.del_dupl_accs)
# изменение списка
def all_accounts_f(self):
self.accounts = []
lists = self.all_accounts.toPlainText().split('\n')
for l in lists:
if l != '' and l != '\n':
self.accounts.append(l)
self.count_accs.setText(str(len(self.accounts)))
# удалить дубликаты акков по логину
def del_dupl_accs(self):
self.all_accounts.blockSignals(True)
if self.count_accs.text() != '0':
self.all_accounts.clear()
self.dupl_log = []
self.logins = [item.split(':')[0] for item in self.accounts]
self.logins = list(set(self.logins))
for item in self.accounts:
while self.thr > self.max_threads:
sleep(0.1)
self.thr += 1
x = threading.Thread(target=self.check_dupl, args=(item,), daemon=True)
x.start()
while self.thr > 0:
sleep(0.1)
for item in self.dupl_log:
self.accounts.pop(self.accounts.index(item))
self.count_accs.setText(str(len(self.accounts)))
self.all_accounts.blockSignals(False)
# поток для проверки дублей (по бд) по логину
def check_dupl(self, item):
if item.split(':')[0] in self.logins:
self.logins.pop(self.logins.index(item.split(':')[0]))
self.all_accounts.append(item)
else:
self.dupl_log.append(item)
self.thr -= 1
def main():
app = QtWidgets.QApplication(sys.argv)
window = ExampleApp()
window.show()
app.exec_()
if __name__ == '__main__':
main()
Answer the question
In order to leave comments, you need to log in
First, deal with the kryakozyabrs - this is the wrong encoding. 866 instead of 1251 or vice versa.
What is script 20 - see: https://docs.microsoft.com/en-us/typography/openty...
You are doing something strange with fonts. Although this may be the result of the fact that the memory is over / broken. Just in the console version, working with the database does not cause errors?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question