Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use certain font with sprintf command ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
Hi,

can I use a certain font with sprintf command ,say,"courier" ?
thanks

Long live king Moshiach !
 
aloha,
maybe i'm totally wrong, but i think that's quite impossible. sprintf is usually used to output something to a scalar. a scalar containing a string is totally independent of fonts etc.
for details on sprintf and printf, see the perlfunc manpage (run "perldoc perlfunc"). maybe curses are able to change terminal font, maybe even for each line separately. in that case you could use curses for output, i don't know that. if you have a GUI application using Tk, Gtk or something, then you can definately set the fonts as you want. but that would be independent from thh sprintf function.
merry christmas
michael
 
That's an ambiguous question. sprintf and printf are a lot like print in how they work, and so they don't imply fonts or anything. The fonts would have to do with how you present the data.

i.e. HTML
Code:
sprintf ("<strong>%02d</strong>", $number);

i.e. Tk
Code:
# where $text is a Tk::Text widget
$text->tagConfigure ('mynewfont',
   -font => [
      -family => 'Courier New',
      -size   => 10,
      -weight => 'bold',
   ],
   -foreground => 'red',
);

$text->insert ('end',
   sprintf ("%02d",$number),
   'mynewfont',
);

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
Thanks.

My code is like :

$temp1=sprintf("%-20s %-15s\n","DiskTime",$DiskTime);
print ALERTLOG "$temp1" if ($mailcounter == int($MailInterval/$SampleInterval -1));

Then ALERTLOG file is sent by some mail program and read in Outlook.It opens with Ariel fonts (unrelated to Outlook settings ...) which looses all the sprintf formating.
If then in outlook I change the font to courier,then the formating is back.
But I'm looking for the way to bring the file with courier formating inside .
thanks


Long live king Moshiach !
 
Email is the same as webpages. You have to html encode the content and send the appropriate headers for an email client to display formatted content.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Why not just have Outlook display plain text e-mails in a monospaced font (which tends to be the default in most mail clients). If you want to see messages in Arial, tell your friends to send HTML messages and use Arial font.

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top