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() 3 2032
Jonah,
It probably depends on whether the font you use is a Unicode one. If it is
not unicode, character translation should be done to match Swedich
characters stored as Unicode ones in a String with the code page the Font
uses. To set up this code page, use the GdiCharSet property of the Font
class.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jonah Olsson" <jo***@IHateSpam.com> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl... 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()
Hi Dmitriy,
I solved the problem by using UrlEncode and UrlDecode, but that feels like a
bad work around. I have to call the web page (in <img src="...">) with
Web.HttpUtility.UrlEncode(...) and then decode the string in my code.
I'll try to set the GdiCharSet to see if there's a way I can skip the encode
and decode part.
Thanks.
Jonah
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> skrev i
meddelandet news:3f********@nexus.validio.com.ua... Jonah,
It probably depends on whether the font you use is a Unicode one. If it is not unicode, character translation should be done to match Swedich characters stored as Unicode ones in a String with the code page the Font uses. To set up this code page, use the GdiCharSet property of the Font class.
Jonah,
Oops, I assumed you used Windows Forms. With the Web, you should set a
correct encoding for the web page in the appropriate meta tag (as well as in
the "Content-Type" header). I am not completely sure, but the HttpResponse
class should have the Encoding property. Set properly, it should
automatically take care over encoding the Unicode characters you send to the
response stream to the right code page.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Jonah Olsson" <jo***@IHateSpam.com> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl... Hi Dmitriy,
I solved the problem by using UrlEncode and UrlDecode, but that feels like
a bad work around. I have to call the web page (in <img src="...">) with Web.HttpUtility.UrlEncode(...) and then decode the string in my code.
I'll try to set the GdiCharSet to see if there's a way I can skip the
encode and decode part.
Thanks. Jonah
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> skrev
i meddelandet news:3f********@nexus.validio.com.ua... Jonah,
It probably depends on whether the font you use is a Unicode one. If it
is not unicode, character translation should be done to match Swedich characters stored as Unicode ones in a String with the code page the
Font uses. To set up this code page, use the GdiCharSet property of the Font class.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Roy W. Andersen |
last post by:
I've been searching google about this for days but can't find anything,
so I'm hoping someone here can help me out.
I'm trying to create zip-files without needing the zip-file extension in
PHP,...
|
by: Barry Olly |
last post by:
Hi,
I'm working on a mini content management system and need help with
dealing with special characters.
The input are taken from html form which are then stored into a
varchar column in...
|
by: Jonah Olsson |
last post by:
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...
|
by: Sakharam Phapale |
last post by:
Hi All,
I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function
gives an error as "Unable to open input file"....
|
by: sonald |
last post by:
Dear All,
I am working on a module that validates the provided CSV data in a text
format, which must be in a predefined format.
We check for the :
1. Number of fields provided in the text file,...
|
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= |
last post by:
I'm drawing text using the DrawString method. I need a way to go back and
erase one or more characters. As a first thought it seemed that one way to
do it would be to go back to the character(s)...
|
by: KevinADC |
last post by:
Purpose
The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
|
by: vaskarbasak |
last post by:
Hi all,
I am trying to display a Chinese string (UTF-8) with
Graphics2D.drawString() but nothing is displayed.
here i paste my code
package com;
import java.awt.*;
import...
|
by: vekipeki |
last post by:
I am having a problem with basic drawing of unicode characters in Windows 2000 and XP.
I have written a simplest possible C# WinForms program to test it (just create a new Windows Forms C#...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |