Well, suppose I want to pass the font size used to a custom QQuickItem? I think it would be useful to expose it.
Anyway, for me the discussion has been academic for a while, I already went to QFontMetrics in C++ some time ago... Thanks for the feedback though :) Harri On 30/01/2015 12:57, Curtis Mitch wrote: > If you're already using a rectangle to determine the size of the text, why > not use one half the size to determine text that should be half the size? > > Besides that, there's probably not a better way to achieve what you're after, > other than exposing the font size. > > Another option to consider, if you want to somehow get access to the font > size, is to provide a function in QFontMetrics: > > int fontSize(const QRect &boundingRect) const > > I'm not sure if that makes sense for QFontMetrics' API, but I'm just throwing > ideas around. :) > > ________________________________________ > From: Harri Pasanen <ha...@mpaja.com> > Sent: Thursday, 29 January 2015 21:12 > To: Curtis Mitch; interest@qt-project.org > Subject: Re: [Interest] QML Text.Fit question > > 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 <ha...@mpaja.com> >> Sent: Wednesday, 28 January 2015 15:48 >> To: Curtis Mitch; interest@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 >> _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest