Board index » delphi » How to write non Ascii characters on Canvas

How to write non Ascii characters on Canvas


2003-10-03 09:21:30 PM
delphi142
Hi Group
I have some code that looks like this
with Canvas do begin
Font.Color := AColor;
TextOut(x, y, s);
w := TextWidth(s);
end;
to write a string s on a canvas. How do I write special characters like an
em-dash or a dagger or other non-Ascii chars ? I would like to be able to write
any character in any font.
I'm sure its pretty simple, but I couldn't find the information.
Thanks !
Jacob
 
 

Re:How to write non Ascii characters on Canvas

Hi Jacob,
Set the Canvas.Font.Name property to any of the wingding fonts, then choose
the right character code and use the normal TextOut command.
You can also install additional fonts by dropping the TTF file in your
Windows Fonts directory. Free fonts of any flavour can be found on the
internet.
Kind regards,
Nils Haeck
www.simdesign.nl
"Jacob Havkrog" <XXXX@XXXXX.COM>writes
Quote
Hi Group

I have some code that looks like this

with Canvas do begin
Font.Color := AColor;
TextOut(x, y, s);
w := TextWidth(s);
end;

to write a string s on a canvas. How do I write special characters like an
em-dash or a dagger or other non-Ascii chars ? I would like to be able to
write
any character in any font.

I'm sure its pretty simple, but I couldn't find the information.

Thanks !
Jacob


 

Re:How to write non Ascii characters on Canvas

Quote
How do I write special characters like an
em-dash or a dagger or other non-Ascii chars ?
Are you talking Unicode, or do you simply mean the non-keyboard characters
from the extended ASCII character set?Em-dash is ASCII 151, and Dagger 134.
Use Chr function to return a character (Char type) for any integer in the
AnsiChar or WideChar range. For example to draw em-dash
TextOut(x, y, Chr(#151));
HTH
Dave
 

Re:How to write non Ascii characters on Canvas

Thanks for your kind, patient replies. It turns out that my problem was that
I was using the very restricted font MS sans serif that does not contain
daggers and the like.
But, how do I write real unicode letters on a canvas, like Arial cyrillic
letters ?
Thanks in advance
Jacob
"Dave Blake" <XXXX@XXXXX.COM>skrev i en meddelelse
Quote
>How do I write special characters like an
>em-dash or a dagger or other non-Ascii chars ?

Are you talking Unicode, or do you simply mean the non-keyboard characters
from the extended ASCII character set?Em-dash is ASCII 151, and Dagger
134.
Use Chr function to return a character (Char type) for any integer in the
AnsiChar or WideChar range. For example to draw em-dash

TextOut(x, y, Chr(#151));

HTH
Dave


 

Re:How to write non Ascii characters on Canvas

You cannot use the standard TCanvas.TextOut because it only accepts a normal
string.
Therefore, switch to the Windows GDI function "TextOutW" (see windows.pas):
function TextOutW(DC: HDC; X, Y: Integer; Str: PWideChar; Count: Integer):
BOOL; stdcall;
The DC is the TCanvas.Handle, Str is a pointer to a WideChar or Widestring,
which can contain any character code in the unicode set. Count is the number
of characters to output.
Kind regards,
Nils Haeck
www.simdesign.nl
"Jacob Havkrog" <XXXX@XXXXX.COM>writes
Quote
Thanks for your kind, patient replies. It turns out that my problem was
that
I was using the very restricted font MS sans serif that does not contain
daggers and the like.

But, how do I write real unicode letters on a canvas, like Arial cyrillic
letters ?

Thanks in advance
Jacob



"Dave Blake" <XXXX@XXXXX.COM>skrev i en meddelelse
news:XXXX@XXXXX.COM...
>>How do I write special characters like an
>>em-dash or a dagger or other non-Ascii chars ?
>
>Are you talking Unicode, or do you simply mean the non-keyboard
characters
>from the extended ASCII character set?Em-dash is ASCII 151, and Dagger
134.
>Use Chr function to return a character (Char type) for any integer in
the
>AnsiChar or WideChar range. For example to draw em-dash
>
>TextOut(x, y, Chr(#151));
>
>HTH
>Dave
>
>


 

Re:How to write non Ascii characters on Canvas

"Jacob Havkrog" <XXXX@XXXXX.COM>writes
Quote
I'm sure its pretty simple, but I couldn't find the information.
Perhaps this will help:
homepages.borland.com/efg2lab/OtherProjects/Unicode.htm
--
efg -- Earl F. Glynn, Overland Park, KS USA
efg's Computer Lab: www.efg2.com/Lab
Mirror: homepages.borland.com/efg2lab/Default.htm