Note that there are some explanatory texts on larger screens.

plurals
  1. POExtTextOut fails with very long strings unless lower font quality specified
    primarykey
    data
    text
    <p>Sometimes our application needs to draw very long strings (e.g. 6,000 chars) using ExtTextOut. Sometimes ExtTextOut fails and returns zero and GetLastError returns zero as well.</p> <p>To re-create the situation create a simple MFC Single Document application and then set the OnDraw to be:</p> <pre><code>void CTestExtTextView::OnDraw(CDC* pDC) { CTestExtTextDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; LOGFONT lfDetail = {0}; lfDetail.lfHeight = -(::MulDiv(100, pDC-&gt;GetDeviceCaps(LOGPIXELSY), 720)); lfDetail.lfCharSet = ANSI_CHARSET; lfDetail.lfOutPrecision = OUT_DEFAULT_PRECIS; lfDetail.lfQuality = CLEARTYPE_QUALITY; lfDetail.lfWeight = 400; _tcscpy_s(lfDetail.lfFaceName, LF_FACESIZE, _T("Arial")); CFont font; font.CreateFontIndirectW( &amp;lfDetail ); CFont * pold = pDC-&gt;SelectObject( &amp;font ); CString str = L"2 &lt;office:document-content xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\" xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\" xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\" xmlns:presentation=\"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\" xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\" xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\" xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\" xmlns:math=\"http://www.w3.org/1998/Math/MathML\" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\" xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\" xmlns:ooo=\"http://openoffice.org/2004/office\" xmlns:ooow=\"http://openoffice.org/2004/writer\" xmlns:oooc=\"http://openoffice.org/2004/calc\" xmlns:dom=\"http://www.w3.org/2001/xml-events\" xmlns:xforms=\"http://www.w3.org/2002/xforms\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" office:version=\"1.1\"&gt;&lt;office:scripts/&gt;&lt;office:font-face-decls&gt;&lt;style:font-face style:name=\"Arial\" svg:font-family=\"Arial\" style:font-family-generic=\"swiss\" style:font-pitch=\"variable\"/&gt;&lt;style:font-face style:name=\"Arial Unicode MS\" svg:font-family=\"&amp;apos;Arial Unicode MS&amp;apos;\" style:font-family-generic=\"system\" style:font-pitch=\"variable\"/&gt;&lt;style:font-face style:name=\"Tahoma\" svg:font-family=\"Tahoma\" style:font-family-generic=\"system\" style:font-pitch=\"variable\"/&gt;&lt;/office:font-face-decls&gt;&lt;office:automatic-styles&gt;&lt;style:style style:name=\"co1\" style:family=\"table-column\"&gt;&lt;style:table-column-properties fo:break-before=\"auto\" style:column-width=\"6.659cm\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"co2\" style:family=\"table-column\"&gt;&lt;style:table-column-properties fo:break-before=\"auto\" style:column-width=\"7.408cm\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"co3\" style:family=\"table-column\"&gt;&lt;style:table-column-properties fo:break-before=\"auto\" style:column-width=\"7.02cm\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"co4\" style:family=\"table-column\"&gt;&lt;style:table-column-properties fo:break-before=\"auto\" style:column-width=\"7.214cm\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"co5\" style:family=\"table-column\"&gt;&lt;style:table-column-properties fo:break-before=\"auto\" style:column-width=\"2.267cm\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"ro1\" style:family=\"table-row\"&gt;&lt;style:table-row-properties style:row-height=\"0.473cm\" fo:break-before=\"auto\" style:use-optimal-row-height=\"true\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"ro2\" style:family=\"table-row\"&gt;&lt;style:table-row-properties style:row-height=\"0.453cm\" fo:break-before=\"auto\" style:use-optimal-row-height=\"true\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"ta1\" style:family=\"table\" style:master-page-name=\"Default\"&gt;&lt;style:table-properties table:display=\"true\" style:writing-mode=\"lr-tb\"/&gt;&lt;/style:style&gt;&lt;style:style style:name=\"T1\" style:family=\"text\"&gt;&lt;style:text-properties style:text-position=\"super 58%\"/&gt;&lt;/style:style&gt;&lt;/office:automatic-styles&gt;&lt;office:body&gt;&lt;office:spreadsheet&gt;&lt;table:table table:name=\"Sheet1\" table:style-name=\"ta1\" table:print=\"false\"&gt;&lt;office:forms form:automatic-focus=\"false\" form:apply-design-mode=\"false\"/&gt;&lt;table:table-column table:style-name=\"co1\" table:default-cell-style-name=\"Default\"/&gt;&lt;table:table-column table:style-name=\"co2\" table:default-cell-style-name=\"Default\"/&gt;&lt;table:table-column table:style-name=\"co3\" table:default-cell-style-name=\"Default\"/&gt;&lt;table:table-column table:style-name=\"co4\" table:default-cell-style-name=\"Default\"/&gt;&lt;table:table-row table:style-name=\"ro1\"&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Sample text for ExtTextOut&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Second Column Sample Text&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;3&lt;text:span text:style-name=\"T1\"&gt;rd&lt;/text:span&gt; Column&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;A More Lengthly bit of text just to make sure we increase the size of the line to something that might make ExtTextOut fail. It doesn&amp;apos;t actually fail if we switch to Anti-Aliased Fonts. Not sure why. It also doesn&amp;apos;t fail if we make the text shorter.&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;/table:table-row&gt;&lt;table:table-row table:style-name=\"ro1\"&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Sample text for ExtTextOut&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Second Column Sample Text&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;3&lt;text:span text:style-name=\"T1\"&gt;rd&lt;/text:span&gt; Column&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;A More Lengthly bit of text just to make sure we increase the size of the line to something that might make ExtTextOut fail. It doesn&amp;apos;t actually fail if we switch to Anti-Aliased Fonts. Not sure why. It also doesn&amp;apos;t fail if we make the text shorter.&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;/table:table-row&gt;&lt;table:table-row table:style-name=\"ro1\"&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Sample text for ExtTextOut&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;&lt;text:p&gt;Second Column Sample Text&lt;/text:p&gt;&lt;/table:table-cell&gt;&lt;table:table-cell office:value-type=\"string\"&gt;"; pDC-&gt;ExtTextOutW( 0,0, NULL, NULL, str, NULL ); pDC-&gt;ExtTextOutW( 0,50, NULL, NULL, CString(L"But this will print out"), NULL ); pDC-&gt;SelectObject( pold ); } </code></pre> <p>When you run the application you should see a single line 'But this will print out' half-way down the screen. If you set lfQuality = ANTIALIASED_QUALITY then it does actually print something out but just doesn't look right.</p> <p>I've tested this on Vista and XP.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload