Qt6: simplified code. Patch by Alexey Torgashin.

This commit is contained in:
Željan Rikalo 2022-11-12 11:52:31 +01:00
parent 3a6e8bfc0f
commit 6e997e296e
2 changed files with 19 additions and 29 deletions
lcl/interfaces/qt6

View File

@ -477,6 +477,23 @@ begin
until Result <> nil;
end;
function ConvertFontWeightToQtConst(Value: Integer): Integer;
begin
case Value of
QtFontWeight_Thin: Result := FW_THIN;
QtFontWeight_ExtraLight: Result := FW_EXTRALIGHT;
QtFontWeight_Light: Result := FW_LIGHT;
QtFontWeight_Normal: Result := FW_NORMAL;
QtFontWeight_Medium: Result := FW_MEDIUM;
QtFontWeight_DemiBold: Result := FW_SEMIBOLD;
QtFontWeight_Bold: Result := FW_BOLD;
QtFontWeight_ExtraBold: Result := FW_EXTRABOLD;
QtFontWeight_Black: Result := FW_HEAVY;
else
Result := Round(Value * 9.5);
end;
end;
{------------------------------------------------------------------------------
Method: GetQtVersion
Params: none

View File

@ -3184,21 +3184,7 @@ begin
end else
ALogFont^.lfHeight := AFont.getPixelSize;
ALogFont^.lfEscapement := AFont.Angle;
case AFont.getWeight of
QtFontWeight_Thin: ALogFont^.lfWeight := FW_THIN;
QtFontWeight_ExtraLight: ALogFont^.lfWeight := FW_EXTRALIGHT;
QtFontWeight_Light: ALogFont^.lfWeight := FW_LIGHT;
QtFontWeight_Normal: ALogFont^.lfWeight := FW_NORMAL;
QtFontWeight_Medium: ALogFont^.lfWeight := FW_MEDIUM;
QtFontWeight_DemiBold: ALogFont^.lfWeight := FW_SEMIBOLD;
QtFontWeight_Bold: ALogFont^.lfWeight := FW_BOLD;
QtFontWeight_ExtraBold: ALogFont^.lfWeight := FW_EXTRABOLD;
QtFontWeight_Black: ALogFont^.lfWeight := FW_HEAVY;
else
ALogFont^.lfWeight := Round(AFont.getWeight * 9.5);
end;
ALogFont^.lfWeight := ConvertFontWeightToQtConst(AFont.getWeight);
ALogFont^.lfItalic := Ord(AFont.getItalic) * High(Byte);
ALogFont^.lfUnderline := Ord(AFont.getUnderline) * High(Byte);
ALogFont^.lfStrikeOut := Ord(AFont.getStrikeOut) * High(Byte);
@ -4357,20 +4343,7 @@ begin
TM.tmMaxCharWidth := QtFontMetrics.maxWidth;
FontWeight := QtDC.font.getWeight;
case FontWeight of
QtFontWeight_Thin: TM.tmWeight := FW_THIN;
QtFontWeight_ExtraLight: TM.tmWeight := FW_EXTRALIGHT;
QtFontWeight_Light: TM.tmWeight := FW_LIGHT;
QtFontWeight_Normal: TM.tmWeight := FW_NORMAL;
QtFontWeight_Medium: TM.tmWeight := FW_MEDIUM;
QtFontWeight_DemiBold: TM.tmWeight := FW_SEMIBOLD;
QtFontWeight_Bold: TM.tmWeight := FW_BOLD;
QtFontWeight_ExtraBold: TM.tmWeight := FW_EXTRABOLD;
QtFontWeight_Black: TM.tmWeight := FW_HEAVY;
else
TM.tmWeight := Round(FontWeight * 9.5);
end;
TM.tmWeight := ConvertFontWeightToQtConst(FontWeight);
TM.tmOverhang := 0;
TM.tmDigitizedAspectX := 0;
TM.tmDigitizedAspectY := 0;