After some research, the correct sequence was found to select the Monospace font on Linux and to select an alternate fixed width font on Windows. First the current font is obtained from the QTextEdit base class. The font is set to fixed pitch to indicate the type of font desired if the selected font family is not found. The font family is set to the "Monospace" string and the style hint is set to Monospace. Finally the current font is set to this modified font. This code was put into the EditBox constructor:
QFont font = currentFont();On Windows (XP, 7 and 8), this appears to select the Courier New font at a fairly small 8 point font, which doesn't look so good on XP, but better on 7 and 8. The size of the Monospace font on Linux also looks to be an 8 point font. This is good enough for the now and eventually a font selection dialog will be added so that any font and size can be selected.
font.setFixedPitch(true);
font.setFamily("Monospace");
font.setStyleHint(QFont::Monospace);
setCurrentFont(font);
[commit 7155b30097]
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)