Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ExtTextOut and Font Mapping

566 views
Skip to first unread message

satol

unread,
Jan 5, 2006, 4:40:27 PM1/5/06
to
Hello,

I already posted that question in December but receive no answer. I
hope MS guys could give me a hint.

It turns out, that for the OpenType fonts the ExtTextOut method does
font substitution if some characters are not present in the currently
selected font.


For example, draw a mixture of English, Japanese, and Arabic text (in
one Unicode string) with ExtTextOut, using Arial. Japanese Glyphs are
not present in the Arial, but they are shown anyway.


We need to read font tables from physical font and we use GetFontData
for that. What is the way to get the data of font, which has been
substituted in the middle of the text?


Thank you,
Sergey

James Brown

unread,
Jan 5, 2006, 6:50:39 PM1/5/06
to
"satol" <sa...@yahoo.com> wrote in message
news:1136497227....@g49g2000cwa.googlegroups.com...

Sergey,

Under Windows 2000 and XP, ExtTextOut uses the Uniscribe API internally
if necessary to display complex scripts such as Arabic. Once Uniscribe has
broken up the string into the appropriate scripts, it then calls back to
ExtTextOut
and displays the string as a series of glyphs (using ExtTextOut's
ETO_GLYPH_INDEX setting).

It will be Uniscribe which is doing the font substitution, using the
ScriptGetCMap
and ScriptShape APIs. You may want to look at Uniscribe if you want to
perform more complex analysis of a string prior to displaying it.

James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials

satol

unread,
Jan 5, 2006, 11:11:20 PM1/5/06
to
James,

Thank you for answer. I do not see how the font substitution can be
done with the functions you mentioned. At least MSDN say nothing.
However, I found that ScriptStringAnalyse accepts SSA_FALLBACK flag,
which enables use of fallback fonts. However, result string is
different from that of the ExtTextOut (it seems different fonts are
used). I use the following code for comparison:


LOGFONT lf;
memset(&lf, 0, sizeof(lf));
lf.lfHeight = -15;
wcscpy(lf.lfFaceName, L"Arial");
HFONT hf = CreateFontIndirect(&lf);

HFONT oldf = (HFONT)pDC->SelectObject(hf);

WCHAR teststr[] = L"『アカサこれは日本語のテ Half width
text キ』ス ان كتبت له الحياة، لن يكون
トです。読めますかこ Full width text れは日本語のテキ』ストです。読めますか";
//I have no idea what it says

pDC->ExtTextOut(0, 0, 0, NULL, teststr, wcslen(teststr), NULL);

SCRIPT_STRING_ANALYSIS ssa;

HRESULT hr = ScriptStringAnalyse(
pDC->GetSafeHdc(),
teststr,
wcslen(teststr),
0,
-1,
SSA_GLYPHS | SSA_FALLBACK, //DWORD dwFlags,
2000,
NULL,
NULL,
NULL, //piDx, //const int *piDx,
NULL, //SCRIPT_TABDEF *pTabdef,
NULL, //const BYTE *pbInClass,
&ssa
);

hr = ScriptStringOut(ssa, 0, 40, 0, NULL, 1, 0, FALSE);

ScriptStringFree(&ssa);

pDC->SelectObject(oldf);

0 new messages