Commit 3a5745cc authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

add ascii_to_unicode unicode_to_ascii

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@59114 954022d7-b5bf-4e40-9824-e11837661b57
parent 4115975f
......@@ -703,8 +703,8 @@ public:
TWmfFont *pFont = pText->pDC->pFont;
long lStyle = ( pFont->ushWeight > 550 ? 1 : 0 ) + ( pFont->unItalic ? 2 : 0 );
#ifdef DESKTOP_EDITOR_GRAPHICS
m_pWmfFile->m_pFontManager->LoadFontByName( UTF8_TO_U(pText->pDC->pFont->sFaceName), dSize, lStyle, 72, 72 );
m_pWmfFile->m_pFontManager->LoadString2( UTF8_TO_U(pText->sText), 0, 0 );
m_pWmfFile->m_pFontManager->LoadFontByName( ascii_to_unicode(pText->pDC->pFont->sFaceName), dSize, lStyle, 72, 72 );
m_pWmfFile->m_pFontManager->LoadString2( ascii_to_unicode(pText->sText), 0, 0 );
TBBox oBox = m_pWmfFile->m_pFontManager->MeasureString2();
fL = oBox.fMinX;
fT = oBox.fMinY;
......@@ -1632,7 +1632,7 @@ private:
{
TWmfFont *pFont = pDC->pFont;
#ifdef DESKTOP_EDITOR_GRAPHICS
m_pRenderer->put_FontName(UTF8_TO_U(pFont->sFaceName));
m_pRenderer->put_FontName(ascii_to_unicode(pFont->sFaceName));
#else
CString strName(pFont->sFaceName);
BSTR bsName = strName.AllocSysString();
......
......@@ -3495,8 +3495,8 @@ private:
float fTempX, fTempY, fTempW, fTempH;
#ifdef DESKTOP_EDITOR_GRAPHICS
m_pFontManager->LoadFontByName( UTF8_TO_U(pPlayer->pDC->pFont->sFaceName), (float)(oDrawText.dFontHeight * 72 / 25.4), lStyle, 72.0f, 72.0f );
m_pFontManager->LoadString2( UTF8_TO_U(oDrawText.sText), 0, 0 );
m_pFontManager->LoadFontByName( ascii_to_unicode(pPlayer->pDC->pFont->sFaceName), (float)(oDrawText.dFontHeight * 72 / 25.4), lStyle, 72.0f, 72.0f );
m_pFontManager->LoadString2( ascii_to_unicode(oDrawText.sText), 0, 0 );
TBBox oBox = m_pFontManager->MeasureString2();
fTempX = oBox.fMinX;
......@@ -4011,7 +4011,7 @@ private:
{
// Проверим есть ли такой шрифт в системе, если запишем имя ближайшайшего шрифта
#ifdef DESKTOP_EDITOR_GRAPHICS
std::wstring bsFontName = UTF8_TO_U( pFont->sFaceName );
std::wstring bsFontName = ascii_to_unicode( pFont->sFaceName );
#else
BSTR bsFontName = CString( pFont->sFaceName ).AllocSysString();
#endif
......@@ -4061,7 +4061,7 @@ private:
if ( NULL != pFontInfo && S_OK == m_pFontManager->LoadFontByName( pFontInfo->m_wsFontName, 11, lStyle, 96, 96 ) )
{
free( pFont->sFaceName );
std::string sNewName = U_TO_UTF8( pFontInfo->m_wsFontName.c_str());
std::string sNewName = unicode_to_ascii( pFontInfo->m_wsFontName.c_str());
int nLen = sNewName.length();
pFont->sFaceName = (char*)m_oMemoryManager.Malloc( nLen + 1, _T("Meta_FontCreate function") );
if ( !pFont->sFaceName )
......
......@@ -15,6 +15,28 @@
#include "../../../../../DesktopEditor/common/File.h"
#define UTF8_TO_U(val) NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)val, strlen(val))
#define U_TO_UTF8(val) NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(val, wcslen(val))
static std::wstring ascii_to_unicode(const char *src)
{
size_t nSize = mbstowcs(0, src, 0);
wchar_t* pBuffer = new wchar_t[nSize];
nSize = mbstowcs(pBuffer, src, nSize);
std::wstring sRes;
if (nSize != (size_t)-1)
sRes = std::wstring(pBuffer, nSize);
delete[] pBuffer;
return sRes;
}
static std::string unicode_to_ascii(const wchar_t *src)
{
size_t nSize = wcstombs(0, src, 0);
char* pBuffer = new char[nSize];
nSize = wcstombs(pBuffer, src, nSize);
std::string sRes;
if (nSize != (size_t)-1)
sRes = std::string(pBuffer, nSize);
delete[] pBuffer;
return sRes;
}
#if !defined(WIN32) && !defined(_WIN32_WCE)
//from MinGw wingdi.h
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment