安装类型1的字体如下:
- Register the font title under Type 1 Fonts
- Copy both the PFM and the PFB to the windows fonts directory
- Call the AddFontResource method
Register the font title under Type 1 Fonts
SOFTWAREMicrosoftWindows NTCurrentVersionType 1 InstallerType 1 Fonts
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:
rel=“nofollow” http://partners.adobe.com/public/developer/en/font/5178.PFM.pdf
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();
}
www.un.org/Depts/DGACM/index_spanish.htm 将PFM和PFB复制到窗户长
根据这一博客, 找到窗户的正确途径如下:
[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();
}
www.un.org/Depts/DGACM/index_spanish.htm 添加FontResource方法
最后,应当称作“AddFontResource”的方法,即直径电离层名称应当由管道星号分离的pfm和pfb文档组成。 在我的案件中,我把通向似乎行之有效的窗户的足迹。 在打电话给AddFontResource之后,你需要用WM的参数打电话。 FONTCHANGE(0x001D)向其他变化窗口提供信息。
[DllImport("gdi32.dll")]
static extern int AddFontResource(string lpFilename);
// build the name for the api "<pfm>|<pfb>"
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);