Commit a1c8d4d0 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Добавлены функции для конвертирования строк из UTF32 в UTF16. Добавлено поле с...

Добавлены функции для конвертирования строк из UTF32 в UTF16. Добавлено поле с вертикальным смещением символа. В графическом рендерере исправлен баг с цветами в градиентах.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63536 954022d7-b5bf-4e40-9824-e11837661b57
parent a3a19a79
...@@ -180,6 +180,162 @@ namespace NSStringExt ...@@ -180,6 +180,162 @@ namespace NSStringExt
return sRet; return sRet;
} }
static std::wstring GetUnicodeFromUTF32(const unsigned int* pData, long lCount)
{
if (0 == lCount)
return L"";
if (4 == sizeof(wchar_t))
return std::wstring((wchar_t*)pData, lCount);
wchar_t* pUnicode = new wchar_t[2 * lCount + 1];
if (!pUnicode)
return L"";
wchar_t* pCur = pUnicode;
memset(pUnicode, 0x00, sizeof(wchar_t) * (2 * lCount + 1));
for (long lIndex = 0; lIndex < lCount; lIndex++)
{
unsigned int unUnicode = pData[lIndex];
if (unUnicode < 0x10000)
{
*pCur = unUnicode;
pCur++;
}
else
{
unUnicode = unUnicode - 0x10000;
*pCur = 0xD800 | (unUnicode >> 10);
pCur++;
*pCur = 0xDC00 | (unUnicode & 0x3FF);
pCur++;
}
}
if (0 == pCur - pUnicode)
return L"";
std::wstring sRet(pUnicode, pCur - pUnicode);
if (pUnicode)
delete[] pUnicode;
return sRet;
}
static unsigned int* GetUtf32FromUnicode(const std::wstring& wsUnicodeText, unsigned int& unLen)
{
if (wsUnicodeText.size() <= 0)
return NULL;
unsigned int* pUnicodes = new unsigned int[wsUnicodeText.size()];
if (!pUnicodes)
return NULL;
unsigned int* pOutput = pUnicodes;
unLen = 0;
if (2 == sizeof(wchar_t))
{
const wchar_t* wsEnd = wsUnicodeText.c_str() + wsUnicodeText.size();
wchar_t* wsInput = (wchar_t*)wsUnicodeText.c_str();
wchar_t wLeading, wTrailing;
unsigned int unCode;
while (wsInput < wsEnd)
{
wLeading = *wsInput++;
if (wLeading < 0xD800 || wLeading > 0xDFFF)
{
pUnicodes[unLen++] = (unsigned int)wLeading;
}
else if (wLeading >= 0xDC00)
{
//
continue;
}
else
{
unCode = (wLeading & 0x3FF) << 10;
wTrailing = *wsInput++;
if (wTrailing < 0xDC00 || wTrailing > 0xDFFF)
{
//
continue;
}
else
{
pUnicodes[unLen++] = (unCode | (wTrailing & 0x3FF) + 0x10000);
}
}
}
}
else
{
unLen = wsUnicodeText.size();
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
pUnicodes[unIndex] = (unsigned int)wsUnicodeText.at(unIndex);
}
}
return pUnicodes;
}
static unsigned short* GetUtf16FromUnicode(const std::wstring& wsUnicodeText, unsigned int& unLen)
{
unsigned int unTextLen = wsUnicodeText.size();
if (unTextLen <= 0)
return NULL;
unsigned short* pUtf16 = NULL;
unLen = 0;
if (2 == sizeof(wchar_t))
{
pUtf16 = new unsigned short[unTextLen];
if (!pUtf16)
return NULL;
unLen = unTextLen;
for (unsigned int unIndex = 0; unIndex < unLen; unIndex++)
{
pUtf16[unIndex] = (unsigned short)wsUnicodeText.at(unIndex);
}
}
else
{
pUtf16 = new unsigned short[2 * unTextLen + 1];
if (!pUtf16)
return NULL;
unsigned short* pCur = pUtf16;
memset(pUtf16, 0x00, sizeof(unsigned short) * (2 * unTextLen + 1));
for (long lIndex = 0; lIndex < unTextLen; lIndex++)
{
unsigned int unUnicode = wsUnicodeText.at(lIndex);
if (unUnicode < 0x10000)
{
*pCur = unUnicode;
pCur++;
}
else
{
unUnicode = unUnicode - 0x10000;
*pCur = 0xD800 | (unUnicode >> 10);
pCur++;
*pCur = 0xDC00 | (unUnicode & 0x3FF);
pCur++;
}
}
unLen = (unsigned int)(pCur - pUtf16);
if (!unLen)
{
delete[] pUtf16;
return NULL;
}
}
return pUtf16;
}
}; };
static std::vector<std::wstring>& Split(const std::wstring& wsString, wchar_t nDelim, std::vector<std::wstring> &arrElements) static std::vector<std::wstring>& Split(const std::wstring& wsString, wchar_t nDelim, std::vector<std::wstring> &arrElements)
...@@ -221,10 +377,12 @@ namespace NSStringExt ...@@ -221,10 +377,12 @@ namespace NSStringExt
return arrElements; return arrElements;
} }
static std::vector<std::wstring> Split(const std::wstring& wsString, const std::wstring& wsDelim) static std::vector<std::wstring> Split(const std::wstring& wsString, const std::wstring& wsDelim, bool bWholeString = true)
{ {
std::vector<std::wstring> arrElements; std::vector<std::wstring> arrElements;
if (bWholeString)
{
int nDelimLen = wsDelim.length(); int nDelimLen = wsDelim.length();
if (0 == nDelimLen) if (0 == nDelimLen)
arrElements.push_back(wsString); arrElements.push_back(wsString);
...@@ -232,6 +390,26 @@ namespace NSStringExt ...@@ -232,6 +390,26 @@ namespace NSStringExt
Split(wsString, wchar_t(wsDelim[0]), arrElements); Split(wsString, wchar_t(wsDelim[0]), arrElements);
else else
Split(wsString, wsDelim, arrElements); Split(wsString, wsDelim, arrElements);
}
else
{
std::vector<std::wstring> arrCurrent;
arrCurrent.push_back(wsString);
arrElements.push_back(wsString);
int nPos = 0;
int nLen = wsDelim.length();
while (nPos < nLen)
{
wchar_t wChar = wsDelim.at(nPos++);
arrElements.clear();
for (int nIndex = 0, nCount = arrCurrent.size(); nIndex < nCount; nIndex++)
{
std::vector<std::wstring>& arrTemp = Split(arrCurrent.at(nIndex), wChar);
arrElements.insert(arrElements.end(), arrTemp.begin(), arrTemp.end());
}
arrCurrent = arrElements;
}
}
return arrElements; return arrElements;
} }
......
...@@ -645,6 +645,7 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode) ...@@ -645,6 +645,7 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode)
oSizes.ushGID = -1; oSizes.ushGID = -1;
oSizes.eState = glyphstateMiss; oSizes.eState = glyphstateMiss;
oSizes.fAdvanceX = (pFace->size->metrics.max_advance >> 6) / 2.0f; oSizes.fAdvanceX = (pFace->size->metrics.max_advance >> 6) / 2.0f;
oSizes.fAdvanceY = oSizes.fAdvanceX;
return oSizes; return oSizes;
} }
...@@ -688,6 +689,7 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode) ...@@ -688,6 +689,7 @@ TFontCacheSizes CFontFile::GetChar(LONG lUnicode)
FT_Done_Glyph( pGlyph ); FT_Done_Glyph( pGlyph );
oSizes.fAdvanceX = (float)(pFace->glyph->linearHoriAdvance * m_dUnitsKoef / pFace->units_per_EM); oSizes.fAdvanceX = (float)(pFace->glyph->linearHoriAdvance * m_dUnitsKoef / pFace->units_per_EM);
oSizes.fAdvanceY = (float)(pFace->glyph->linearVertAdvance * m_dUnitsKoef / pFace->units_per_EM);
oSizes.oBBox.fMinX = (float)(oBBox.xMin >> 6); oSizes.oBBox.fMinX = (float)(oBBox.xMin >> 6);
oSizes.oBBox.fMaxX = (float)(oBBox.xMax >> 6); oSizes.oBBox.fMaxX = (float)(oBBox.xMax >> 6);
oSizes.oBBox.fMinY = (float)(oBBox.yMin >> 6); oSizes.oBBox.fMinY = (float)(oBBox.yMin >> 6);
......
...@@ -31,6 +31,7 @@ public: ...@@ -31,6 +31,7 @@ public:
USHORT ushGID; USHORT ushGID;
float fAdvanceX; float fAdvanceX;
float fAdvanceY;
TBBox oBBox; TBBox oBBox;
TMetrics oMetrics; TMetrics oMetrics;
......
...@@ -50,10 +50,10 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush) ...@@ -50,10 +50,10 @@ Aggplus::CBrush* CGraphicsRenderer::CreateBrush(NSStructures::CBrush* pBrush)
for( int i = 0; i < nCountSubColors; i++ ) for( int i = 0; i < nCountSubColors; i++ )
{ {
DWORD dwColor = (DWORD)pBrush->m_arrSubColors[i].color; DWORD dwColor = (DWORD)pBrush->m_arrSubColors[i].color;
BYTE r = (dwColor >> 24) & 0xFF; BYTE a = (dwColor >> 24) & 0xFF;
BYTE g = (dwColor >> 16) & 0xFF; BYTE b = (dwColor >> 16) & 0xFF;
BYTE b = (dwColor >> 8) & 0xFF; BYTE g = (dwColor >> 8) & 0xFF;
BYTE a = (dwColor) & 0xFF; BYTE r = (dwColor) & 0xFF;
if (bIsSwappedRGB) if (bIsSwappedRGB)
{ {
......
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