![]()  | 
 
Question about rendering Text? | 
 
    Post Reply  
   | 
  
| Author | |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: Question about rendering Text?Posted: 29 June 2007 at 9:09pm  | 
 
| 
   
    
   Hello,,, 
 
   
  I have a question about how rendering text using codejock... 
I search in the help but I didn't find anything, so if anybody know how I can use codejock to render Text please tell me how. 
Note: I don't ask for general function that render text like TextOut|DrawText ... (I only ask for rendering text using codejock). 
thank's for help. 
    | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 30 June 2007 at 4:09am | 
 
| 
   
    Hi, 
We don't have any special function for rendering text. What problem with CDC::DrawText  ? 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 30 June 2007 at 2:47pm | 
 
| 
   
    
   There is no problem, but I just wondered if there is special function in codejock.
 
   
  thank's for replay 
    | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 02 July 2007 at 2:20am | 
 
| 
   
    I have a question about calculate the height of Text? First I select a font object created previously  
*/pdc->SelectObject( mFont ); 
then I used one of these function 
1/pdc->GetTextMetrics(&TEXTMETRIC); 
   then I use TEXTMETRIC.tmHeight 
2/CSIZE = pdc->GetTextExtent( CString ); 
   then I use CSIZE.cy 
3/pdc->DrawText( CString, CRect, DT_CALCRECT ); 
but no one of them can return the right value of height. 
Well, I wonder if you can help me.... 
    | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 02 July 2007 at 5:01am | 
 
| 
   
    
   pdc->DrawText( CString, CRect, DT_CALCRECT ); have to return right value - check that rcHeight is 0 before you run it:
CRect rc(0, 0, nWidth, 0);
    
   
   | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 02 July 2007 at 5:45am | 
 
| 
   
    First I like to thanks oleg for his great help.  
![]() Look I don't know where I am wrong, this is my code: 
VOID CCustomCaptionBar::DrawItem(LPDRAWITEMSTRUCT lpDrawIS) { CDC *pdc = CDC::FromHandle(lpDrawIS->hDC);  CRect rcClient; this->GetClientRect( &rcClient ); XTPDrawHelpers()->GradientFill( pdc, rcGradient, this->m_clrGradientTop, this->m_clrGradientBottom, FALSE);  pdc->FillSolidRect( rcSolid, this->m_clrBack );  UINT nFormat = DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS;//|DT_RIGHT;//*|DT_RTLREADING*/|DT_NOCLIP;//DT_INTERNAL  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 02 July 2007 at 8:46am | 
 
| 
   
    in line this->m_rcTitle.SetRect(0,0,0,0); pdc->DrawText( this->m_strTitle, this->m_rcTitle, DT_SINGLELINE|DT_CALCRECT );  | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 02 July 2007 at 5:01pm | 
 
| 
   
    Hi, It's the same; I have always extra large height then the text it self, look at this screenshoot: 
 if there any chance that the problem is with the font type I used. (I  use font from adobe common files, it is "WinSoft Serif Pro"  with extension ".otf" (open type font)). 
this is the font files: uploads/20070702_165857_Fonts.rar In other hand this my class implementation 
 BEGIN_MESSAGE_MAP(CCustomCaptionBar, CCustomCaptionBarBase) 
  this->m_cbGradientWidth  = 30;  this->m_nXMargeTitle = 10; m_strTitle = _T("قسم السنة الأولى أ");  //this->m_fntTitle.CreatePointFont( 180, _T("WinSoft Serif Pro") );  lf.lfHeight = -MulDiv( 18, theApp.m_pSAMResource->m_LogPixelsY, 72 ); 
 CCustomCaptionBar::~CCustomCaptionBar() 
  CRect rcClient; this->GetClientRect( &rcClient );  XTPDrawHelpers()->GradientFill( pdc, rcGradient, this->m_clrGradientTop, this->m_clrGradientBottom, FALSE);   pdc->SetBkMode( TRANSPARENT );  this->m_rcTitle.SetRect(0,0,rcClient.Width(),0);  CRect rcrc(this->m_rcTitle); rcrc.top = rcrc.bottom; rcrc.bottom ++; Note: I used arabic characters, and drawing from right to left; the application initialized first with (CWinApp)this->SetDefaultLayout( LAYOUT_RTL );  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 03 July 2007 at 1:54am | 
 
| 
   
    
   Hello,
 
   
  Code now looks good :( Problem can be indeed because of fonts. if you use predefined height of font you can use predefined height of this text line too.... 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 03 July 2007 at 6:05am | 
 
| 
   
    
   I see, 
 
   
  thank you..  
    | 
 |
![]()  | 
 |
   
   shobits1  
   
   Newbie  
   Joined: 18 June 2007 Location: Algeria Status: Offline Points: 16  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 04 July 2007 at 1:48pm | 
 
| 
   
    hi oleg, I finally figure it out and find some sort of solution.... I agree with you maybe the problem is in the font, but this is the solution I have found: if I want to create Normal font with weight = FW_NORMAL then I must use: to calculate the rect; to draw  
 to calculate the rect; to draw   | 
 |
![]()  | 
 |
   
   terrym  
   
   Senior Member  
   Joined: 13 April 2007 Status: Offline Points: 836  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 27 August 2007 at 6:01am | 
 
| 
   
    
   There is a better option to rewrite the DrawText function as this is a very limited function as it works in integers and loses accuracy, therefore not giving WYSIWYG
 
   
  We decided to write our own version which uses it's own kerning and works using floating point accuracy giving true WYSIWYG 
 | 
 |
| 
   
     
     Thank you, 
   
  Terry Mancey email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey  | 
 |
![]()  | 
 |
    Post Reply  
   | 
  |
|       
  
  Tweet   	
    | 
 
| Forum Jump | Forum Permissions  ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum  |