How do I set a font/fontfamily to Unicode?

How do I set a font/fontfamily to Unicode?

Forum member · Jan 30, 2007
I want to use Unicode on my page and I don’t find how to do that. “Latin 1 encoding is used by default” The example “how to change encoding” in the help library looks like this: Font centralEuropeHelveticaFont = new Helvetica( Encoder.CentralEurope ); // Use the font in a text area Page Element page.Elements.Add( new TextArea( "Text using the Central Europe encoder", 0, 0, 200, 12, centralEuropeHelveticaFont, 12 ) ); But I don’t understand how I set a fontfamily to Unicode. “My” code looks like this: // Create four TrueType fonts. TrueTypeFont verdana = new TrueTypeFont( "Verdana.ttf" ); TrueTypeFont verdanaBold = new TrueTypeFont( "Verdanab.ttf" ); TrueTypeFont verdanaItalic = new TrueTypeFont( "Verdanai.ttf" ); TrueTypeFont verdanaBoldItalic = new TrueTypeFont( "Verdanaz.ttf" ); // Create a font family for Verdana. FontFamily verdanaFontFamily = new FontFamily( "Verdana", verdana, verdanaBold, verdanaItalic, verdanaBoldItalic ); Label label = new Label(text, 0, 0, 504, 100, verdana, 18, TextAlign.Center); page.Elements.Add(label); FormattedTextAreaStyle ftStyle = new FormattedTextAreaStyle(verdanaFontFamily, 14, false); FormattedTextArea txtArea = new FormattedTextArea(txt, 0, 300, 300, 200, ftStyle); page.Elements.Add(txtArea); document.Pages.Add(page); /Magnus

Re: How do I set a font/fontfamily to Unicode?

Support · Jan 30, 2007
Hello Magnus, You can use Unicode characters in the PDF by using our product without any problem. You can do this in two ways. One is by using a TrueType font which has support for the unicode characters you are using. You can use this font in the FontFamily constructor and then you can use this in the FormattedTextArea which takes the unicode values. Following is the sample code which shows this. TrueTypeFont verdana = new TrueTypeFont( "verdana.ttf" ); FontFamily family = new FontFamily("Verdana",verdana); FormattedTextAreaStyle style = new FormattedTextAreaStyle( family, 12, false ); FormattedTextArea txtArea = new FormattedTextArea("Unicode text", 0, 300, 300, 200, style); Another by converting the Unicode data into string using any other API or library. You can use inbuilt classes from .NET which can convert unicode values to text and then you can use this text in our product. Following is the sample code to convert unicode values into string using .NET. string myText = System.Text.Encoding.UTF8.GetString( myUTF8Data ); Thanks, ceTe Software Support Team.