richmemo: added wsgetfontparams to handle missing informations

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4010 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-03-09 03:10:06 +00:00
parent 9f26fd4b79
commit 896ff5fe08
2 changed files with 19 additions and 8 deletions

View File

@@ -293,11 +293,16 @@ end;
function GetFontParams(AFont: TFont): TFontParams; overload;
var
data : TFontData;
wstest : Boolean;
begin
InitFontParams(Result);
if not Assigned(AFont) then Exit;
if AFont.Reference.Handle <> 0 then begin
// WSGetFontParams is introduced, because default Gtk widgetset returns
// only FontName from the handle.
wstest:= Assigned(WSGetFontParams) and WSGetFontParams(AFont.Reference.Handle, Result);
if not wstest then begin
data:=GetFontData(AFont.Reference.Handle);
if data.Height<0
then Result.Size:=round(abs(data.Height)/ScreenInfo.PixelsPerInchY*72)
@@ -305,6 +310,7 @@ begin
Result.Name:=data.Name;
Result.Color:=AFont.Color;
Result.Style:=data.Style;
end;
end else begin
Result.Name := AFont.Name;
Result.Color := AFont.Color;

View File

@@ -25,6 +25,7 @@ interface
uses
Types, Classes, SysUtils,
LCLType,
Graphics, Controls, StdCtrls,
WSStdCtrls, RichMemo;
@@ -103,6 +104,10 @@ type
function WSRegisterCustomRichMemo: Boolean; external name 'WSRegisterCustomRichMemo';
var
//note: this internal function might go away eventually!
WSGetFontParams: function (wsfontref: HFONT; var params: TFontParams): Boolean = nil;
implementation
{ TWSCustomRichMemo }