You are not logged in.
Hello,
I try to write some texts written in English, Japanese, Hebrew and Arabic inside a PDF file, using the VCLCanvas property of the TPdfDocument class, and the Window TextOut() function. For that I written a small function, called DrawTextTo(), that takes a TCanvas as parameter. I tried to draw my texts on the screen and inside the PDF document using the exactly same function for the both.
I noticed that the texts inside the generated PDF file contained errors regarding to the non Latin texts. I also tried to enable the UseUniscribe property, but the two ways result in errors:
- Enabling the UseUniscribe property, all my non Latin texts are broken (i.e. the Japanese font size is incorrect, the Hebrew is partially drawn and some chars are randomly drawn, and the Arabic only shows square)
- Disabling the UseUniscribe property, the chars, sometimes the whole sentence, are crossed for Arabic and Hebrew texts
Of course I tried to change the used font family, especially to a configuration that writes the text correctly using the TPdfCanvas functions.
So, what I do wrong here?
Here are the texts I use:
std::wstring WAppSettings::m_EnglishText = L"Any text... What happen?";
std::wstring WAppSettings::m_JapaneseText = L"任意のテキストには、何が起こりますか?";
std::wstring WAppSettings::m_HebrewText = L"כל טקסט, מה קורה?";
std::wstring WAppSettings::m_ArabicText = L"أي نص، ماذا يحدث؟";
Here is the code used to draw text (pCanvas can either be a pointer to a screen canvas or to the VCLCanvas provided in TPdfDocument):
DWORD drawFlags = DT_WORDBREAK | DT_NOPREFIX | DT_VCENTER;
if (rtlLayout)
drawFlags |= DT_RTLREADING;
if (doCenter)
drawFlags |= DT_CENTER;
if (singleLine)
drawFlags |= DT_SINGLELINE;
// configure text brush
pCanvas->Brush->Color = textColor; // a TColor value e.g. clRed, clBlue, ...
pCanvas->Brush->Style = bsClear;
// draw text
::DrawTextW(pCanvas->Handle, text.c_str(), text.length(), &rect, drawFlags);
Regards
Offline