mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-14 12:36:14 +02:00
CairoCanvas: implement default values for default font (fix fonts on exporting LazReport grid using cairo export)
git-svn-id: trunk@52568 -
This commit is contained in:
parent
72d7b7a01a
commit
a3fdf62ba2
@ -38,7 +38,7 @@ type
|
|||||||
procedure UpdatePangoLayout(Layout: PPangoLayout);
|
procedure UpdatePangoLayout(Layout: PPangoLayout);
|
||||||
{$endif}
|
{$endif}
|
||||||
procedure SelectFontEx(AStyle: TFontStyles; const AName: string;
|
procedure SelectFontEx(AStyle: TFontStyles; const AName: string;
|
||||||
ASize: double);
|
ASize: double; aPitch: TFontPitch);
|
||||||
function SX(x: double): double;
|
function SX(x: double): double;
|
||||||
function SY(y: double): double;
|
function SY(y: double): double;
|
||||||
function SX2(x: double): double;
|
function SX2(x: double): double;
|
||||||
@ -934,16 +934,17 @@ end;
|
|||||||
procedure TCairoPrinterCanvas.SelectFont;
|
procedure TCairoPrinterCanvas.SelectFont;
|
||||||
begin
|
begin
|
||||||
RequiredState([csHandleValid]);
|
RequiredState([csHandleValid]);
|
||||||
SelectFontEx(Font.Style, Font.Name, abs(Font.Size));
|
SelectFontEx(Font.Style, Font.Name, abs(Font.Size), Font.Pitch);
|
||||||
SetSourceColor(Font.Color);
|
SetSourceColor(Font.Color);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCairoPrinterCanvas.SelectFontEx(AStyle: TFontStyles; const AName: string; ASize: double);
|
procedure TCairoPrinterCanvas.SelectFontEx(AStyle: TFontStyles;
|
||||||
|
const AName: string; ASize: double; aPitch: TFontPitch);
|
||||||
var
|
var
|
||||||
slant: cairo_font_slant_t;
|
slant: cairo_font_slant_t;
|
||||||
weight: cairo_font_weight_t;
|
weight: cairo_font_weight_t;
|
||||||
{$ifdef pangocairo}
|
{$ifdef pangocairo}
|
||||||
S: string;
|
S, aFontName: string;
|
||||||
{$endif}
|
{$endif}
|
||||||
begin
|
begin
|
||||||
if fsBold in Font.Style then
|
if fsBold in Font.Style then
|
||||||
@ -955,7 +956,16 @@ begin
|
|||||||
else
|
else
|
||||||
slant := CAIRO_FONT_SLANT_NORMAL;
|
slant := CAIRO_FONT_SLANT_NORMAL;
|
||||||
{$ifdef pangocairo}
|
{$ifdef pangocairo}
|
||||||
S := format('%s %s %dpx',[AName, StylesToStr(AStyle), round(ASize)]);
|
if ASize<0.001 then
|
||||||
|
ASize := 10.0;
|
||||||
|
aFontName := AName;
|
||||||
|
if (aFontName='') or SameText(aFontName, 'default') then begin
|
||||||
|
if aPitch=fpFixed then
|
||||||
|
aFontName := 'monospace'
|
||||||
|
else
|
||||||
|
aFontName := 'sans-serif';
|
||||||
|
end;
|
||||||
|
S := format('%s %s %dpx',[aFontName, StylesToStr(AStyle), round(ASize)]);
|
||||||
if (fFontDesc=nil) or (S<>fFontDescStr) then
|
if (fFontDesc=nil) or (S<>fFontDescStr) then
|
||||||
begin
|
begin
|
||||||
if fFontDesc<>nil then
|
if fFontDesc<>nil then
|
||||||
@ -1148,7 +1158,7 @@ begin
|
|||||||
|
|
||||||
if Style.SystemFont and Assigned(OnGetSystemFont) then begin
|
if Style.SystemFont and Assigned(OnGetSystemFont) then begin
|
||||||
fd := GetFontData(OnGetSystemFont());
|
fd := GetFontData(OnGetSystemFont());
|
||||||
SelectFontEx(fd.Style, fd.Name, fd.Height);
|
SelectFontEx(fd.Style, fd.Name, fd.Height, fd.Pitch);
|
||||||
SetSourceColor(clWindowText);
|
SetSourceColor(clWindowText);
|
||||||
end else
|
end else
|
||||||
SelectFont;
|
SelectFont;
|
||||||
|
Loading…
Reference in New Issue
Block a user