mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 21:59:19 +02:00
Qt: assign qt font when not owning painter instead of setting new font for QPainter. fixes #16646
git-svn-id: trunk@27236 -
This commit is contained in:
parent
74596e95e8
commit
6ac8338ecf
@ -740,6 +740,8 @@ function Clipboard: TQtClipboard;
|
|||||||
function QtDefaultContext: TQtDeviceContext;
|
function QtDefaultContext: TQtDeviceContext;
|
||||||
function QtScreenContext: TQtDeviceContext;
|
function QtScreenContext: TQtDeviceContext;
|
||||||
|
|
||||||
|
procedure AssignQtFont(FromFont: QFontH; ToFont: QFontH);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -831,6 +833,25 @@ begin
|
|||||||
Result := FScreenContext;
|
Result := FScreenContext;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AssignQtFont(FromFont: QFontH; ToFont: QFontH);
|
||||||
|
var
|
||||||
|
FntFam: WideString;
|
||||||
|
begin
|
||||||
|
QFont_family(FromFont, @FntFam);
|
||||||
|
QFont_setFamily(ToFont, @FntFam);
|
||||||
|
if QFont_pixelSize(FromFont) > 0 then
|
||||||
|
QFont_setPixelSize(ToFont, QFont_pixelSize(FromFont))
|
||||||
|
else
|
||||||
|
QFont_setPointSize(ToFont, QFont_pointSize(FromFont));
|
||||||
|
QFont_setWeight(ToFont, QFont_weight(FromFont));
|
||||||
|
QFont_setBold(ToFont, QFont_bold(FromFont));
|
||||||
|
QFont_setItalic(ToFont, QFont_italic(FromFont));
|
||||||
|
QFont_setUnderline(ToFont, QFont_underline(FromFont));
|
||||||
|
QFont_setStrikeOut(ToFont, QFont_strikeOut(FromFont));
|
||||||
|
QFont_setStyle(ToFont, QFont_style(FromFont));
|
||||||
|
QFont_setStyleStrategy(ToFont, QFont_styleStrategy(FromFont));
|
||||||
|
end;
|
||||||
|
|
||||||
{ TQtObject }
|
{ TQtObject }
|
||||||
|
|
||||||
constructor TQtObject.Create;
|
constructor TQtObject.Create;
|
||||||
@ -2303,17 +2324,7 @@ end;
|
|||||||
|
|
||||||
function TQtDeviceContext.GetMetrics: TQtFontMetrics;
|
function TQtDeviceContext.GetMetrics: TQtFontMetrics;
|
||||||
begin
|
begin
|
||||||
{$note this is workaround for qt bug when QPainter refuses to
|
Result := Font.Metrics
|
||||||
set font (Vista & Win7 themes).See #16646.
|
|
||||||
No harm for other platforms with this patch.}
|
|
||||||
if FOwnPainter then
|
|
||||||
Result := Font.Metrics
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
if FMetrics = nil then
|
|
||||||
FMetrics := TQtFontMetrics.Create(QPainter_font(Widget));
|
|
||||||
Result := FMetrics;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -2635,6 +2646,8 @@ end;
|
|||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TQtDeviceContext.setFont(AFont: TQtFont);
|
procedure TQtDeviceContext.setFont(AFont: TQtFont);
|
||||||
|
var
|
||||||
|
QFnt: QFontH;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
Write('TQtDeviceContext.setFont() ');
|
Write('TQtDeviceContext.setFont() ');
|
||||||
@ -2642,7 +2655,12 @@ begin
|
|||||||
SelFont := AFont;
|
SelFont := AFont;
|
||||||
if (AFont.Widget <> nil) and (Widget <> nil) then
|
if (AFont.Widget <> nil) and (Widget <> nil) then
|
||||||
begin
|
begin
|
||||||
QPainter_setFont(Widget, QFontH(AFont.Widget));
|
if not FOwnPainter then
|
||||||
|
begin
|
||||||
|
QFnt := QPainter_font(Widget);
|
||||||
|
AssignQtFont(AFont.Widget, QFnt);
|
||||||
|
end else
|
||||||
|
QPainter_setFont(Widget, QFontH(AFont.Widget));
|
||||||
vFont.Angle := AFont.Angle;
|
vFont.Angle := AFont.Angle;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user