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# application and add a Paint event handler): -
public partial class Form1 : Form
-
{
-
public Form1()
-
{
-
InitializeComponent();
-
this.Paint += new PaintEventHandler(Form1_Paint);
-
}
-
-
void Form1_Paint(object sender, PaintEventArgs e)
-
{
-
Font f = new Font("Tahoma", 12); // this is used just to get a larger font
-
-
// try drawing with DrawString
-
e.Graphics.DrawString("Test \u2153", f, SystemBrushes.ControlText, new PointF(10, 50));
-
-
// try drawing with DrawText
-
TextRenderer.DrawText(e.Graphics, "Test \u2153", f, new Rectangle(10, 10, 50, 50), SystemColors.ControlText);
-
}
-
}
-
In Windows Vista, the unicode character (U2153, representing "1/3" in a single character) is drawn twice, but in Windows XP or 2000, it is not drawn in any case.
So, the question is: how to draw a unicode string in XP?
[EDIT:] I just found out something, but decided to add this post anyway: the main problem is - Windows XP Tahoma font simply does not have these characters! When you try to insert this unicode symbol in MS Word using Tahoma font, it is omitted from the list ( http://zero2180.net/2008/01/tahoma/).
I usually use SystemFonts.MessageBoxFont to get the default system font (returns "Tahoma" for XP and 2000, "Segoe" for Vista).
So what font should I then use for unicode?
6 10601
Find one that supports the characters you want and use that font?
Well actually I haven't succeeded writing a superscript "+" sign using any of the common Windows fonts in w2k. For example, Arial Unicode MS font (which is said to be one of Microsoft's most-complete fonts in sense of unicode support), is not included by default in my win2k sp4 installation (does it come with Office?).
I don't like the idea of an application installing its fonts to the system, and I don't like the idea of using the Arial font instead of Tahoma just to get a couple of glyphs - I try to follow the Windows GUI design guidelines and they suggest avoiding non-system-default fonts in controls. I usually use SystemFonts.MessageBoxFont, and I presume (I hope correctly) that it will return a font which supports locale characters on a given machine - we might decide to localize our application to Chinese one day!
So at the end, what I wanted to avoid was using DrawString to manually create subscript and superscript signs because I thought the win2k and xp "unicode" fonts supported them.
I have two clean Virtual PC installations of win2k and xp, and have also modified my first program to try some other fonts: -
using System.Windows.Forms;
-
using System.Drawing;
-
-
public partial class Form1 : Form
-
{
-
public Form1()
-
{
-
InitializeComponent();
-
this.Paint += new PaintEventHandler(Form1_Paint);
-
}
-
-
void Form1_Paint(object sender, PaintEventArgs e)
-
{
-
string[] fontNames = new string[]
-
{ "Arial",
-
"Tahoma",
-
"Microsoft Sans Serif",
-
"Arial Unicode MS",
-
"Lucida Sans Unicode",
-
"MS Sans Serif",
-
SystemFonts.DefaultFont.FontFamily.Name,
-
SystemFonts.MessageBoxFont.FontFamily.Name };
-
-
int yOffset = 10;
-
-
foreach (string f in fontNames)
-
using (Font fnt = new Font(f, 12))
-
{
-
e.Graphics.DrawString(fnt.FontFamily.ToString() + " \u2153", fnt, SystemBrushes.ControlText, new PointF(10, yOffset)); yOffset += 20;
-
TextRenderer.DrawText(e.Graphics, fnt.FontFamily.ToString() + " \u2153", fnt, new Point(10, yOffset), SystemColors.ControlText); yOffset += 20;
-
}
-
}
-
}
-
It has a list of constant font family names, and two system defined fonts at the end. Windows XP shows the "1/3" glyph only with plain Arial font, but Win 2000 does not show it using any of the fonts.
Can anyone tell me if there is a font which works for you in w2k, and should be included by default?
Have you checked using charmap?
I avoid win2k like the plague so I don't have access to it anymore.
Thanks for the tip, I haven't used Char. map for a long time. I started it in both windows xp and 2000, and found which fonts support which glyphs.
They are pretty mixed up, so I will probably try to isolate those special glyphs and handle them separately, leaving MessageBoxFont as the default font for normal text. Should have done it in the first place! :)
Thanks!
How to use charmap for special character for writing a string in drawstring?
I have a long string, trying to print it using drawstring function, but the special character are getting doubled in the output print. Please help me how to use charmap to get rid of this problem. Your suggestion is very important for me
Sign in to post your reply or Sign up for a free account.
Similar topics
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: Charles A. Lackman |
last post by:
Hello,
I have created a complete PrintDocument and need to create an image from it.
How is this done?
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
|
by: Gürkan Demirci |
last post by:
Hi,
i am trying to write Jananese characters with DrawString().
It is not working. The characters a printed as boxes only.
How can i change the culture of my windows forms application ?
It...
|
by: Michael Galvin |
last post by:
I am trying to use Python to send to the printer a calender filled
with a mix of text and simple graphics. I want to draw on the printed
page something like a table with 6 rows and 7 columns to...
|
by: Peter Row |
last post by:
Hi,
I've started work on my own control some parts of which use standard
controls, others I need to draw on my controls surface to get the display
output I require, however....
I seem to be...
|
by: grawsha2000 |
last post by:
Hi,
Is there a way to force Graphics.drawstring() method to display Hindi
numbers when printing?
I changed the locale settings of the Regional Options to an Arabic
lang. but no luck.
...
|
by: Tony Johansson |
last post by:
Hello!
If I use the DrawString below with object of StringFormat as the last object
it works good.
If I instead remove object StringFormat below as the last object of
DrawString I get some rows...
|
by: Dilip |
last post by:
Howdy Folks
I have a display where the Graphics.DrawString function is called to
display something. Since the text seems to be larger than its
bounding rectangle, the call basically splits the...
|
by: anuking |
last post by:
Hi,
I made a tool that compares the texts from 2 richtextboxes and then marks the characters that are different in red. An option needs me to overlap these 2 text data to show the exact...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |