How to change a font programatically?
Hi, I am fairly new to RAP and I need some advice on how to change a font from within a report based on data within the report. I have a printed label with limited space as a report. One line of the information can vary from 10 characters to 60+. I wish to be able to have a larger font when few characters are printed and then change the font size to a smaller font when more data has to be printed.
Can someone please provide a clue on how this is done?
Best regards,
Bruce
Can someone please provide a clue on how this is done?
Best regards,
Bruce
Comments
Take a look at the following example on finding the right font size to fit in a static area. It uses the Band.BeforePrint event to compare the text width to the width of the control, then begins shrinking the font in a loop and re-testing until it fits. Doing something similar is RAP should be fairly easy however the text measurement aspect may need to be moved outside RAP into a pass-thru function.
See the main RAP demos for how to create and use pass-thru functions.
http://www.digital-metaphors.com/tips/AutoFontSize.zip
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Many thanks.
I am facing the same issue, for the first time.
I went through Nico's sample code, but I don't understand it fully.
Should my ppDBText1have the Autosize property true?
If I set it to false, it never reduces the font size even for very long texts; if I set it to true, it reduces it a bit too much, aka it does not use the whole space available.
In the function ppToMMThousandths, why are you using the parametrs utInches in the first call, and utPrinterPixels in the second one?
Thank you very much!