Author: Jonas Bilinkevicius How can I save a font (including all its properties like color, angle, etc.) to a stream? Answer: 1 { ... } 2 type 3 FontRec = packed record 4 Color: TColor; 5 LogFont: TLogFont; 6 end; 7 8 procedure ReadFont(s: TStream; font: TFont); 9 var 10 fRec: FontRec; 11 sz: integer; 12 begin 13 s.read(sz, SizeOf(Integer)); 14 if sz = SizeOf(fRec.LogFont) then 15 begin 16 s.read(fRec, SizeOf(fRec)); 17 font.Handle := CreateFontIndirect(fRec.LogFont); 18 font.Color := fRec.Color; 19 end; 20 end; 21 22 procedure WriteFont(s: TStream; font: TFont); 23 var 24 fRec: FontRec; 25 sz: integer; 26 begin 27 sz := SizeOf(fRec.LogFont); 28 if Windows.GetObject(font.Handle, sz, @fRec.LogFont) > 0 then 29 begin 30 s.write(sz, SizeOf(Integer)); 31 fRec.Color := font.Color; 32 s.write(fRec, SizeOf(fRec)); 33 end 34 else 35 begin 36 sz := 0; 37 s.write(sz, SizeOf(Integer)); 38 end; 39 end;