Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Auto Font Size to Fit

edited March 2006 in General
Hi,

Is their a way that I can code in my application a way to detect whether or
not the text fits inside a ppText component?

In a previous application, I had set the font to start at 14, and reduce in
size, if the text overflowed until the entire text would display within the
component. (For a comments field) and i would like to reproduce this with
Reportbuilder.

Thanks & Regards

Adam.

Comments

  • edited March 2006
    Hi Adam,

    Take a look at the following example of changing the font size to fit a
    static area.

    http://www.digital-metaphors.com/tips/AutoFontSize.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2006
    Thanks Nico,

    This works with a single lined component, but is it possible to find out how
    to do this with a multiple lined tppdbMemo component? (So it uses up all the
    width and height, before it starts shrinking the font)?

    Thanks & Regards

    Adam.
  • edited March 2006
    Hi Adam,

    Take a look at this example of forcing the font of a memo to fit inside a
    single page. You could use the same technique of printing to a "dummy"
    device initially to measure the memo before deciding whether to shrink the
    font or not.

    http://www.digital-metaphors.com/tips/ForceFontToOnePageReport.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2006
    Hi Nico,

    Thanks for your reply, and your help to date.

    Unforutnatly, this is not able to help me with my particular issue. I will
    try to explain clearer:

    I have a form that needs to be printed. Within that form, is a space (let's
    say 6cm x 4cm) that is used for comments or description. I have placed a
    static sized memo field in this location, with a font size of 12pt. (The
    same as everything else on the report to start with).

    However, it is possible that the comments or description that will print in
    this area may be greater than what the memo can fit at 12pt. If this is the
    case, I need to be able to resize the font within the memo to shrink to a
    size that will allow all the text to fit within the memo.

    The first example you gave me was good, but it only worked for a single line
    label (not a word wrapped label). The second example you gave me was more
    for the entire page, rather than just a single memo field.

    Is what I'm trying to achieve possible within Reportbuilder?

    Thanks again for all your help.

    Adam.
  • edited March 2006
    Hi Adam,

    Yes, this should be possible, however you will need to measure your memo
    text before the memo object is created. There is unfortunately nothing
    built-in to ReportBuilder to achieve this. Using the static width of the
    memo object, you can determine how many lines will be required, then using
    the Canvas.TextHeight routine, you could determine if that many lines will
    fit in the alloted space.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.