mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 02:19:39 +02:00
LCL: Use a helper function for testing fontname 'default'. Issue #31940, patch from AlexeyT.
git-svn-id: trunk@55188 -
This commit is contained in:
parent
6add4a7106
commit
1184822164
@ -27,7 +27,7 @@ uses
|
||||
CarbonPrivate, CarbonProc,
|
||||
CarbonDbgConsts,
|
||||
// LCL
|
||||
LCLMessageGlue, LCLType, Graphics;
|
||||
LCLMessageGlue, LCLType, LCLProc, Graphics;
|
||||
|
||||
type
|
||||
TUpdateValueEvent = procedure (Sender: TObject; CurrentValue: Integer; var AValue: Integer) of object;
|
||||
@ -497,7 +497,7 @@ end;
|
||||
procedure TCarbonBitBtn.SetFont(const AFont: TFont);
|
||||
begin
|
||||
inherited;
|
||||
CustomFont:=(AFont.Name<>'default') and (AFont.Name<>'');
|
||||
CustomFont:= not IsFontNameDefault(AFont.Name) and (AFont.Name<>'');
|
||||
UpdateButtonStyle;
|
||||
end;
|
||||
|
||||
|
@ -567,7 +567,7 @@ begin
|
||||
// because otherwise the result is wrong in Mac OS X 10.11, see bug 30300
|
||||
// Code used for 10.10 or inferior:
|
||||
// FName := NSStringToString(NSFont.systemFontOfSize(0).familyName);
|
||||
if AnsiCompareText(FName, 'default') = 0 then
|
||||
if IsFontNameDefault(FName) then
|
||||
begin
|
||||
FTmpFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
|
||||
FName := NSStringToString(FTmpFont.familyName);
|
||||
|
@ -472,7 +472,7 @@ var
|
||||
fn : String;
|
||||
begin
|
||||
Result := 0;
|
||||
if SysUtils.CompareText(FontName, 'default')=0 then fn:=DefaultFont else fn:=FontName;
|
||||
if IsFontNameDefault(FontName) then fn:=DefaultFont else fn:=FontName;
|
||||
if (fn <> '') then
|
||||
ATSUFindFontFromName(@fn[1], Length(fn),
|
||||
kFontFullName, kFontMacintoshPlatform, kFontRomanScript,
|
||||
|
@ -236,9 +236,9 @@ begin
|
||||
// First look if font name matches a stored name
|
||||
// but replace generic with reasonable default
|
||||
AFontName:= '';
|
||||
if LowerCase(LongFontName) = 'default' then AFontName:= 'Arial'
|
||||
else if LowerCase(LongFontName) = 'sans' then AFontName:= 'Arial'
|
||||
else if LowerCase(LongFontName) = 'serif' then AFontName:= 'Times New Roman'
|
||||
if IsFontNameDefault(LongFontName) then AFontName:= 'Arial'
|
||||
else if SameText(LongFontName, 'sans') then AFontName:= 'Arial'
|
||||
else if SameText(LongFontName, 'serif') then AFontName:= 'Times New Roman'
|
||||
else AFontName:= LongFontName;
|
||||
|
||||
str := FFontList.Values[AFontName];
|
||||
|
@ -681,15 +681,15 @@ begin
|
||||
// but replace generic with reasonable default
|
||||
AFontName:= '';
|
||||
if LiberationFont then begin
|
||||
if LowerCase(LongFontName) = 'default' then AFontName:= 'Liberation Sans'
|
||||
else if LowerCase(LongFontName) = 'sans' then AFontName:= 'Liberation Sans'
|
||||
else if LowerCase(LongFontName) = 'serif' then AFontName:= 'Liberation Serif'
|
||||
if IsFontNameDefault(LongFontName) then AFontName:= 'Liberation Sans'
|
||||
else if SameText(LongFontName, 'sans') then AFontName:= 'Liberation Sans'
|
||||
else if SameText(LongFontName, 'serif') then AFontName:= 'Liberation Serif'
|
||||
else AFontName:= LongFontName;
|
||||
end
|
||||
else if LuxiFont then begin
|
||||
if LowerCase(LongFontName) = 'default' then AFontName:= 'Luxi Sans Regular'
|
||||
else if LowerCase(LongFontName) = 'sans' then AFontName:= 'Luxi Sans Regular'
|
||||
else if LowerCase(LongFontName) = 'serif' then AFontName:= 'Luxi Serif Regular'
|
||||
if IsFontNameDefault(LongFontName) then AFontName:= 'Luxi Sans Regular'
|
||||
else if SameText(LongFontName, 'sans') then AFontName:= 'Luxi Sans Regular'
|
||||
else if SameText(LongFontName, 'serif') then AFontName:= 'Luxi Serif Regular'
|
||||
else AFontName:= LongFontName;
|
||||
end;
|
||||
|
||||
|
@ -1605,7 +1605,7 @@ begin
|
||||
|
||||
FamilyName := StrPas(lfFaceName);
|
||||
|
||||
if (CompareText(FamilyName,'default')<>0) then begin
|
||||
if not IsFontNameDefault(FamilyName) then begin
|
||||
|
||||
// check if we have foundry encoded in family name
|
||||
n := pos(FOUNDRYCHAR_OPEN, FamilyName);
|
||||
@ -1622,7 +1622,7 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
if CompareText(FamilyName,'default')=0 then begin
|
||||
if IsFontNameDefault(FamilyName) then begin
|
||||
{$IFDEF VerboseFonts}
|
||||
DebugLn('TGtkWidgetSet.CreateFontIndirectEx FamilyName="',FamilyName,'" PixelSize=',PixelSize,' LogFont.lfHeight=',dbgs(LogFont.lfHeight));
|
||||
{$ENDIF}
|
||||
|
@ -1402,7 +1402,7 @@ begin
|
||||
(lfItalic = 0) and
|
||||
(lfUnderline = 0) and
|
||||
(lfOrientation = 0) and
|
||||
(CompareText(lfFacename, 'default') = 0) then
|
||||
IsFontNameDefault(lfFacename) then
|
||||
begin
|
||||
// use default font
|
||||
{$IFDEF VerboseFonts}
|
||||
@ -1430,7 +1430,7 @@ begin
|
||||
|
||||
// using method 2
|
||||
|
||||
if aFamily = 'default' then
|
||||
if IsFontNameDefault(aFamily) then
|
||||
begin
|
||||
CurFont := GetDefaultGtkFont(False);
|
||||
if PANGO_IS_LAYOUT(CurFont) then
|
||||
@ -5173,11 +5173,11 @@ begin
|
||||
begin
|
||||
PLogfont(Buf)^ := GDIObject^.LogFont;
|
||||
Result:= SizeOf(TLogFont);
|
||||
if GDIObject^.LogFont.lfFaceName = 'default' then
|
||||
if IsFontNameDefault(GDIObject^.LogFont.lfFaceName) then
|
||||
begin
|
||||
AFontName := GetDefaultFontName;
|
||||
|
||||
if (AFontName = '') or (AFontName = 'default') then
|
||||
if (AFontName = '') or IsFontNameDefault(AFontName) then
|
||||
begin
|
||||
AFont := GetDefaultGtkFont(False);
|
||||
if PANGO_IS_LAYOUT(AFont) then
|
||||
|
@ -469,7 +469,7 @@ begin
|
||||
FLogFont := ALogFont;
|
||||
FFontName := ALogFont.lfFaceName;
|
||||
AContext := gdk_pango_context_get;
|
||||
if (LowerCase(FFontName) = 'default') or (FFontName = '') then
|
||||
if IsFontNameDefault(FFontName) or (FFontName = '') then
|
||||
begin
|
||||
if Gtk3WidgetSet.DefaultAppFontName <> '' then
|
||||
FHandle := pango_font_description_from_string(PgChar(Gtk3WidgetSet.DefaultAppFontName))
|
||||
|
@ -470,7 +470,7 @@ begin
|
||||
' pxPerInch ',dbgs(AFont.PixelsPerInch));
|
||||
{$ENDIF}
|
||||
AWidget := TGtk3Widget(AWinControl.Handle);
|
||||
if LowerCase(AFont.Name) = 'default' then
|
||||
if IsFontNameDefault(AFont.Name) then
|
||||
begin
|
||||
AGtkFont := TGtk3Widget(AWinControl.Handle).Font;
|
||||
if AFont.Size <> 0 then
|
||||
|
@ -588,7 +588,7 @@ begin
|
||||
|
||||
FamilyName := StrPas(LogFont.lfFaceName);
|
||||
|
||||
if (CompareText(FamilyName, 'default') <> 0) then
|
||||
if not IsFontNameDefault(FamilyName) then
|
||||
QtFont.setFamily(FamilyName)
|
||||
else
|
||||
QtFont.setFamily(UTF16ToUTF8(GetDefaultAppFontName));
|
||||
|
@ -126,9 +126,8 @@ const
|
||||
{ True } QtRightToLeft
|
||||
);
|
||||
implementation
|
||||
{$IF DEFINED(VerboseQtResize) OR DEFINED(VerboseQt)}
|
||||
|
||||
uses LCLProc;
|
||||
{$ENDIF}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TQtWSCustomControl.CreateHandle
|
||||
@ -630,7 +629,7 @@ begin
|
||||
// issue #28437, #30966 - regression from r53365: when FontChanged() is called
|
||||
// here handle is recreated inside LCL, so we are dead - SEGFAULT.
|
||||
if AWinControl.HandleObjectShouldBeVisible and
|
||||
(LowerCase(AWinControl.Font.Name) = 'default') then
|
||||
IsFontNameDefault(AWinControl.Font.Name) then
|
||||
begin
|
||||
if AWinControl.IsParentFont and Assigned(AWinControl.Parent) then
|
||||
SetFont(AWinControl, AWinControl.Parent.Font) {DO NOT TOUCH THIS PLEASE !}
|
||||
|
@ -583,7 +583,7 @@ begin
|
||||
|
||||
FamilyName := StrPas(LogFont.lfFaceName);
|
||||
|
||||
if (CompareText(FamilyName, 'default') <> 0) then
|
||||
if not IsFontNameDefault(FamilyName) then
|
||||
QtFont.setFamily(FamilyName)
|
||||
else
|
||||
QtFont.setFamily(UTF16ToUTF8(GetDefaultAppFontName));
|
||||
|
@ -124,9 +124,8 @@ const
|
||||
{ True } QtRightToLeft
|
||||
);
|
||||
implementation
|
||||
{$IF DEFINED(VerboseQtResize) OR DEFINED(VerboseQt)}
|
||||
|
||||
uses LCLProc;
|
||||
{$ENDIF}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TQtWSCustomControl.CreateHandle
|
||||
@ -629,7 +628,7 @@ begin
|
||||
// issue #28437, #30966 - regression from r53365: when FontChanged() is called
|
||||
// here handle is recreated inside LCL, so we are dead - SEGFAULT.
|
||||
if AWinControl.HandleObjectShouldBeVisible and
|
||||
(LowerCase(AWinControl.Font.Name) = 'default') then
|
||||
IsFontNameDefault(AWinControl.Font.Name) then
|
||||
begin
|
||||
if AWinControl.IsParentFont and Assigned(AWinControl.Parent) then
|
||||
SetFont(AWinControl, AWinControl.Parent.Font) {DO NOT TOUCH THIS PLEASE !}
|
||||
|
@ -394,6 +394,8 @@ procedure LCLGetLanguageIDs(var Lang, FallbackLang: String); inline; deprecated
|
||||
// identifier
|
||||
function CreateFirstIdentifier(const Identifier: string): string;
|
||||
function CreateNextIdentifier(const Identifier: string): string;
|
||||
// Font
|
||||
function IsFontNameDefault(const AName: string): boolean; inline;
|
||||
|
||||
{$IFDEF WithOldDebugln}
|
||||
type
|
||||
@ -3011,6 +3013,11 @@ begin
|
||||
+IntToStr(1+StrToIntDef(copy(Identifier,p+1,length(Identifier)-p),0));
|
||||
end;
|
||||
|
||||
function IsFontNameDefault(const AName: string): boolean; inline;
|
||||
begin
|
||||
Result := LowerCase(AName) = 'default';
|
||||
end;
|
||||
|
||||
procedure FreeLineInfoCache;
|
||||
var
|
||||
ANode: TAvlTreeNode;
|
||||
|
Loading…
Reference in New Issue
Block a user