ImageGear for .NET
FindUnrepresentableCharacters Method
See Also  Example Send Feedback
ImageGear21.Formats.Pdf Assembly > ImageGear.Formats.PDF Namespace > ImGearPDEFont Class : FindUnrepresentableCharacters Method




text
String with Unicode characters.

Glossary Item Box

Gets a collection of characters in the Unicode string that could not be represented in the font.

Syntax

 
Visual Basic
C#
Managed Extensions for C++
C++/CLI
 
 

Parameters

text
String with Unicode characters.

Return Value

Collection of characters not representable in the font.

Remarks

The Unicode API methods require a TrueType or Type 0 font that can be embedded. This font must be created from a font file on the local machine, because the lookup tables used by these API only exist in the font files. This is required even if you only check for representable text. This method will raise an exception, if used with other fonts, like Type 1 or font retrieved from an existing PDF document.

Example

C#Copy Code
string textToCheck =
    "Russian: Русский Текст. Greek: Κείμενο στην ελληνική γλώσσα. Japanese (unrepresentable): 日本";

// see the code example in ImGearPDEText.Add
ImGearPDEFont fontSerif = CreateFont("Times-Roman", "Type0", "Identity-H");

// Ensure that the text is fully representable by the font.
// Add a warning if not.
if (!fontSerif.IsTextRepresentable(textToCheck))
{
    System.Collections.Generic.IEnumerable<char> unrepresentableChars =
        fontSerif.FindUnrepresentableCharacters(textToCheck);

    string unrepresentableCharsString = String.Empty;
    foreach (char unrepresentableChar in unrepresentableChars)
    {
        if (unrepresentableCharsString != String.Empty)
        {
            unrepresentableCharsString += ",";
        }

        unrepresentableCharsString += unrepresentableChar;
    }

    MessageBox.Show(
        string.Format(
            "The selected font, {0}, does not support the following characters: [{1}]",
            fontSerif.GetAttributes().Name.String, unrepresentableCharsString));
}
Visual BasicCopy Code
Dim textToCheck As String = "Russian: Русский Текст. Greek: Κείμενο στην ελληνική γλώσσα. Japanese (unrepresentable): 日本"

' see the code example in ImGearPDEText.Add
Dim fontSerif As ImGearPDEFont = CreateFont("Times-Roman", "Type0", "Identity-H")

' Ensure that the text is fully representable by the font.
' Add a warning if not.
If Not fontSerif.IsTextRepresentable(textToCheck) Then
    Dim unrepresentableChars As System.Collections.Generic.IEnumerable(Of Char) = fontSerif.FindUnrepresentableCharacters(textToCheck)

    Dim unrepresentableCharsString As String = [String].Empty
    For Each unrepresentableChar As Char In unrepresentableChars
        If unrepresentableCharsString <> [String].Empty Then
            unrepresentableCharsString += ","
        End If

        unrepresentableCharsString += unrepresentableChar
    Next

    MessageBox.Show(String.Format("The selected font, {0}, does not support the following characters: [{1}]", fontSerif.GetAttributes().Name.[String], unrepresentableCharsString))

See Also

©2013. Accusoft Corporation. All Rights Reserved.