Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


GetFontUnicodeRanges trouble

Hi all, I'm new to the board and have quite a diffcult dilemna. In writing a small MFC app I want to print out all characters that a particular font can display. In my search I came across the function GetFontUnicodeRanges which is laid out like so:

The GetFontUnicodeRanges function returns information about which Unicode characters are supported by a font. The information is returned as a GLYPHSET structure.

DWORD GetFontUnicodeRanges(
HDC hdc, // handle to DC
LPGLYPHSET lpgs // glyph set
[in] Handle to the device context.
[out] Pointer to a GLYPHSET structure that receives the glyph set information. If this parameter is NULL, the function returns the size of the GLYPHSET structure required to store the information.
Return Values
If the function succeeds, it returns number of bytes written to the GLYPHSET structure or, if the lpgs parameter is NULL, it returns the size of the GLYPHSET structure required to store the information.

If the function fails, it returns zero.

I can get the function to work correctly but my problem is AFTER the call is made. Here is a sample of my code:

CClientDC dc(this);
CFont* pOld = dc.SelectObject(&m_fCurrentFont);
GetFontUnicodeRanges(dc.GetSafeHdc(), m_pGS);
return m_pGS->cGlyphsSupported;

m_fCurrentFont is a font that I have created and DOES exist on my system. The problem occurs when I try to select the previous font (pOld) back into the device context. any thoughts?


  • Shawn CarterShawn Carter Member Posts: 0

    _____ < /> free ebooks and video tutorials about | Objective-C, PL/SQL, Perl, C++, Swift, Visual Basic, Python, Go, Delphi, Assembly, PHP, MATLAB, Ruby, Scratch, R, C, Visual Basic .NET, JavaScript, Java, C# Prolog, Bash, VBScript, COBOL, D, Alice, Crystal, Fortran, LabVIEW, Apex, Logo, Lisp, Scala, Awk, Erlang, Lua, F#, Kotlin, Ada, Transact-SQL, FoxPro, ABAP, SAS, Hack, Dart, Julia, Rust, Scheme, ML, Clojure | ___

Sign In or Register to comment.