[Interest] QML Text.Fit question

Harri Pasanen harri at mpaja.com
Thu Jan 29 21:12:32 CET 2015


We'll putting on my designer classes here:

Imagine I have a rectangle on screen, let's say a sign to a shop.
I want to have the title text within the sign so that it leaves 5 mm 
margin on both sides and top and bottom.   So I compute the rectangle 
where the text needs to fit, exactly so that it complements the golden 
ratio of the larger layout.

Then I need to use the same font, exactly half size elsewhere in the 
image, again to please my eye.
At that point it is convenient to know what the initial font size was.

Or how would you achieve this otherwise?

Regards,

Harri




On 29/01/2015 13:47, Curtis Mitch wrote:
> I've found that a combination of scaling font size based on the default font size (font.pixelSize of an empty Text item, for example, or the new Font/TextMetrics types) and Text.Fit handles stuff pretty well. I'd be interested to see your case where it's not working, just because I'm curious. :)
>
> The patch to expose it shouldn't be that hard, and I don't see a reason why it'd be rejected. Still, I wonder if there's a better way to solve your problem.
>
> ________________________________________
> From: Harri Pasanen <harri at mpaja.com>
> Sent: Wednesday, 28 January 2015 15:48
> To: Curtis Mitch; interest at qt-project.org
> Subject: Re: [Interest] QML Text.Fit question
>
> On 28/01/2015 13:25, Curtis Mitch wrote:
>> Why do you need to know the size of the text?
> I work mostly in mobile space where the size, resolution and pixel
> densities vary greatly between displays.
>
> If one wants to automate layout so that it remains usable (even if not
> "artful" in all cases), one needs to settle on a font size where all the
> text fits.   So it is convenient to be able to ask for a font size that
> fits in a given rectangle and then standardize on that.
>
> I think it would be useful to expose that property in Text element.
>
> Just my 2 cents,
>
> Harri
>




More information about the Interest mailing list