Displaying Chinese characters with TrueType technology

Source: Internet
Author: User

I know that there is a freetype library that can render a TrueType font to a dot-matrix character. Note, however, that the TrueType technology contains a number of Apple's technology patents (mainly to explain its hint code), and the current FreeType project leader has been notified by Apple that it is currently under negotiation to apply for Apple's patent license.

To avoid the patent problem, you have to hint, but this shows very poor results.

In fact, if only in Windows (whether Chinese or e), as long as the Chinese into a Unicode string (MultiByteToWideChar?), and then use the TEXTOUTW function output.

These functions are supported by either 95 or NT, as long as the corresponding fonts are installed. There is no need to explain TrueType yourself.

Grey Coat Monk: Is it? The patent issue has the company to consider!

The problem is converting to Unicode output in English I didn't succeed!

Used to be a master: How can you use CP_OEMCP?

Of course we have to fill in 936.

To use TEXTOUTW () explicitly, you cannot use DC. TextOut (), because the program is still compiled in a non-Unicode fashion.

wchar_t wstr[500];

int N=multibytetowidechar (936, mb_precomposed,

STR,-1, WSTR, 500);

TEXTOUTW (PDC->M_HDC, x, Y, wstr);

The system must have 936 code pages installed. How does it fit? The Cp_936.nls (VC + +) copy to Windows\System, and then in the registry

\hkey_local_machine\system\currentcontrolset\control\nls\codepage, plus 936 = "Cp_936.nls"

\hkey_local_machine_system\currentcontrolset\control\nls\locale, plus 00000804 = "Chinese (PRC)"

Gray Coat Monk: that's great! It worked! When you return home, monk must buy you a drink!

Code:

BOOL bResult = m_Font.CreateFont(-16,0,0,0,400,0,0,0,134,3,2,1,50,"SimSun");
   char *pText = "Test汉字显示测试Test";
   wchar_t wBuffer[256];
   int nLength = MultiByteToWideChar(936, MB_PRECOMPOSED, pText, -1, wBuffer, 256);
   CDC *pDC = GetDC();
   CFont *pFontTemp = (CFont *)pDC->SelectObject(&m_Font);
   TextOutW(pDC->m_hDC, 80, 80, wBuffer, nLength - 1);
   pDC->SelectObject(pFontTemp);
   ReleaseDC(pDC);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.