{"id":191,"date":"2007-05-12T16:51:56","date_gmt":"2007-05-12T14:51:56","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/write-all-font-styles-to-the-registry\/"},"modified":"2007-05-12T16:51:58","modified_gmt":"2007-05-12T14:51:58","slug":"write-all-font-styles-to-the-registry","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/write-all-font-styles-to-the-registry\/","title":{"rendered":"Write all Font-Styles to the registry"},"content":{"rendered":"<p><em>Q: How to write all Font-Styles to the registry?<br \/>\n<\/em><br \/>\nA:<br \/>\nTrue, but why handle the set elements in the first place? The following<br \/>\nfunctions save\/restore a font via a single registry key:<\/p>\n<p>[code lang=&#8221;delphi&#8221;]  FontRec = packed record<br \/>\n    Color: TColor;<br \/>\n    LogFont: TLogFont;<br \/>\n  end;<\/p>\n<p>  procedure LoadFont(reg: TRegistry; const key,id: string; font: TFont);<br \/>\n  var fRec: FontRec;<br \/>\n  begin<br \/>\n    if reg.OpenKey(key,False) then try<br \/>\n      if reg.ReadBinaryData(id,frec,SizeOf(fRec)) = SizeOf(fRec) then<br \/>\n        font.Handle := CreateFontIndirect(fRec.LogFont);<br \/>\n        font.Color := fRec.Color;<br \/>\n    finally<br \/>\n      reg.CloseKey;<br \/>\n    end;<br \/>\n  end;<\/p>\n<p>  procedure SaveFont(reg: TRegistry; const key,id: string; font: TFont);<br \/>\n  var fRec: FontRec;<br \/>\n  begin<br \/>\n    if Windows.GetObject(font.Handle,SizeOf(fRec.LogFont),@fRec.LogFont) > 0<br \/>\nthen begin<br \/>\n      if reg.OpenKey(key,True) then try<br \/>\n        fRec.Color := font.Color;<br \/>\n        reg.WriteBinaryData(id,fRec,SizeOf(fRec));<br \/>\n      finally<br \/>\n        reg.CloseKey;<br \/>\n      end;<br \/>\n    end;<br \/>\n  end;<br \/>\n[\/code]  <\/p>\n<p> Mike Orriss (TeamB &#038; Developer Express)<\/p>\n<p>[tags]Delphi, Misc, Fonts[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q: How to write all Font-Styles to the registry? A: True, but why handle the set elements in the first place? The following&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,103,107],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-35","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/191"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=191"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/191\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}