TextRenderer

Hi,
(argh, could you set a reply-to field to the list?)
2009/11/23 Geoffrey Hutchison :

Avogadro::Painter have no interface to set fonts. I’ve looked inside text renderer, and my first wish was to overload draw() to accept QFont.

I’d add methods to TextRenderer to set the font and/or size explicitly. This way, the existing calls to draw() can remain the same – I think this approach is more in keeping with Qt API as well.
Just one note about the TextRenderer, assuming that didnt change since
my days: it assumes a single font/size to be used throughout, in the
following sense: the hash-table where textrenderer stores glyphs, is
indexed by QChar’s, so it is not aware of font and font size. So if
you render a ‘Z’ with size 12, then afterwards when you want to print
‘Zorro’ in size 14, it will use the cached ‘Z’ of size 12.
So if you want TextRenderer to be aware of multiple fonts/sizes, you
need to make that part of the indexes used in the Hash table.
Not sure what the best way to do this is; either you find an efficient
way of getting a single hash value for a (QFont,QChar) pair, or
perhaps instead it’s better to have a “hash table of hash tables”, the
big table indexed by QFont, the small tables are like the existing one
indexed by QChar …?
Oh and you could discuss that with kgllib / Gluon people who are using
a variant of TextRenderer.

I think it would be rather ineffective to store all chars of all fonts in hash. Maybe it’s possible to change them dynamicaly? There will be no more then two fonts and two font sizes simultaniously in the view (atom and bond labels_


Regards,
Konstantin

New code I’ve recently submitted to my Git allows user to change color of atom and bond labels. But when I tried to change fonts, I’ve faced with problem Avogadro::Painter have no interface to set fonts. I’ve looked inside text renderer, and my first wish was to overload draw() to accept QFont. But than I’ve found in sources some tricks dependent on font size. Also I’ve found issue https://sourceforge.net/tracker/?func=detail&aid=2902472&group_id=165310&atid=835077

Will change of font work?


Regards,
Konstantin

Avogadro::Painter have no interface to set fonts. I’ve looked inside text renderer, and my first wish was to overload draw() to accept QFont.

I’d add methods to TextRenderer to set the font and/or size explicitly. This way, the existing calls to draw() can remain the same – I think this approach is more in keeping with Qt API as well.

Just my $0.02,
-Geoff

Hi,

(argh, could you set a reply-to field to the list?)

2009/11/23 Geoffrey Hutchison geoff.hutchison@gmail.com:

Avogadro::Painter have no interface to set fonts. I’ve looked inside text renderer, and my first wish was to overload draw() to accept QFont.

I’d add methods to TextRenderer to set the font and/or size explicitly. This way, the existing calls to draw() can remain the same – I think this approach is more in keeping with Qt API as well.

Just one note about the TextRenderer, assuming that didnt change since
my days: it assumes a single font/size to be used throughout, in the
following sense: the hash-table where textrenderer stores glyphs, is
indexed by QChar’s, so it is not aware of font and font size. So if
you render a ‘Z’ with size 12, then afterwards when you want to print
‘Zorro’ in size 14, it will use the cached ‘Z’ of size 12.

So if you want TextRenderer to be aware of multiple fonts/sizes, you
need to make that part of the indexes used in the Hash table.

Not sure what the best way to do this is; either you find an efficient
way of getting a single hash value for a (QFont,QChar) pair, or
perhaps instead it’s better to have a “hash table of hash tables”, the
big table indexed by QFont, the small tables are like the existing one
indexed by QChar …?

Oh and you could discuss that with kgllib / Gluon people who are using
a variant of TextRenderer.

Benoit

Just my $0.02,
-Geoff


Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what’s new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options