disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk

git-svn-id: trunk@6221 -
This commit is contained in:
mattias 2004-11-08 19:11:55 +00:00
parent 005b18e798
commit 891b8aa58a
7 changed files with 85 additions and 34 deletions

View File

@ -69,14 +69,14 @@ const
{ tracing level { tracing level
splitted in two if memory is released !! } splitted in two if memory is released !! }
{$ifdef EXTRA} {$ifdef EXTRA}
tracesize = 16; // normal: 16 tracesize = 64; // normal: 16
{$else EXTRA} {$else EXTRA}
tracesize = 32; // normal: 8 tracesize = 32; // normal: 8
{$endif EXTRA} {$endif EXTRA}
{ install heaptrc memorymanager } { install heaptrc memorymanager }
useheaptrace : boolean=true; useheaptrace : boolean = true;
{ less checking } { less checking }
quicktrace : boolean=true; quicktrace : boolean = true;
{ calls halt() on error } { calls halt() on error }
HaltOnError : boolean = false; HaltOnError : boolean = false;
{ ExceptOnError: raise gdb catchable exception on error } { ExceptOnError: raise gdb catchable exception on error }
@ -359,7 +359,7 @@ begin
is_in_getmem_list:=true; is_in_getmem_list:=true;
// MG: changes for codetools: // MG: changes for codetools:
inc(i); inc(i);
if i>getmem_cnt-freemem_cnt then begin if (i>getmem_cnt-freemem_cnt) and (not keepreleased) then begin
writeln(ptext^,'error in linked list of heap_mem_info', writeln(ptext^,'error in linked list of heap_mem_info',
' FreedCnt=',getmem_cnt-freemem_cnt,' RealCnt=',i); ' FreedCnt=',getmem_cnt-freemem_cnt,' RealCnt=',i);
runerror(204); runerror(204);
@ -2318,6 +2318,9 @@ end.
{ {
$Log$ $Log$
Revision 1.35 2004/11/08 19:11:55 mattias
disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk
Revision 1.34 2004/10/25 17:59:29 vincents Revision 1.34 2004/10/25 17:59:29 vincents
fpc 1.9.5 has no saveregisters calling convention anymore. fpc 1.9.5 has no saveregisters calling convention anymore.

View File

@ -112,7 +112,8 @@ end;
{ TGdkFontCache } { TGdkFontCache }
function CompareGdkFontWithResItem(Font: PGDKFont; Item: TGdkFontCacheItem): integer; function CompareGdkFontWithResItem(Font: PGDKFont;
Item: TGdkFontCacheItem): integer;
begin begin
Result := ComparePointers(Font, Item.GdkFont); Result := ComparePointers(Font, Item.GdkFont);
end; end;
@ -121,10 +122,10 @@ function CompareLogFontAndNameWithResDesc(Key: PLogFontAndName;
Desc: TGdkFontCacheDescriptor): integer; Desc: TGdkFontCacheDescriptor): integer;
begin begin
Result:=CompareStr(Key^.LongFontName,Desc.LongFontName); Result:=CompareStr(Key^.LongFontName,Desc.LongFontName);
//writeln('CompareLogFontAndNameWithResDesc A ',Key^.LongFontName,' ',Desc.LongFontName,' ',HexStr(Cardinal(Desc),8),' Result=',Result); //debugln('CompareLogFontAndNameWithResDesc A ',Key^.LongFontName,' ',Desc.LongFontName,' ',HexStr(Cardinal(Desc),8),' Result=',Result);
if Result=0 then if Result=0 then
Result:=CompareMemRange(@Key^.LogFont,@Desc.LogFont,SizeOf(Desc.LogFont)); Result:=CompareMemRange(@Key^.LogFont,@Desc.LogFont,SizeOf(Desc.LogFont));
//writeln('CompareLogFontAndNameWithResDesc END Result=',Result); //debugln('CompareLogFontAndNameWithResDesc END Result=',Result);
end; end;
procedure TGdkFontCache.RemoveItem(Item: TResourceCacheItem); procedure TGdkFontCache.RemoveItem(Item: TResourceCacheItem);

View File

@ -1511,8 +1511,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TGtkWidgetSet.AppInit(var ScreenInfo: TScreenInfo); procedure TGtkWidgetSet.AppInit(var ScreenInfo: TScreenInfo);
begin begin
If Assigned(Screen) then // MG: TODO: call FillScreenFonts on demand, not for every application
FillScreenFonts(Screen.Fonts); //FillScreenFonts(Screen.Fonts);
InitKeyboardTables; InitKeyboardTables;
{ Compute pixels per inch variable } { Compute pixels per inch variable }
ScreenInfo.PixelsPerInchX := ScreenInfo.PixelsPerInchX :=
@ -6942,6 +6942,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.608 2004/11/08 19:11:55 mattias
disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk
Revision 1.607 2004/11/03 14:18:36 mattias Revision 1.607 2004/11/03 14:18:36 mattias
implemented preferred size for controls for theme depending AutoSizing implemented preferred size for controls for theme depending AutoSizing

View File

@ -7738,9 +7738,10 @@ begin
{$IFDEF GTK1} {$IFDEF GTK1}
{$IFDEF UNIX} {$IFDEF UNIX}
theFonts := XListFonts(X11Display,PChar('-*-*-*-*-*-*-*-*-*-*-*-*-*-*'), 10000, @N); theFonts := XListFonts(X11Display,PChar('-*-*-*-*-*-*-*-*-*-*-*-*-*-*'), 10000, @N);
debugln('FillScreenFonts N=',dbgs(N));
for I := 0 to N - 1 do for I := 0 to N - 1 do
if theFonts[I] <> nil then begin if theFonts[I] <> nil then begin
Tmp := ExtractFamilyFromXLFDName(AnsiString(theFonts[I])); Tmp := ExtractFamilyFromXLFDName(theFonts[I]);
if Tmp <> '' then if Tmp <> '' then
if ScreenFonts.IndexOf(Tmp) < 0 then if ScreenFonts.IndexOf(Tmp) < 0 then
ScreenFonts.Append(Tmp); ScreenFonts.Append(Tmp);
@ -7791,6 +7792,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.317 2004/11/08 19:11:55 mattias
disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk
Revision 1.316 2004/11/03 14:18:36 mattias Revision 1.316 2004/11/03 14:18:36 mattias
implemented preferred size for controls for theme depending AutoSizing implemented preferred size for controls for theme depending AutoSizing

View File

@ -1306,7 +1306,6 @@ end;
{$Else} {$Else}
var var
GdiObject: PGdiObject; GdiObject: PGdiObject;
S: String;
FontNameRegistry, Foundry, FamilyName, WeightName, FontNameRegistry, Foundry, FamilyName, WeightName,
Slant, SetwidthName, AddStyleName, PixelSize, Slant, SetwidthName, AddStyleName, PixelSize,
PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth, PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth,
@ -1315,13 +1314,27 @@ var
CachedFont: TGdkFontCacheDescriptor; CachedFont: TGdkFontCacheDescriptor;
function LoadFont: boolean; function LoadFont: boolean;
var
S: string;
begin begin
S:=FontNameRegistry+'-'+Foundry+'-'+FamilyName+'-'+WeightName
+'-'+Slant+'-'+SetwidthName+'-'+AddStyleName+'-'+PixelSize
+'-'+PointSize+'-'+ResolutionX+'-'+ResolutionY+'-'+Spacing+'-'+AverageWidth
+'-'+CharSetRegistry+'-'+CharSetCoding;
{ MG: heaptrc gets corrupted heap using the construction below:
S := Format('%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s', S := Format('%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s-%s',
[FontNameRegistry, Foundry, FamilyName, WeightName, [FontNameRegistry, Foundry, FamilyName, WeightName,
Slant, SetwidthName, AddStyleName, PixelSize, Slant, SetwidthName, AddStyleName, PixelSize,
PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth, PointSize, ResolutionX, ResolutionY, Spacing, AverageWidth,
CharSetRegistry, CharSetCoding CharSetRegistry, CharSetCoding
]); ]);}
//DebugLn(' Trying "',S,'"');
{S:=FontNameRegistry+','+Foundry+','+FamilyName+','+WeightName
+','+Slant+','+SetwidthName+','+AddStyleName+','+PixelSize
+','+PointSize+','+ResolutionX+','+ResolutionY+','+Spacing+','+AverageWidth
+','+CharSetRegistry+','+CharSetCoding;
DebugLn(' Trying B "',S,'"');}
GdiObject^.GDIFontObject := gdk_font_load(PChar(s)); GdiObject^.GDIFontObject := gdk_font_load(PChar(s));
Result:=GdiObject^.GDIFontObject<>nil; Result:=GdiObject^.GDIFontObject<>nil;
@ -1331,7 +1344,7 @@ var
end; end;
{$IFDEF VerboseFonts} {$IFDEF VerboseFonts}
DebugLn(' Trying "',S,'" Success=',dbgs(GdiObject^.GDIFontObject<>nil)); DebugLn(' Tried "',S,'" Success=',dbgs(GdiObject^.GDIFontObject<>nil));
{$ENDIF} {$ENDIF}
end; end;
@ -1347,12 +1360,15 @@ var
function GetDefaultFontFamilyName: string; function GetDefaultFontFamilyName: string;
begin begin
Result:=GetDefaultFontName; Result:=GetDefaultFontName;
if IsFontNameXLogicalFontDesc(Result) then
Result := ExtractXLFDItem(LongFontName,2);
if Result='' then Result:='*'; if Result='' then Result:='*';
end; end;
function FamilyNameExists: boolean; function FamilyNameExists: boolean;
var var
AFont: PGdkFont; AFont: PGdkFont;
S: String;
begin begin
S := '*-*-'+FamilyName+'*-*-*-*-*-*-*-*-*-*-*-*-*'; S := '*-*-'+FamilyName+'*-*-*-*-*-*-*-*-*-*-*-*-*';
AFont:=gdk_font_load(PChar(s)); AFont:=gdk_font_load(PChar(s));
@ -1360,6 +1376,21 @@ var
if Result then gdk_font_unref(AFont); if Result then gdk_font_unref(AFont);
end; end;
function CheckFontNameIsMangledXLogicalFontDesc(const ALongFontName: string
): boolean;
var
c: Integer;
i: Integer;
begin
c:=0;
for i:=1 to length(ALongFontName) do
if ALongFontName[i]='-' then inc(c);
Result:=(c>5) and (c<>14);
if Result then
debugln('WARNING: Fontnamt "',ALongFontName,'" seems to be a XLFD fontname, but has 14<>',dbgs(c),' minus signs');
end;
begin begin
// For info about xlfd see: // For info about xlfd see:
// http://wwwinfo.cern.ch/umtf/working-groups/X11/fonts/hp_xlfd.html // http://wwwinfo.cern.ch/umtf/working-groups/X11/fonts/hp_xlfd.html
@ -1404,10 +1435,9 @@ begin
{$IFDEF VerboseFonts} {$IFDEF VerboseFonts}
DebugLn('TGtkWidgetSet.CreateFontIndirectEx Name="',LogFont.lfFaceName,'"', DebugLn('TGtkWidgetSet.CreateFontIndirectEx Name="',LogFont.lfFaceName,'"',
' Long="',LongFontName,'" IsXLFD=',IsFontNameXLogicalFontDesc(LongFontName) ' Long="',LongFontName,'" IsXLFD=',dbgs(IsFontNameXLogicalFontDesc(LongFontName))
,' ',ord(LogFont.lfFaceName[0])); ,' ',dbgs(ord(LogFont.lfFaceName[0])));
{$ENDIF} {$ENDIF}
S:=LongFontName;
if IsFontNameXLogicalFontDesc(LongFontName) then begin if IsFontNameXLogicalFontDesc(LongFontName) then begin
FontNameRegistry := ExtractXLFDItem(LongFontName,0); FontNameRegistry := ExtractXLFDItem(LongFontName,0);
Foundry := ExtractXLFDItem(LongFontName,1); Foundry := ExtractXLFDItem(LongFontName,1);
@ -1424,6 +1454,7 @@ begin
AverageWidth := ExtractXLFDItem(LongFontName,12); AverageWidth := ExtractXLFDItem(LongFontName,12);
CharSetRegistry := ExtractXLFDItem(LongFontName,13); CharSetRegistry := ExtractXLFDItem(LongFontName,13);
CharSetCoding := ExtractXLFDItem(LongFontName,14); CharSetCoding := ExtractXLFDItem(LongFontName,14);
end else if CheckFontNameIsMangledXLogicalFontDesc(LongFontName) then begin
end; end;
with LogFont do with LogFont do
@ -1625,8 +1656,8 @@ begin
end; end;
if Result = 0 if Result = 0
then DebugLn(Format('WARNING: [TGtkWidgetSet.CreateFontIndirectEx] NOT found XLFD: <%s>', [S])) then DebugLn(Format('WARNING: [TGtkWidgetSet.CreateFontIndirectEx] NOT found XLFD: <%s>', [LongFontName]))
else Assert(False, Format('Trace: [TGtkWidgetSet.CreateFontIndirectEx] found XLFD: <%s>', [S])); else Assert(False, Format('Trace: [TGtkWidgetSet.CreateFontIndirectEx] found XLFD: <%s>', [LongFontName]));
end; end;
end; end;
{$EndIf} {$EndIf}
@ -8695,6 +8726,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.371 2004/11/08 19:11:55 mattias
disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk
Revision 1.370 2004/10/15 13:28:22 mattias Revision 1.370 2004/10/15 13:28:22 mattias
codeexplorer: using lower recursive depth codeexplorer: using lower recursive depth

View File

@ -113,7 +113,7 @@ begin
CharSetRegistry := ExtractXLFDItem(LongFontName,13); CharSetRegistry := ExtractXLFDItem(LongFontName,13);
CharSetCoding := ExtractXLFDItem(LongFontName,14); CharSetCoding := ExtractXLFDItem(LongFontName,14);
end else end else
if (LongFontName <> '') and (Screen.Fonts.IndexOf(LongFontName) > 0) then if (LongFontName <> '') {and (Screen.Fonts.IndexOf(LongFontName) > 0) }then
FamilyName := LongFontName; FamilyName := LongFontName;
with LogFont do begin with LogFont do begin
@ -830,6 +830,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.11 2004/11/08 19:11:55 mattias
disabled hardly used gtk FillScreenFont, this should be only done on demand, improved getting default font family for gtk
Revision 1.10 2004/08/04 15:48:44 mazen Revision 1.10 2004/08/04 15:48:44 mazen
* fix UTF8 text display in source note book * fix UTF8 text display in source note book

View File

@ -25,19 +25,19 @@ interface
{$IFNDEF VER1_0} {$IFNDEF VER1_0}
uses uses
Classes, SysUtils, Forms, PropertyStorage, XMLCfg, DOM; Classes, SysUtils, LCLProc, Forms, PropertyStorage, XMLCfg, DOM;
type type
{ TXMLPropStorage } { TXMLPropStorage }
TPropStorageXMLConfig = class(TXMLConfig) TPropStorageXMLConfig = class(TXMLConfig)
Public Public
Procedure DeleteSubNodes (const ARootNode : String); Procedure DeleteSubNodes (const ARootNode: String);
end; end;
TCustomXMLPropStorage = class(TFormPropertyStorage) TCustomXMLPropStorage = class(TFormPropertyStorage)
private private
FCount : Integer; FCount: Integer;
FFileName: String; FFileName: String;
FXML: TPropStorageXMLConfig; FXML: TPropStorageXMLConfig;
FRootNode: String; FRootNode: String;
@ -45,17 +45,17 @@ type
protected protected
procedure StorageNeeded(ReadOnly: Boolean);override; procedure StorageNeeded(ReadOnly: Boolean);override;
procedure FreeStorage; override; procedure FreeStorage; override;
Function GetXMLFileName : string; virtual; Function GetXMLFileName: string; virtual;
Function RootSection : String; Override; Function RootSection: String; Override;
Function FixPath(const APath : String) : String; virtual; Function FixPath(const APath: String): String; virtual;
Property XMLConfig: TPropStorageXMLConfig Read FXML; Property XMLConfig: TPropStorageXMLConfig Read FXML;
public public
function DoReadString(const Section, Ident, Default: string): string; override; function DoReadString(const Section, Ident, TheDefault: string): string; override;
procedure DoWriteString(const Section, Ident, Value: string); override; procedure DoWriteString(const Section, Ident, Value: string); override;
Procedure DoEraseSections(const ARootSection: String);override; Procedure DoEraseSections(const ARootSection: String);override;
public public
property FileName : String Read FFileName Write FFileName; property FileName: String Read FFileName Write FFileName;
property RootNodePath : String Read FRootNode Write FRootNodePath; property RootNodePath: String Read FRootNode Write FRootNodePath;
end; end;
TXMLPropStorage = class(TCustomXMLPropStorage) TXMLPropStorage = class(TCustomXMLPropStorage)
@ -116,7 +116,7 @@ begin
{$endif} {$endif}
end; end;
function TCustomXMLPropStorage.FixPath(const APath : String) : String; function TCustomXMLPropStorage.FixPath(const APath: String): String;
begin begin
Result:=StringReplace(APath,'.','/',[rfReplaceAll]); Result:=StringReplace(APath,'.','/',[rfReplaceAll]);
@ -131,14 +131,15 @@ begin
Result:=FixPath(Result); Result:=FixPath(Result);
end; end;
function TCustomXMLPropStorage.DoReadString(const Section, Ident, Default: string function TCustomXMLPropStorage.DoReadString(const Section, Ident,
): string; TheDefault: string): string;
begin begin
Result:=FXML.GetValue(FixPath(Section)+'/'+Ident, Default); Result:=FXML.GetValue(FixPath(Section)+'/'+Ident, TheDefault);
//debugln('TCustomXMLPropStorage.DoReadString Section=',Section,' Ident=',Ident,' Result=',Result); //debugln('TCustomXMLPropStorage.DoReadString Section=',Section,' Ident=',Ident,' Result=',Result);
end; end;
procedure TCustomXMLPropStorage.DoWriteString(const Section, Ident, Value: string); procedure TCustomXMLPropStorage.DoWriteString(const Section, Ident,
Value: string);
begin begin
//debugln('TCustomXMLPropStorage.DoWriteString Section=',Section,' Ident=',Ident,' Value=',Value); //debugln('TCustomXMLPropStorage.DoWriteString Section=',Section,' Ident=',Ident,' Value=',Value);
FXML.SetValue(FixPath(Section)+'/'+Ident, Value); FXML.SetValue(FixPath(Section)+'/'+Ident, Value);
@ -169,8 +170,10 @@ begin
System.Delete(NodePath,1,I); System.Delete(NodePath,1,I);
Node := Child; Node := Child;
end; end;
If Assigned(Node) then If Assigned(Node) then begin
//debugln('TPropStorageXMLConfig.DeleteSubNodes ',ARootNode);
Node.Free; Node.Free;
end;
end; end;
{$ENDIF not VER1_0} {$ENDIF not VER1_0}