TOPIC: Reporting : underline? italic? how to format text
#1309
Reporting : underline? italic? how to format text 1 Year, 7 Months ago
First, hi to everyone on the forum. I think that Suneido is a great software, with a lot of features. The documentation is not very helping for some points : I can find some basic text formating : how do you print a text in italic or underline?

A text can be given a font. The only parameter in the docs is "weight".
 
 
#1311
Re:Reporting : underline? italic? how to format text 1 Year, 7 Months ago
Hi,

Looking at the latest Report.SelectFont (in stdlib), font can include:

name
size (in points, e.g. 14)
weight (e.g. 700 for bold)
italic (true or false)

e.g. font: (name: 'Arial', size: 14, weight: 700, italic: )

It should be easy enough to add the other features supported by LOGFONT e.g. underline and strikeout. I guess no one needed them till now. The code would be very similar to italic. We're always looking for contributions :-)

Sounds like the documentation needs updating, I will look at it.

Hope that helps!
 
 
Last Edit: 2009/01/23 23:09 By andrew.
 
andrew
 
#1313
Re:Reporting : underline? italic? how to format text 1 Year, 7 Months ago
Thanks, so Italic can be used in reports. For underline, I'll try to do it in the library. It seems to be easy... Let's try.

After a first test, it seems to work. But it doesn't show in preview mode. I use CutePDF as my default printer.

Here is the code :
Code:


weight = font.GetDefault(#weight, 400)
italic = font.GetDefault(#italic, false)
underline = font.GetDefault(#underline, false)

size = font.GetDefault(#size, { .curfont.size })
size = (size * 20).Int()

name = font.GetDefault(#name, 'Arial')
id = name $ " " $ size $ " " $ weight;
if (.fonts.Member?(id))
f = .fonts[id];
else
{
lf = Object(
lfFaceName: font.name,
lfHeight: -size,
lfWeight: weight,
lfItalic: italic,
lfUnderline: underline,
lfCharSet: CHARSET[font.Member?("charset") ? font.charset : 'DEFAULT']
);

 
 
Last Edit: 2009/01/23 21:23 By WwW1. Reason: The code
 
#1314
Re:Reporting : underline? italic? how to format text 1 Year, 7 Months ago
I think the problem is that Report caches the fonts under id but id did not include underline (or italic). Just need to change it to:

id = name $ " " $ size $ " " $ weight $ " " $ italic $ " " $ underline

The other problem I noticed is that it should be name instead of font.name in:

lfFaceName: name

so you can have just font: ( underline: )

I have added this to stdlib for the next release. Thanks!
 
 
Last Edit: 2009/01/23 23:05 By andrew.
 
andrew