void UFont::GetStringHeightAndWidth( const TCHAR *Text, int32& Height, int32& Width ) const { float TotalWidth = 0.0f; float TotalHeight = 0.0f; const TCHAR* PrevChar = nullptr; while( *Text ) { float TmpWidth, TmpHeight; GetCharSize( *Text, TmpWidth, TmpHeight ); int8 CharKerning = 0; if (PrevChar) { CharKerning = GetCharKerning( *PrevChar, *Text ); } TotalWidth += TmpWidth + CharKerning; TotalHeight = FMath::Max( TotalHeight, TmpHeight ); PrevChar = Text++; } Width = FMath::CeilToInt( TotalWidth ); Height = FMath::CeilToInt( TotalHeight ); }
void CreateTheCaret( LPCLASSDATA lpcd ) { int cx, cy; /* * Make sure the character size is * present. */ GetCharSize( NULL, lpcd ); /* * Setup caret height. */ cy = Parser->szCharSize.cy; /* * When in insert mode we switch to the * block style caret. */ if ( lpcd->bOverwrite ) cx = Parser->szCharSize.cx; else { /* * Default width. */ cx = GetSystemMetrics( SM_CXBORDER ); /* * What type of caret? */ if ( Parser->nCaretType == CARET_WIDE ) cx *= 2; else if ( Parser->nCaretType == CARET_BLOCK ) cx = Parser->szCharSize.cx; else if ( Parser->nCaretType == CARET_HORIZONTAL ) { cx = Parser->szCharSize.cx; cy = GetSystemMetrics( SM_CYBORDER ) * 2; } } /* * Create and update the caret. */ CreateCaret( lpcd->hWnd, NULL, cx, cy ); UpdateCaret( lpcd ); }