none
Finding a font that can display all of the text we're inserting RRS feed

  • Question

  • Hi;

    We at times insert text into a DOCX file. What happens occasionally is the text inserted has characters that the font at that point has no glyphs for. When you do this in Word using paste, it changes to a font that handles all characters. And clearly has a set of rules for what font to use for what characters.

    Anyone know what the rules are for font switching? And is there a .NET or SDK call where I can feed it a font & string and find out if that font handles that string?

    thanks - dave


    Very funny video - What's your Metaphor?
    Friday, February 18, 2011 3:43 PM

Answers

  • I don't believe there is any easy way to do what Word does, but, essentially (and I don't know all the details), you must check fonts on the machine to see whether they support the Unicode Range a character falls into, and pick an appropriate one (the rules Microsoft use are kept secret). The Unicode Ranges are absolute and part of the Unicode standard - see http://www.unicode.org/Public/UNIDATA/Blocks.txt. The API to check a font is GetFontUnicodeRanges; there may be a higher level interface in .NET, I don't know.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by DavidThi808 Tuesday, February 22, 2011 4:13 PM
    Monday, February 21, 2011 12:02 PM

All replies

  • Hello Dave,

    Thanks for posting. If I understand this issue correctly, this issue happens in the following scenario.

    1. There is a docx file A with some paragraphs and the paragraph which the text is inserted into a special font Font1.
    2. The text to be inserted into this document A is from other docx file or also from the document A. And the text also has a special font Font2.
    3. When pasting the text in Font2 into the paragraph in Font1, the paragraph turns to be in Font2.

    For it, if I have mistaken any point, just feel free to follow up. I have tested this scenario in UI, and the text in Font2 does not affect the paragraph in Font1. Are you using Word automation for this issue? Would you mind sharing the related code here? So I could try to get a better understanding on this issue.

    We are looking forward to your reply. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, February 21, 2011 3:57 AM
  • I don't believe there is any easy way to do what Word does, but, essentially (and I don't know all the details), you must check fonts on the machine to see whether they support the Unicode Range a character falls into, and pick an appropriate one (the rules Microsoft use are kept secret). The Unicode Ranges are absolute and part of the Unicode standard - see http://www.unicode.org/Public/UNIDATA/Blocks.txt. The API to check a font is GetFontUnicodeRanges; there may be a higher level interface in .NET, I don't know.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by DavidThi808 Tuesday, February 22, 2011 4:13 PM
    Monday, February 21, 2011 12:02 PM
  • Hi Bessie;

    A little different from what you said. If I have a line of text in Arial and I insert unicode text (ie no formatting) in the middle of it - and the text is Chinese, then Word will change the font for the Chinese characters so they display by using a font that has those glyphs.

    thanks - dave


    Very funny video - What's your Metaphor?
    Tuesday, February 22, 2011 4:14 PM
  • That's what I was afraid of - thanks - dave
    Very funny video - What's your Metaphor?
    Tuesday, February 22, 2011 4:15 PM