On Wed, 27 Aug 2003 Dave_Belanger@cimmetry.com wrote:
+ + /* check for underline or strike-through */ + long lineWidth = tm.tmDescent / 4; + + if (lf.lfUnderline) { + long linePos = tm.tmDescent / 2; + + TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); + TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, + LineSolid, CapProjecting, JoinBevel ); + TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, + physDev->org.x + x, physDev->org.y + y + linePos, + physDev->org.x + x + width, physDev->org.y + y + linePos ); + } + + if (lf.lfStrikeOut) { + long linePos = tm.tmAscent / 3.5; + + TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); + TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, + LineSolid, CapProjecting, JoinBevel ); + TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, + physDev->org.x + x, physDev->org.y + y - linePos, + physDev->org.x + x + width, physDev->org.y + y - linePos ); + }
What about we simplify this a bit:
if (lf.lfUnderline || lf.lfStrikeOut) { long linePos = (lf.lfUnderline ? tm.tmDescent / 2 : - tm.tmAscent / 3.5);
TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, physDev->org.x + x, physDev->org.y + y + linePos, physDev->org.x + x + width, physDev->org.y + y + linePos ); }
Le mer 27/08/2003 à 17:34, Dimitrie O. Paun a écrit :
On Wed, 27 Aug 2003 Dave_Belanger@cimmetry.com wrote:
...
if (lf.lfUnderline) {
...
TSXDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + x, physDev->org.y + y + linePos,
physDev->org.x + x + width, physDev->org.y + y + linePos );
...
if (lf.lfStrikeOut) {
...
TSXDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + x, physDev->org.y + y - linePos,
physDev->org.x + x + width, physDev->org.y + y - linePos );
What about we simplify this a bit:
if (lf.lfUnderline || lf.lfStrikeOut) { long linePos = (lf.lfUnderline ? tm.tmDescent / 2 : - tm.tmAscent / 3.5); TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, physDev->org.x + x, physDev->org.y + y + linePos, physDev->org.x + x + width, physDev->org.y + y + linePos ); }
Not sure it'll do the same thing, it's +linePos in the first case and -linePos in the second...
Vincent
Le mer 27/08/2003 à 17:43, Vincent Béron a écrit :
Le mer 27/08/2003 à 17:34, Dimitrie O. Paun a écrit :
On Wed, 27 Aug 2003 Dave_Belanger@cimmetry.com wrote:
...
if (lf.lfUnderline) {
...
TSXDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + x, physDev->org.y + y + linePos,
physDev->org.x + x + width, physDev->org.y + y + linePos );
...
if (lf.lfStrikeOut) {
...
TSXDrawLine( gdi_display, physDev->drawable, physDev->gc,
physDev->org.x + x, physDev->org.y + y - linePos,
physDev->org.x + x + width, physDev->org.y + y - linePos );
What about we simplify this a bit:
if (lf.lfUnderline || lf.lfStrikeOut) { long linePos = (lf.lfUnderline ? tm.tmDescent / 2 : - tm.tmAscent / 3.5); TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, physDev->org.x + x, physDev->org.y + y + linePos, physDev->org.x + x + width, physDev->org.y + y + linePos ); }
Not sure it'll do the same thing, it's +linePos in the first case and -linePos in the second...
Do'h! Just saw the - in in front of tm.tmAscent. Forget this.
Vincent
On Wed, Aug 27, 2003 at 05:34:53PM -0400, Dimitrie O. Paun wrote:
What about we simplify this a bit:
if (lf.lfUnderline || lf.lfStrikeOut) { long linePos = (lf.lfUnderline ? tm.tmDescent / 2 : - tm.tmAscent / 3.5); TSXSetForeground( gdi_display, physDev->gc, physDev->textPixel ); TSXSetLineAttributes( gdi_display, physDev->gc, lineWidth, LineSolid, CapProjecting, JoinBevel ); TSXDrawLine( gdi_display, physDev->drawable, physDev->gc, physDev->org.x + x, physDev->org.y + y + linePos, physDev->org.x + x + width, physDev->org.y + y + linePos ); }
Actually you want to use the otmsUnderscoreSize, otmsUnderscorePosition, otmsStrikeoutSize and otmsStrikeoutPosition members of OUTLINETEXTMETRIC, rather than hard coding those 2s and 3.5s.
You may also want to think about what happens when the text is rotated :)
Huw.
On Wed, 27 Aug 2003, Huw D M Davies wrote:
Actually you want to use the otmsUnderscoreSize, otmsUnderscorePosition, otmsStrikeoutSize and otmsStrikeoutPosition members of OUTLINETEXTMETRIC, rather than hard coding those 2s and 3.5s.
You may also want to think about what happens when the text is rotated :)
These are good points. But having common code makes all this a bit easier to handle. I just made a trivial simplification, I don't pretend to understand the problem. :)
On Wed, Aug 27, 2003 at 06:12:44PM -0400, Dimitrie O. Paun wrote:
On Wed, 27 Aug 2003, Huw D M Davies wrote:
Actually you want to use the otmsUnderscoreSize, otmsUnderscorePosition, otmsStrikeoutSize and otmsStrikeoutPosition members of OUTLINETEXTMETRIC, rather than hard coding those 2s and 3.5s.
You may also want to think about what happens when the text is rotated :)
These are good points. But having common code makes all this a bit easier to handle. I just made a trivial simplification, I don't pretend to understand the problem. :)
True, they were really comments for Dave. Your simplification however doesn't work if both lfUnderline and lfStrikeout are set...
Huw.