On local if you look at the Chart Screen the fonts on the four graphs (Premises etc) look all lovely - in Ariel with a Bold Title at the top.
After uploading these to either the Testing or the Live system, these graphs revert to the default Courier font.
I’ve done a full dump of my dev code (copy/paste of all files) onto Testing in an attempt to see if it’s anything that’s not being transferred over, but this doesn’t appear to be the case.
I’ve searched the forums/google and can find no reference to this issue, bit of a puzzler!
try comparing your C:\windows\fonts folder with the same folder on the web server. does it contain the same "arialbld.ttf" (or whatever font you are using)? are the files the same size on both machines?
Checked the above both files are 344k Version 3.0 of the ArialBd.ttf
Was wondering if it's a permissions issue?Have given "Everyone" and "Network" Users permissions to theFonts folder, but this hasn't solved it.have tried both the HTML and Programmatic methods for changing the fonts and neither make a difference.
Happening with any of the UltraWebChart objects and also the UltraWebGauge objects.
I'm out of ideas. :-(
Just incase it's useful, we're using: Infragistics35.WebUI.UltraWebChart.v8.2 - v2.0.50727
This got put on the back burner for a while as a "Low Priority".
Still not fully completed it - but thought I should mention some progress.I believe David's settings above will fix my problem, once I get the Chart working again. :D
Have finally got the DrawString (as described above) to work.This took some bashing of code, and finally appears to have come down to a corrupted Arial Font.
This font was finally removed via Safe Mode and updated with one from another Server and finally it worked. This was loaded via the Control Panel/Font by dragging and dropping from a temp C drive location.
Anyone else encountering this problem may benefit from my code below.
The InstalledFontCollection is a list of the fonts that the GDI+ has access to, thus if it's not appearing it won't be able to use it.
As you can see, the Arial Font is being added using the PrivateFontCollection - which is how I discovered the Font file had become corrupted. This should allow you to utilise any Font on the Server without it being part of the GDI+.
NB: GetBaseURL(), gets the Base Path to the Application, which varies across servers with different Port Numbers.
protected void Page_Load(object sender, EventArgs e) { try { //Force garbage collection - should help solve some GDI+ issues GC.Collect(); PrivateFontCollection pfc = new PrivateFontCollection(); pfc.AddFontFile(@"c:\windows\fonts\Arial.ttf"); Font arial = new Font(pfc.Families[0], 12, FontStyle.Bold); Font bliss = new Font("Bliss2-Regular", 12, FontStyle.Bold); Font Haettenschweiler = new Font("Haettenschweiler", 12, FontStyle.Bold); Font Wingdings = new Font("Wingdings", 12, FontStyle.Bold); Bitmap bmp = new System.Drawing.Bitmap(250, 250); Graphics gfx = Graphics.FromImage(bmp); gfx.Clear(System.Drawing.Color.White); gfx.TextRenderingHint = TextRenderingHint.AntiAlias; gfx.DrawString("Arial Test", arial, Brushes.Black, 10, 10); gfx.DrawString("Bliss Test", bliss, Brushes.Black, 10, 30); gfx.DrawString("Haettenschweiler Test", Haettenschweiler, Brushes.Black, 10, 50); gfx.DrawString("Wingdings Test", Wingdings, Brushes.Black, 10, 70); gfx.Dispose(); GC.Collect(); string mypath = Server.MapPath("~/ChartImages/") + "test.png"; Response.Write("<br>Server Mapped Path: " + mypath); Response.Write("<br>GetBaseURL Path: " + GetBaseURL() + "/ChartImages/test.png"); bmp.Save(mypath, System.Drawing.Imaging.ImageFormat.Png); System.Web.UI.WebControls.Image tmpImage = new System.Web.UI.WebControls.Image(); tmpImage.ImageUrl = GetBaseURL() + "ChartImages/test.png"; Page.Controls.Add(tmpImage); InstalledFontCollection insFont = new InstalledFontCollection(); Response.Write("<br>Number Of Fonts In InstalledFontCollection: " + insFont.Families.GetLength(0).ToString()); foreach (FontFamily ff in insFont.Families) { Response.Write(ff.Name.ToString() + "<br>"); } } catch (Exception ex) { Response.Write("<br>" + ex.Message); } }
http://forums.asp.net/t/1383198.aspx
after some google searching that's the only link i could come up with that seems relevant.
maybe it is the same font but it looks different due to the SmoothingMode & TextRenderingHint settings on the server machine. try setting these properties explicitly on the chart control instead of leaving them at their defaults.
First up, thanks for the help!
After encountering the "A generic error occurred in GDI+" and struggling with permissions have finally got the above code working on both... However, whereas my Dev environment returns the correct font, the Test environment returns the incorrect.
Bah!
Any ideas?
try testing this code in both environments... sometimes it helps to simplify the problem, so let's see what happens without the chart / gauge involved.
protected void Page_Load(object sender, EventArgs e) { System.Drawing.Font arial = new System.Drawing.Font("Arial", 12f, System.Drawing.FontStyle.Bold); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(250, 250); System.Drawing.Graphics gfx = System.Drawing.Graphics.FromImage(bmp); gfx.Clear(System.Drawing.Color.White); gfx.DrawString("Hello World", arial, System.Drawing.Brushes.Black, System.Drawing.PointF.Empty); bmp.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png); }