QTextEdit setting font often doesn't work
-
I'm trying to use QTextEdit and I want to be able to freely set the fonts of the text in the document.
However I'm finding that often this operation doesn't work.
Most common font names will not set i.e. the native equivalents of Courier, Arial and others are not automatically found and the set font operation fails.
However sometimes it works.
Does anyone know a reliable way to set the font such that the native equivalent font will be found and the operation will succeed every time? -
I'm trying to use QTextEdit and I want to be able to freely set the fonts of the text in the document.
However I'm finding that often this operation doesn't work.
Most common font names will not set i.e. the native equivalents of Courier, Arial and others are not automatically found and the set font operation fails.
However sometimes it works.
Does anyone know a reliable way to set the font such that the native equivalent font will be found and the operation will succeed every time? -
@clarify if they can not be found automatically or not available on some machines, you can
https://stackoverflow.com/questions/30973781/qt-add-custom-font-from-resource@JoeCFD
I should clarify. What I'm doing is this:- Load HTML file into QTextEdit which uses many fonts.
- Select-All (control-A)
- Set font.
What I find is that the first paragraph is successfully changed, even to Courier. The rest of it cannot be changed.
Sometimes I can set the entire document to the Gentium font, but not to any others.Second test:
- Load HTML file into QTextEdit which uses many fonts.
- Select any paragraph after the first.
- Set font.
Observe that the font family will not change. Other characteristics can be changed e.g. bold, text color, text size.
Third test:
I just now added a little code to convert to native Linux font family names but that only helped a little. Some text still won't change. This is very discouraging. I assumed QTextEdit was better tested and less buggy than this. But I'm seeing bug after bug.Fourth test:
Replace all SPAN tags in my HTML with FONT tags.
That seems to work... -
@JoeCFD
I should clarify. What I'm doing is this:- Load HTML file into QTextEdit which uses many fonts.
- Select-All (control-A)
- Set font.
What I find is that the first paragraph is successfully changed, even to Courier. The rest of it cannot be changed.
Sometimes I can set the entire document to the Gentium font, but not to any others.Second test:
- Load HTML file into QTextEdit which uses many fonts.
- Select any paragraph after the first.
- Set font.
Observe that the font family will not change. Other characteristics can be changed e.g. bold, text color, text size.
Third test:
I just now added a little code to convert to native Linux font family names but that only helped a little. Some text still won't change. This is very discouraging. I assumed QTextEdit was better tested and less buggy than this. But I'm seeing bug after bug.Fourth test:
Replace all SPAN tags in my HTML with FONT tags.
That seems to work... -
@clarify Do not expect everything works smoothly. Try to fix bugs when they show up. That is a part of your job.
-
@JoeCFD I don't work for Qt, I'm just a user of their code.
I'm working around their bugs, but it would be nicer if their bugs didn't exist in the first place. Or at least that they were documented somewhere. Their bugs are wasting my time.