lcl: update font on Height change. Change the size only is not correct since LogFont contains lfHeight = Height. fixes bug #0013727

git-svn-id: trunk@20010 -
This commit is contained in:
paul 2009-05-17 13:57:24 +00:00
parent 331b3f8019
commit f977ee640b
4 changed files with 21 additions and 9 deletions

View File

@ -516,7 +516,7 @@ type
procedure SetColor(Value: TColor);
procedure SetFlags(Index: integer; AValue: boolean); override;
procedure SetFPColor(const AValue: TFPColor); override;
procedure SetHeight(value: Integer);
procedure SetHeight(Avalue: Integer);
procedure SetName(AValue: string); override;
procedure SetOrientation(AValue: Integer);
procedure SetPitch(Value: TFontPitch);

View File

@ -835,13 +835,25 @@ end;
Sets the height of a font
------------------------------------------------------------------------------}
procedure TFont.SetHeight(Value: Integer);
procedure TFont.SetHeight(AValue: Integer);
begin
if FHeight = Value then Exit;
// set Size first. This will set FHeight to a rounded equivalent
Size := -MulDiv(Value, 72, FPixelsPerInch);
// store the real FHeight
FHeight := Value;
// Don't update Size only. The LogFont contains a lfHeight value and on Windows,
// Qt and Carbon it is the main parameter which determins the font height.
if Height <> AValue then
begin
BeginUpdate;
try
FreeReference;
FHeight := AValue;
// update size to equivalent value
inherited SetSize(-MulDiv(AValue, 72, FPixelsPerInch));
if IsFontNameXLogicalFontDesc(Name) then
Name := ClearXLFDHeight(Name);
Changed;
finally
EndUpdate;
end;
end;
end;
{------------------------------------------------------------------------------

View File

@ -123,7 +123,7 @@ end;
function CreateFontIndirectEx(const LogFont: TLogFont;
const LongFontName: string): HFONT;
begin
Result := WidgetSet.CreateFontIndirectEx(LogFont,LongFontName);
Result := WidgetSet.CreateFontIndirectEx(LogFont, LongFontName);
end;
function CreateIconIndirect(IconInfo: PIconInfo): HICON;

View File

@ -188,7 +188,7 @@ begin
// NOTE: in gtk2.8 is possible to use pango_font_description_set_absolute_size
// which would be great with the given lfheight value, but older gtk2 version
// doesn't have this function
if lfHeight<0 then
if lfHeight < 0 then
aSize := -MulDiv(lfheight, 72, ScreenInfo.PixelsPerInchY) * PANGO_SCALE
else
aSize := lfHeight * PANGO_SCALE;