We help IT Professionals succeed at work.

Rich Edit Control, two unicode fonts, same character present in both, but only one of them will display that character

Medium Priority
Last Modified: 2013-12-03

I'm having a curious problem with one unicode font.  I'm running XP, and VS7,

I have a tiny application with a single window with a Richtextbox.  I'm
compiling with unicode characters, and am running the following code to
check that I'm OK.  My code has two Greek characters, and two Syriac

If I use the palatino linotype font, the two Greek characters display OK, and I
get two square boxes for the Syriac.

If I use the TITUS Cyberbit Basic free font (which includes all
characters) then I get all four symbols displayed OK.

If I use the Estrangelo Edessa font (which is basically just Syriac,
and comes with XP) then the Syriac characters don't display (and only
one of the Greek; but that's fine).  Yet I can see the characters fine
in charmap, and if I copy and paste one into the running application,
it displays OK in the window.

Why would my code work for TITUS, but not Estrangelo Edessa?

I'm pretty new to the MFC, so I may be doing some howlers.  Here's the
code I'm running, and all comments are very welcome.

Roger Pearse

---- start -----
void CharnessView::OnFileRun()

        CRichEditCtrl& rCtrl = GetRichEditCtrl();

// Initializes a CFont object with the specified characteristics.
        CFont * font = new CFont;
   36,                        // nHeight
   0,                         // nWidth
   0,                         // nEscapement
   0,                         // nOrientation
   FW_NORMAL,                 // nWeight
   FALSE,                     // bItalic
   FALSE,                     // bUnderline
   0,                         // cStrikeOut
   ANSI_CHARSET,              // nCharSet
   OUT_DEFAULT_PRECIS,        // nOutPrecision
   CLIP_DEFAULT_PRECIS,       // nClipPrecision
   DEFAULT_QUALITY,           // nQuality
   DEFAULT_PITCH | FF_DONTCARE,  // nPitchAndFamily
   _T("estrangelo edessa")));                 // lpszFacename
//   _T("titus cyberbit basic")));                 // lpszFacename
//   _T("palatino linotype")));                 // lpszFacename

        // Cause the textbox to use the new font

        rCtrl.SetSel(-1,-1);  // end of line
        rCtrl.ReplaceSel( _T("some text\n") );

        //WriteRedTxt(_T("red text\n"));
        rCtrl.SetSel(-1,-1);  // end of line
        rCtrl.ReplaceSel(_T("\x03ac \x1ff6\n"));   // Greek text
        rCtrl.SetSel(-1,-1);  // end of line
        rCtrl.ReplaceSel(_T("\x0710 \x0717\n"));   // Syriac
        rCtrl.SetSel(-1,-1);  // end of line
        rCtrl.ReplaceSel(_T("more text\n"));

    // Done with the font.  Delete the font object.


Watch Question

Well, I don't see what the problem is directly, but you definately shouldn't be deleting teh font while it is still in use.  You font should be a member variable of the class and never deleted until the control is destroyed or you SetFont a different font.  Otherwise the control will be pointing to a bad font handle (this applies to all windows, not just CRichEditCtrl).

Specifically for CRichEditCtrl you should be using SetSelectionCharFormat ( http://msdn2.microsoft.com/en-US/library/kwc5txzf(VS.80).aspx ) instead of SetFont.

Hope this helps.
mahesh1402IT Professional
Top Expert 2005
You may refer this About display UNICODE characters in Edit Controls :

http://www.codeguru.com/cpp/cpp/cpp_mfc/general/article.php/c10285/ <==

refer CUnicodeDlg::SetControlsFont() function on above link to create and set UNICODE font


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
mahesh1402IT Professional
Top Expert 2005

as shown in above link you can create UNICODE font by using CreateFontIndirect() by passing LOGFONT type structure to it.

In LOGFONT strcuture there is lfCharSet parameter which allows you to set character set like GREEK_CHARSET etc.

Refer above article for more.




I tried using the sample code supplied, and the same problem happened.  I added a couple of Syriac characters onto the unicode.txt file (editing using Notepad, get the characters from charmap), and changed the font in the code to Titus Cyberbit Basic, and they displayed; changed it to Estrangelo Edessa and it did not.

So I can only infer that I am not doing anything wildly daft; but why does it not work, I wonder?


Did you try using Estrangelo Edessa in WordPad?  WordPad is basically just a CRichEditCtrl with a menu bar, so if it works in that you are doing something wrong, and if it doesn't work it is the font's problem.


Well, I can paste unicode characters from charmap in Estrangelo Edessa into Wordpad, and indeed into my application just fine.  It's purely when I try to write them to the Richtextbox in code.  That's why I felt that *I* was doing something wrong.  But the fact that the sample app. given by Mahesh has the same problem reading a file containing the characters suggests that it is not me.

This last suggested that something may be odd about the font.  Other Syriac fonts made by the same people (the 'Meltho' fonts for Syriac) are fine.

So I queried the SYRCOM forum for Syriac computing, and got an interesting response, although I don't know if it is relevant: "George Kiraz [the font author] explained to me that Edessa was the first font they made and when it shipped XP did not yet have Syriac capability fully so they labeled Edessa as an arabic font to make it work. The problem arises for me when I have a word document in Talada (which is the prettier font according to many anyway) which XP/Word    recognizes as Syriac and then if I change it to Edessa the boxes come up since Edessa is tagged as Arabic. The problem (at least within word) is solved by manually  changing the  language (tools>language) to either Syriac or Arabic so that it works."

I'm not sure that I entirely understand about fonts belonging to languages, tho.
I think what he means is that the font isn't tagged to contain the Syriac characters (even though it does) so anything that looks at those tags is automatically going to think the characters are blank.

If they paste into your RichEdit fine, then it is undoubtedly the way the text is being added.  Since other fonts work from code it must be the ReplaceSel function is doing some translation work "under the hood" to make sure characters are part of the font.  It appears pasting bypasses this.

Try using SetWindowText just to see if sticking teh characters in directly changes things.  You could also call EM_REPLACESEL directly: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_replacesel.asp
or EM_SETTEXTEX: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditmessages/em_settextex.asp


My PC melted last night, so it will be a few days before I can get another and get going again.  I will try these ideas!  Thanks, Roger.
mahesh1402IT Professional
Top Expert 2005

BTW  you tried to change font of your Dialog box ?



In the code?  I did.  I changed it from Lucida to first Titus (which worked) and then Estangelo (which did not).
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.