J
Jonah Olsson
Hi guys!
I'm trying to use Swedish characters with DrawString but no luck. Do I need
to set the Charset somewhere?? I've been searching Google Groups for hours
now, but I can't find any help or tutorial. Below is my code.
Thanks for any kind of help!
Regards,
Jonah Olsson
Dim b As Bitmap = New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(b)
Dim solidBrush As SolidBrush = New SolidBrush(TextColor)
Dim privateFontCollection As PrivateFontCollection = New
PrivateFontCollection
privateFontCollection.AddFontFile(Server.MapPath("Static/Fonts/TELEBC__.TTF"
))
Dim thisFont As FontFamily = privateFontCollection.Families(0)
Dim regFont As Font = New Font(thisFont, FontSize, FontStyle.Bold,
GraphicsUnit.Pixel)
Dim Width As Integer
Width = Convert.ToInt32(g.MeasureString(Text, regFont).Width)
Dim Height As Integer
Height = Convert.ToInt32(g.MeasureString(Text, regFont).Height)
b = New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
g = Graphics.FromImage(b)
g.TextRenderingHint = TextRenderingHint.AntiAlias
g.SmoothingMode = SmoothingMode.AntiAlias
g.Clear(BackColor)
g.DrawString(Text, regFont, solidBrush, 0, 0,
StringFormat.GenericTypographic)
Response.ContentType = "image/gif"
b.Save(Response.OutputStream, ImageFormat.Gif)
b.Dispose()
I'm trying to use Swedish characters with DrawString but no luck. Do I need
to set the Charset somewhere?? I've been searching Google Groups for hours
now, but I can't find any help or tutorial. Below is my code.
Thanks for any kind of help!
Regards,
Jonah Olsson
Dim b As Bitmap = New Bitmap(1, 1)
Dim g As Graphics = Graphics.FromImage(b)
Dim solidBrush As SolidBrush = New SolidBrush(TextColor)
Dim privateFontCollection As PrivateFontCollection = New
PrivateFontCollection
privateFontCollection.AddFontFile(Server.MapPath("Static/Fonts/TELEBC__.TTF"
))
Dim thisFont As FontFamily = privateFontCollection.Families(0)
Dim regFont As Font = New Font(thisFont, FontSize, FontStyle.Bold,
GraphicsUnit.Pixel)
Dim Width As Integer
Width = Convert.ToInt32(g.MeasureString(Text, regFont).Width)
Dim Height As Integer
Height = Convert.ToInt32(g.MeasureString(Text, regFont).Height)
b = New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
g = Graphics.FromImage(b)
g.TextRenderingHint = TextRenderingHint.AntiAlias
g.SmoothingMode = SmoothingMode.AntiAlias
g.Clear(BackColor)
g.DrawString(Text, regFont, solidBrush, 0, 0,
StringFormat.GenericTypographic)
Response.ContentType = "image/gif"
b.Save(Response.OutputStream, ImageFormat.Gif)
b.Dispose()