Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To install Type 1 fonts you need to do the following:</p> <ol> <li>Register the font title under 'Type 1 Fonts'</li> <li>Copy both the PFM and the PFB to the windows fonts directory</li> <li>Call the AddFontResource method</li> </ol> <p><strong>Register the font title under 'Type 1 Fonts'</strong></p> <p><code>SOFTWARE\Microsoft\Windows NT\CurrentVersion\Type 1 Installer\Type 1 Fonts</code></p> <p>The Font Title is required, rather than providing this to the installer, the following code snippet will allow you to read the font title from the PFM. It is based on information gathered from the following source:</p> <p><a href="http://partners.adobe.com/public/developer/en/font/5178.PFM.pdf" rel="nofollow">http://partners.adobe.com/public/developer/en/font/5178.PFM.pdf</a></p> <pre><code> private static string GetType1FontName(string filename) { StringBuilder postscriptName = new StringBuilder(); FileInfo fontFile = new FileInfo(filename); using (FileStream fs = fontFile.OpenRead()) { using (StreamReader sr = new StreamReader(fs)) { using (BinaryReader inStream = new BinaryReader(fs)) { // PFM Header is 117 bytes inStream.ReadBytes(117); // skip 117 short size = inStream.ReadInt16(); int extMetricsOffset = inStream.ReadInt32(); int extentTableOffset = inStream.ReadInt32(); inStream.ReadBytes(4); // skip 4 int kernPairOffset = inStream.ReadInt32(); int kernTrackOffset = inStream.ReadInt32(); int driverInfoOffset = inStream.ReadInt32(); fs.Position = driverInfoOffset; while (inStream.PeekChar() != 0) { postscriptName.Append(inStream.ReadChar()); } } } } return postscriptName.ToString(); } </code></pre> <p><strong>Copy both the PFM and the PFB to the windows fonts directory</strong></p> <p>According to this blog <a href="http://www.atalasoft.com/cs/blogs/stevehawley/archive/2008/08/25/getting-the-fonts-folder.aspx" rel="nofollow">http://www.atalasoft.com/cs/blogs/stevehawley/archive/2008/08/25/getting-the-fonts-folder.aspx</a> the right way to get the windows fonts folder is as follows:</p> <pre><code> [DllImport("shell32.dll")] private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, uint dwFlags, [Out] StringBuilder pszPath); public static string GetFontFolderPath() { StringBuilder sb = new StringBuilder(); SHGetFolderPath(IntPtr.Zero, 0x0014, IntPtr.Zero, 0x0000, sb); return sb.ToString(); } </code></pre> <p><strong>Call the AddFontResource method</strong></p> <p>Finally, the method AddFontResource should be called, the parameter lpFilename should be made up of the pfm and pfb files separated by the pipe character '|'. In my case I put the full path to the windows fonts folder which seemed to work. After calling AddFontResource you need to call PostMessage with a parameter of WM.FONTCHANGE (0x001D) to inform other windows of the change.</p> <pre><code> [DllImport("gdi32.dll")] static extern int AddFontResource(string lpFilename); // build the name for the api "&lt;pfm&gt;|&lt;pfb&gt;" string apiValue = string.Format("{0}|{1}", PfmFileDestination, PfbFileDestination); // Call the api to register the font int retVal = AddFontResource(apiValue); // Inform other windows of change PostMessage(HWND_BROADCAST, WM.FONTCHANGE, IntPtr.Zero, IntPtr.Zero); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload