![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Hi Thomas, Thanks for the feedback. Actually, ClickOnce is only a deployment technology, it does not offer any support for font installation currently, since this operation requires extra coding. We have to code the font installation logic in the application. So this question is not a ClickOnce specific. Based on my test using the code snippet below, after I called InstallFont, the Word application can use the font without any problem, so I think it should work for Excel application. But without restarting the application, the .Net winform application still can not use it. , do you get different result? My testing machine is Win2003 SP1. private void button1_Click(object sender, EventArgs e) { InstallFont(); } internal static void InstallFont() { string fontsPath = GetFontsPath(); string ttfFile = System.IO.Path.Combine(fontsPath, "cookiehollow.ttf"); System.IO.File.Copy(@"C:\cookiehollow.ttf", ttfFile); int ret; if (System.IO.File.Exists(ttfFile)) { //Add font resource ret = AddFontResource(ttfFile); //Add registry entry so the font is also available next session Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Mi crosoft\Windows NT\CurrentVersion\Fonts", "Cookie Hollow Regular (TrueType)", "cookiehollow.ttf", RegistryValueKind.String); //Broadcast to let all top-level windows know about change ret = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, new IntPtr(0), new IntPtr(0)); } } // PInvoke to look up fonts path [System.Runtime.InteropServices.DllImport("shfolder .dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)] private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath); private const int CSIDL_FONTS = 0x0014; private const int MAX_PATH = 260; private static string GetFontsPath() { StringBuilder sb = new StringBuilder(MAX_PATH); SHGetFolderPath(IntPtr.Zero, CSIDL_FONTS, IntPtr.Zero, 0, sb); return sb.ToString(); } // PInvoke to 'register' fonts and broadcast addition [System.Runtime.InteropServices.DllImport("gdi32.dl l")] private static extern int AddFontResource(string lpszFilename); [System.Runtime.InteropServices.DllImport("gdi32.dl l")] private static extern int CreateScalableFontResource(uint fdwHidden, string lpszFontRes, string lpszFontFile, string lpszCurrentPath); private static IntPtr HWND_BROADCAST = new IntPtr(0xffff); private const uint WM_FONTCHANGE = 0x001D; [System.Runtime.InteropServices.DllImport("user32.d ll", CharSet =System.Runtime.InteropServices.CharSet.Auto)] private static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); private void button2_Click(object sender, EventArgs e) { this.button2.Font = new Font("CookieHollow", 10, FontStyle.Regular); } Thanks. Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. |
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
#9
| |||
| |||
|
#10
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |