mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
cleanup: name changes; don't measure the same glyph twice.
This commit is contained in:
parent
1536a05ac2
commit
1a1beed2f3
2 changed files with 20 additions and 13 deletions
|
@ -202,12 +202,12 @@ ceDrawTextClipped( HDC hdc, wchar_t* buf, XP_S16 len, XP_Bool clip,
|
||||||
const FontCacheEntry* fce, XP_U16 left, XP_U16 top,
|
const FontCacheEntry* fce, XP_U16 left, XP_U16 top,
|
||||||
XP_U16 width, XP_U16 hJust )
|
XP_U16 width, XP_U16 hJust )
|
||||||
{
|
{
|
||||||
RECT rect;
|
RECT rect = {
|
||||||
|
.left = left,
|
||||||
rect.left = left;
|
.top = top,
|
||||||
rect.top = top;
|
.bottom = top + fce->glyphHt,
|
||||||
rect.bottom = top + fce->glyphHt;
|
.right = left + width
|
||||||
rect.right = left + width;
|
};
|
||||||
|
|
||||||
if ( clip ) {
|
if ( clip ) {
|
||||||
ceClipToRect( hdc, &rect );
|
ceClipToRect( hdc, &rect );
|
||||||
|
@ -391,7 +391,7 @@ ceMeasureGlyph( HDC hdc, HBRUSH white, wchar_t glyph,
|
||||||
} /* ceMeasureGlyph */
|
} /* ceMeasureGlyph */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ceMeasureGlyphs( CEDrawCtx* dctx, HDC hdc, /* HFONT font, */wchar_t* str,
|
ceMeasureGlyphs( CEDrawCtx* dctx, HDC hdc, wchar_t* str,
|
||||||
XP_U16* hasMinTop, XP_U16* hasMaxBottom )
|
XP_U16* hasMinTop, XP_U16* hasMaxBottom )
|
||||||
{
|
{
|
||||||
HBRUSH white = dctx->brushes[CE_WHITE_COLOR];
|
HBRUSH white = dctx->brushes[CE_WHITE_COLOR];
|
||||||
|
@ -406,6 +406,11 @@ ceMeasureGlyphs( CEDrawCtx* dctx, HDC hdc, /* HFONT font, */wchar_t* str,
|
||||||
for ( ii = 0; ii < len; ++ii ) {
|
for ( ii = 0; ii < len; ++ii ) {
|
||||||
XP_U16 thisTop, thisBottom;
|
XP_U16 thisTop, thisBottom;
|
||||||
|
|
||||||
|
/* TODO: Find a way to to keep minTopIndex && maxBottomIndex the same
|
||||||
|
IFF there's a character, like Q, that has the lowest point but
|
||||||
|
as high a top as anybody else. Maybe for > until both are set,
|
||||||
|
then >= ? */
|
||||||
|
|
||||||
ceMeasureGlyph( hdc, white, str[ii],
|
ceMeasureGlyph( hdc, white, str[ii],
|
||||||
minTopSeen, maxBottomSeen,
|
minTopSeen, maxBottomSeen,
|
||||||
&thisTop, &thisBottom );
|
&thisTop, &thisBottom );
|
||||||
|
@ -485,7 +490,7 @@ ceBestFitFont( CEDrawCtx* dctx, XP_U16 soughtHeight, RFIndex index,
|
||||||
SelectObject( memDC, testFont );
|
SelectObject( memDC, testFont );
|
||||||
|
|
||||||
/* first time, measure all of them to determine which chars have
|
/* first time, measure all of them to determine which chars have
|
||||||
high and low points */
|
the set's high and low points */
|
||||||
if ( firstPass ) {
|
if ( firstPass ) {
|
||||||
ceMeasureGlyphs( dctx, memDC, widebuf, &hasMinTop,
|
ceMeasureGlyphs( dctx, memDC, widebuf, &hasMinTop,
|
||||||
&hasMaxBottom );
|
&hasMaxBottom );
|
||||||
|
@ -494,8 +499,10 @@ ceBestFitFont( CEDrawCtx* dctx, XP_U16 soughtHeight, RFIndex index,
|
||||||
/* Thereafter, just measure the two we know about */
|
/* Thereafter, just measure the two we know about */
|
||||||
ceMeasureGlyph( memDC, white, widebuf[hasMinTop], 1000, 0,
|
ceMeasureGlyph( memDC, white, widebuf[hasMinTop], 1000, 0,
|
||||||
&top, &bottom );
|
&top, &bottom );
|
||||||
|
if ( hasMaxBottom != hasMinTop ) {
|
||||||
ceMeasureGlyph( memDC, white, widebuf[hasMaxBottom],
|
ceMeasureGlyph( memDC, white, widebuf[hasMaxBottom],
|
||||||
top, bottom, &top, &bottom );
|
top, bottom, &top, &bottom );
|
||||||
|
}
|
||||||
thisHeight = bottom - top + 1;
|
thisHeight = bottom - top + 1;
|
||||||
|
|
||||||
if ( thisHeight <= soughtHeight ) { /* got it!!! */
|
if ( thisHeight <= soughtHeight ) { /* got it!!! */
|
||||||
|
|
|
@ -2151,12 +2151,12 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
RECT winrect;
|
RECT winrect;
|
||||||
if ( GetUpdateRect( hWnd, &winrect, FALSE ) ) {
|
if ( GetUpdateRect( hWnd, &winrect, FALSE ) ) {
|
||||||
if ( !!globals->game.board ) {
|
if ( !!globals->game.board ) {
|
||||||
XP_Rect rect;
|
XP_Rect xprect;
|
||||||
/* When an obscuring window goes away, the update region
|
/* When an obscuring window goes away, the update region
|
||||||
needs to be redrawn. This allows invalidating it. */
|
needs to be redrawn. This allows invalidating it. */
|
||||||
|
|
||||||
RECTtoXPR( &rect, &winrect );
|
RECTtoXPR( &xprect, &winrect );
|
||||||
board_invalRect( globals->game.board, &rect );
|
board_invalRect( globals->game.board, &xprect );
|
||||||
|
|
||||||
XP_ASSERT( globals->hWnd == hWnd );
|
XP_ASSERT( globals->hWnd == hWnd );
|
||||||
drawInsidePaint( globals, &winrect );
|
drawInsidePaint( globals, &winrect );
|
||||||
|
|
Loading…
Reference in a new issue