Thread: [Plib-devel] PUI rendering fixes
Brought to you by:
sjbaker
From: Andy R. <an...@pl...> - 2004-05-04 19:15:36
Attachments:
pui-rendering.patch
|
I started chasing down a font rendering issue in FlightGear on Sunday. The original issue was a metrics bug in the afm2txf.pl font generator, a script I wrote for plib a while back. But fixing that didn't quite solve all the problems, so I spent some time hunting around in the PUI rendering code and fixing buglets. The patch is attached. Explanations: There was a hard-coded assumption in fnt.cxx that when rendering multi-line strings the interline distance was 1.333 * pointsize. My guess is that this was there as a workaround for an older bug somewhere; pointsize is, of course, the very definition of interline distance. Likewise, puFont has a getStringHeight() with the same baked-in constant. I rewrote this to use the more common GUI convention that the height of a single line of text is "ascender + descender", instead of the full point size (which includes significant whitespace in many fonts). Once that was changed, it exposed some weirdness in the vertical positioning code in puInput and puObject. I'm honestly not sure what the older formulas were trying to do. I changed them all to adhere to the line height convention above (i.e.: ascender + descender + (Nlines - 1) * pointsize). Vertical centering of text now looks significantly better. The dashed line rendered for the "default" button almost always cut right through the button text. I moved it out by three pixels, which gives it one pixel of margin from the edge of the thickest widget border. I also changed the stipple to a simpler 1010 pattern from the four-pixel dash pattern it originally had. IMHO, the tighter pattern is prettier. The rendering code for the "default" line also had a coordinate aliasing bug: when drawing GL_LINES, you have to use pixel center coordinates or else the GL will see a value exactly on the edge of two pixels and you'll get funny off-by-one artifacts. I fixed a similar coordinate issue with the puInput caret rendering. I also increased its height; most GUIs draw this from the bottom of the descender to the baseline of the next line. I tried this with a bunch of test code (and FlightGear, of course) and it doesn't seem to break anything. Andy |
From: Steve B. <sjb...@ai...> - 2004-05-04 23:35:03
|
Andy Ross wrote: > The dashed line rendered for the "default" button almost always cut > right through the button text. I moved it out by three pixels, which > gives it one pixel of margin from the edge of the thickest widget > border. I also changed the stipple to a simpler 1010 pattern from the > four-pixel dash pattern it originally had. IMHO, the tighter pattern > is prettier. I chose the 0x0F0F pattern because 0x5555 or even 0x3333 tend to look more like a grey line on cheap high resolution CRT's. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |
From: Andy R. <an...@pl...> - 2004-05-05 01:02:41
Attachments:
pui-old.png
pui-new.png
|
Steve Baker wrote: > Andy Ross wrote: > > I also changed the stipple to a simpler 1010 pattern from the > > four-pixel dash pattern it originally had. IMHO, the tighter > > pattern is prettier. > > I chose the 0x0F0F pattern because 0x5555 or even 0x3333 tend to > look more like a grey line on cheap high resolution CRT's. And is a grey line undesirable? FWIW, current versions of Gtk+ use exactly the same stipple pattern to indicate their keyboard focus. I've attached two (tiny) screenshots of the old and new code as an example. Honestly, the wide dashes look kinda clunky to me. Would you accept a patch that made the value settable? Andy |
From: Andy R. <an...@pl...> - 2004-05-12 15:50:08
|
Andy Ross wrote: > I started chasing down a font rendering issue in FlightGear on Sunday. > The original issue was a metrics bug in the afm2txf.pl font generator, > a script I wrote for plib a while back. But fixing that didn't quite > solve all the problems, so I spent some time hunting around in the PUI > rendering code and fixing buglets. The patch is attached. Can I get a yea or nay on this patch? Are there objections? I've just commited some layout management code for FlightGear which, while it doesn't strictly require the plib patch, certainly looks better with it enabled. Andy |
From: Andy R. <an...@pl...> - 2004-05-14 17:55:54
|
Knock, knock. Andy Ross wrote: > Andy Ross wrote: > >>I started chasing down a font rendering issue in FlightGear on Sunday. >>The original issue was a metrics bug in the afm2txf.pl font generator, >>a script I wrote for plib a while back. But fixing that didn't quite >>solve all the problems, so I spent some time hunting around in the PUI >>rendering code and fixing buglets. The patch is attached. > > > Can I get a yea or nay on this patch? Are there objections? I've just commited > some layout management code for FlightGear which, while it doesn't strictly > require the plib patch, certainly looks better with it enabled. |