Ticket Q491606
Visible to All Users

Chinese fonts or other CJK fonts in the richeditcontrol

created 12 years ago

Hi,thereI am using RichEditControl in my Silverlight project.I want custom fonts in the RichEditControl.Now the RichEditControl can display the correct Chinese fonts format(STXingkai.tff that i added) after i read this page (http://www.devexpress.com/Support/Center/e/E3393.aspx)

However,the Chinese fonts format STXingkai missing or changed to default fonts format like Simsun when i export it to a .docx files and open it with MS WORD 2010.I thought these Chinese fonts format were missing.To my surprise,these Chinese fonts format come back again when i import this .docx to my RichEditContol and display normally.
How let these Chinese fonts display normally in the .docx ?Someone help me?

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi,
It looks like you simply forgot to install the "STXingkai" font to the C:\WINDOWS\Fonts folder. Thus, MS Word uses the default Windows font substitution mechanism to select the most appropriate font to display a document.
Thanks,
Alessandro.

    Show previous comments (7)

      en,Maybe I solved this problem,and really thanks for your help.
      Solve:: I got the WordMLText before I export the file.Then I replaced all "STXingkai" characters to “华文行楷”. My Word could understand it.
      This is the program:
      //At the beginning of the progam in richeditcontrol,I registered the “STXingkai”
                  DevExpress.Utils.Internal.FontManager.RegisterFontFamily("STXingkai",
                  Assembly.GetExecutingAssembly().GetManifestResourceStream("slTest2.Fonts.STXINGKA.TTF"));
      //Then I referd the page of "Custom Save Document " and overrided the function of ExecuteCore();
          public class CustomSaveDocumentAsCommand : SaveDocumentAsCommand
          {
              public CustomSaveDocumentAsCommand(IRichEditControl control)
                  : base(control) { }
              protected override void ExecuteCore()
              {
                  string yy = ((RichEditControl)this.Control).Document.WordMLText.ToString();
                  Regex re = new Regex(@"STXingkai");
                  string tt=re.Replace(yy, "华文行楷");
                  ((RichEditControl)this.Control).Document.WordMLText=tt;
                  base.ExecuteCore();
              }
          }
      //At last,Once I open the exported file,the fonts display well.
      //Thank you very much,谢谢哈

        Sorry.I think you need ignore my the lastest comment.The problem still exists.
        I 'm sure that the Build Action setting is available for the files.
        ”生成方式“means "Build Action"
        "嵌入的资源"means “Embedded Resources”

        Alessandro (DevExpress Support) 12 years ago

          Thank you for you clarification. I think that the technique you illustrated in your previous comment might be a solution. However, instead of replacing the font in the raw WordML string, please try to apply the "华文行楷" font to the document range by using the approach from the How to: Change Formatting of Selected Text help section. Does this make any difference?

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.