Hi guys, long time no talk!
Using wxPdfDocument (Win32 static Unicode build), i'm trying to output some french accentuated text using the font Arial Narrow (an MS font installed with Office), only to see funny garbage in lieu of the text I'm expecting.
For example, if I do:
wxString text ( wxT("Bureau du président; Bureaux; Réunion du conseil d’administration") );
pdf.SetFont(wxT("ArialNarrow"),wxT(""), 7);
pdf.MultiCell ( 70, 2, text, 0, wxPDF_ALIGN_LEFT );
The program outputs some strange random characters (a mixture of «, ', " and squares).
This thread (http://forums.wxwidgets.org/viewtopic.p ... tf#p149552) seems promising, but everything I tried from it led to nowhere.
In a word, help!
Thanks,
Paul de Repentigny
wxPdfDocument accentuated chars and ArialNarrow
Re: wxPdfDocument accentuated chars and ArialNarrow
OK, I found that the application I was working on was loading and external font file from a local folder, and that font definition file did not support more than the standard ASCII set.
Which brings me to another question I'll post as a new thread (finding installed fonts).
Anyway, thanks!
PdR
Which brings me to another question I'll post as a new thread (finding installed fonts).
Anyway, thanks!
PdR
Re: wxPdfDocument accentuated chars and ArialNarrow
As you mentioned in your second post it is of course important that the used font really contains the glyphs for all characters you want to write to the resulting PDF file. However, it is also important to take the encoding of the source code files into account, if you specify strings with non-ASCII characters within the source code. Quite often source code is encoded in Windows codepage cp1252. That is, you have to convert the string accordingly before using it within your application for writing it to PDF. Even if you use an editor for your source code which encodes your files in UTF-8, you need to convert the string before using it. The wxString class of wxWidgets offers a method FromUTF8 to do this. For other encodings you need to use a wxString constructor with conversion by passing an appropirate wxMBConv instance.pderep wrote:Using wxPdfDocument (Win32 static Unicode build), i'm trying to output some french accentuated text using the font Arial Narrow (an MS font installed with Office), only to see funny garbage in lieu of the text I'm expecting.
For example, if I do:
wxString text ( wxT("Bureau du président; Bureaux; Réunion du conseil d’administration") );
pdf.SetFont(wxT("ArialNarrow"),wxT(""), 7);
pdf.MultiCell ( 70, 2, text, 0, wxPDF_ALIGN_LEFT );
The program outputs some strange random characters (a mixture of «, ', " and squares).
Regards,
Ulrich
Re: wxPdfDocument accentuated chars and ArialNarrow
Just for this purpose the class wxPdfFontManager offers the method RegisterSystemFonts. This method registers all installed fonts. Be aware that registering all installed fonts may take a while if there are many installed fonts. However, at startup of an application it's usually acceptable to let the user wait for a short period of time while the application is initialized.pderep wrote:OK, I found that the application I was working on was loading and external font file from a local folder, and that font definition file did not support more than the standard ASCII set.
Which brings me to another question I'll post as a new thread (finding installed fonts).
Regards,
Ulrich