macOS: respect underline attribute in menu item fonts

When we draw menu item text with CoreText instead of QPainter, then we
need to translate QFont::underline() explicitly to an entry in the
attribute dictionary.

Task-number: QTBUG-73990
Pick-to: 6.1 5.15
Change-Id: I7e0c258f7cf80a89b29517fa8122576342654de1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Volker Hilsheimer 2021-05-27 11:44:30 +02:00
parent 6ac2b902d1
commit 5ac479f599
1 changed files with 4 additions and 2 deletions

View File

@ -4376,8 +4376,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// line-break the string if it doesn't fit the given rect. It's better to draw outside
// the rect and possibly overlap something than to have part of the text disappear.
[s.toNSString() drawAtPoint:CGPointMake(xpos, yPos)
withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c,
NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0]}];
withAttributes:@{ NSFontAttributeName:f, NSForegroundColorAttributeName:c,
NSObliquenessAttributeName: [NSNumber numberWithDouble: myFont.italic() ? 0.3 : 0.0],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt: myFont.underline() ? NSUnderlineStyleSingle
: NSUnderlineStyleNone]}];
d->restoreNSGraphicsContext(cgCtx);
} else {