{"id":58,"date":"2015-08-08T14:38:59","date_gmt":"2015-08-08T22:38:59","guid":{"rendered":"http:\/\/wordpress\/?p=58"},"modified":"2015-10-31T14:41:43","modified_gmt":"2015-10-31T22:41:43","slug":"installing-fonts-on-windows-using-puppet","status":"publish","type":"post","link":"https:\/\/andrewwippler.com\/2015\/08\/08\/installing-fonts-on-windows-using-puppet\/","title":{"rendered":"Installing fonts on Windows using Puppet"},"content":{"rendered":"

I was recently tasked to install a group of fonts on windows systems. In order to do it the Internet way, you have to:<\/p>\n

    \n
  1. Install the font on a system<\/li>\n
  2. Export the registry file<\/li>\n
  3. Create a GPO<\/li>\n
  4. Place the font in an accessible location (domain readable)<\/li>\n
  5. Make sure the GPO has the .reg and the font file installing<\/li>\n
  6. Reboot the machine 2-3 times<\/li>\n<\/ol>\n

    <\/p>\n

    Some have also suggested to install fonts via a packaged .msi – Something I also tried which did not work. Since my machines already have puppet installed, I went that route.<\/p>\n

    mkdir fonts\/files\/ #where the FontReg file resides\r\nmkdir fonts\/files\/fonts #where the fonts reside\r\nmkdir fonts\/manifests\/ #where the below init.pp file resides\r\n<\/code><\/pre>\n

    Contents of init.pp are below:<\/p>\n

    \r\nclass fonts {\r\n\r\ncase $operatingsystem {\r\n\twindows: {\r\n\t\t\texec { 'FontReg':\r\n\t\t\t\tcommand\t\t=> 'C:\\Windows\\FontReg.exe',\r\n\t\t\t\tpath\t\t=> $::path,\r\n\t\t\t\trefreshonly\t=> true,\r\n\t\t\t\trequire\t\t=> File['C:\\Windows\\FontReg.exe'],\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t\r\n\t\t\texec { 'FixFonts':\r\n\t\t\t\tcommand \t=> 'cmd.exe \/c C:\\Windows\\font_ownership.bat',\r\n\t\t\t\tpath\t\t=> $::path,\r\n\t\t\t\trefreshonly\t=> true,\r\n\t\t\t\trequire\t\t=> File['C:\\Windows\\font_ownership.bat'],\r\n\t\t\t}\r\n\t\t\tfile { 'C:\\Windows\\font_ownership.bat':\r\n\t\t\t\tensure\t\t\t=> present,\r\n\t\t\t\tnotify \t\t\t=> Exec[\"FixFonts\"],\r\n\t\t\t\tsource_permissions\t=> ignore,\r\n\t\t\t\tcontent\t\t\t=> \"attrib -r -s c:\\Windows\\Fonts\r\ntakeown \/f c:\\Windows\\Fonts \/r \/d n\r\ncacls c:\\Windows\\Fonts \/e \/t \/g users:c\r\ncacls c:\\Windows\\System32\\FNTCACHE.DAT \/e \/t \/g users:c\",\r\n\t\t\t\r\n\t\t\t}\r\n\t\t\tfile {\t'C:\\Windows\\FontReg.exe':\r\n\t\t\t\tsource \t\t\t=> $architecture ? {\r\n\t\t\t\t\t\t\"x86\" \t=> \"puppet:\/\/\/modules\/fonts\/FontReg32.exe\",\r\n\t\t\t\t\t\t\"x64\" \t=> \"puppet:\/\/\/modules\/fonts\/FontReg64.exe\",\r\n\t\t\t\t\t\tdefault => \"unsupported architecture\"\r\n\t\t\t\t\t\t},\r\n\t\t\t\tsource_permissions\t=> ignore,\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t$fonts = [\"font-name1.otf\",\"fontname2.ttf\"];\r\n\t\t\t$fonts.each |$font| {\r\n\t\t\t\tfile {\"C:\\\\Windows\\\\Fonts\\\\${font}\":\r\n\t\t\t\tsource  \t\t=> \"puppet:\/\/\/modules\/fonts\/fonts\/${font}\",\r\n\t\t\t\tensure\t\t\t=> present,\r\n\t\t\t\tnotify \t\t\t=> Exec[\"FontReg\"],\r\n\t\t\t\trequire\t\t\t=> [File['C:\\Windows\\FontReg.exe'],File['C:\\Windows\\font_ownership.bat'],],\r\n\t\t\t\tsource_permissions\t=> ignore\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n}\r\n<\/code><\/pre>\n

    Required programs:<\/h3>\n