Commit 49337ff6 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov
parent e161de35
...@@ -72,6 +72,18 @@ namespace NSStringUtils ...@@ -72,6 +72,18 @@ namespace NSStringUtils
public: public:
inline void SetText(const std::wstring& bsText)
{
ClearNoAttack();
WriteString(bsText);
for (size_t i = 0; i < m_lSizeCur; ++i)
{
if (WCHAR(8233) == m_pData[i])
m_pData[i] = WCHAR(' ');
}
}
inline void WriteStringNoSafe(const wchar_t* pString, size_t nLen) inline void WriteStringNoSafe(const wchar_t* pString, size_t nLen)
{ {
memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t)); memcpy(m_pDataCur, pString, nLen * sizeof(wchar_t));
...@@ -119,9 +131,10 @@ namespace NSStringUtils ...@@ -119,9 +131,10 @@ namespace NSStringUtils
m_lSizeCur += 2; m_lSizeCur += 2;
} }
inline void WriteEncodeXmlString(const wchar_t* pString) inline void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1)
{ {
const wchar_t* pData = pString; const wchar_t* pData = pString;
int nCounter = 0;
while (*pData != 0) while (*pData != 0)
{ {
BYTE _code = CheckCode(*pData); BYTE _code = CheckCode(*pData);
...@@ -184,8 +197,13 @@ namespace NSStringUtils ...@@ -184,8 +197,13 @@ namespace NSStringUtils
} }
++pData; ++pData;
if (-1 != nCount)
{
++nCounter;
if (nCounter == nCount)
break;
}
} }
} }
inline size_t GetCurSize() inline size_t GetCurSize()
......
...@@ -403,6 +403,115 @@ std::string CFontFile::GetStyleName() ...@@ -403,6 +403,115 @@ std::string CFontFile::GetStyleName()
return s; return s;
} }
void CFontFile::GetPanose(BYTE* pData)
{
memset(pData, 0, 10);
if (!m_pFace)
return;
TT_OS2 *pTable = (TT_OS2 *)FT_Get_Sfnt_Table( m_pFace, ft_sfnt_os2 );
if ( NULL == pTable )
return;
memcpy( pData, pTable->panose, 10 );
}
bool CFontFile::IsFixedWidth()
{
if (!m_pFace)
return false;
return FT_IS_FIXED_WIDTH( m_pFace ) != 0;
}
int CFontFile::IsUnicodeRangeAvailable(unsigned long ulBit, unsigned int un4ByteIndex)
{
if (!m_pFace)
return -1;
TT_OS2 *pOs2 = (TT_OS2 *)FT_Get_Sfnt_Table( m_pFace, ft_sfnt_os2 );
if ( NULL == pOs2 || 0xFFFF == pOs2->version )
return -1;
int nResult = 0;
unsigned long ulMult = 1;
for ( unsigned long ulIndex = 0; ulIndex < ulBit; ulIndex++ )
ulMult <<= 1;
switch(un4ByteIndex)
{
case 0: if ( pOs2->ulUnicodeRange1 & ulMult ) nResult = 1; break;
case 1: if ( pOs2->ulUnicodeRange2 & ulMult ) nResult = 1; break;
case 2: if ( pOs2->ulUnicodeRange3 & ulMult ) nResult = 1; break;
case 3: if ( pOs2->ulUnicodeRange4 & ulMult ) nResult = 1; break;
case 4: if ( pOs2->ulCodePageRange1 & ulMult ) nResult = 1; break;
case 5: if ( pOs2->ulCodePageRange2 & ulMult ) nResult = 1; break;
}
// Специальная ветка для случаев, когда charset может быть задан не через значения
// ulCodePageRange, а непосредственно через тип Cmap.
// Charset Name Charset Value(hex) Codepage number Platform_ID Encoding_ID Description
// -------------------------------------------------------------------------------------------------
//
// SYMBOL_CHARSET 2 (x02) 3 0 Symbol
// SHIFTJIS_CHARSET 128 (x80) 932 3 2 ShiftJIS
// GB2313_CHARSET 134 (x86) 936 3 3 PRC
// CHINESEBIG5_CHARSET 136 (x88) 950 3 4 Big5
// HANGEUL_CHARSET 129 (x81) 949 3 5 Wansung
// JOHAB_CHARSET 130 (x82) 1361 3 6 Johab
if ( 4 == un4ByteIndex && 0 == nResult )
{
for( int nIndex = 0; nIndex < m_pFace->num_charmaps; nIndex++ )
{
// Symbol
if ( 31 == ulBit && 0 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
// ShiftJIS
if ( 17 == ulBit && 2 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
// PRC
if ( 18 == ulBit && 3 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
// Big5
if ( 20 == ulBit && 4 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
// Wansung
if ( 19 == ulBit && 5 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
// Johab
if ( 21 == ulBit && 6 == m_pFace->charmaps[nIndex]->encoding_id && 3 == m_pFace->charmaps[nIndex]->platform_id )
{
nResult = 1;
break;
}
}
}
return nResult;
}
void CFontFile::UpdateStyles(const INT& bBold, const INT& bItalic) void CFontFile::UpdateStyles(const INT& bBold, const INT& bItalic)
{ {
std::string sStyle = GetStyleName(); std::string sStyle = GetStyleName();
......
...@@ -217,6 +217,11 @@ public: ...@@ -217,6 +217,11 @@ public:
void SetCharSpacing(const double& dCharSpacing); void SetCharSpacing(const double& dCharSpacing);
double GetCharSpacing(); double GetCharSpacing();
std::string GetStyleName(); std::string GetStyleName();
void GetPanose(BYTE* pData);
bool IsFixedWidth();
int IsUnicodeRangeAvailable(unsigned long ulBit, unsigned int un4ByteIndex);
void UpdateStyles(const INT& bBold, const INT& bItalic); void UpdateStyles(const INT& bBold, const INT& bItalic);
......
...@@ -615,6 +615,12 @@ INT CFontManager::LoadFontFromFile(const std::wstring& sPath, const int& lFaceIn ...@@ -615,6 +615,12 @@ INT CFontManager::LoadFontFromFile(const std::wstring& sPath, const int& lFaceIn
m_pFont->m_pFontManager = this; m_pFont->m_pFontManager = this;
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY); m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
m_sName = L"";
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
{
m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
}
return TRUE; return TRUE;
} }
...@@ -627,6 +633,12 @@ INT CFontManager::LoadFontFromFile2(CFontsCache* pCache, const std::wstring& sPa ...@@ -627,6 +633,12 @@ INT CFontManager::LoadFontFromFile2(CFontsCache* pCache, const std::wstring& sPa
m_pFont->m_pFontManager = this; m_pFont->m_pFontManager = this;
m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY); m_pFont->SetSizeAndDpi(dSize, (UINT)dDpiX, (UINT)dDpiY);
m_sName = L"";
if (m_pFont->m_pFace && m_pFont->m_pFace->family_name)
{
m_sName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)m_pFont->m_pFace->family_name, strlen(m_pFont->m_pFace->family_name));
}
return TRUE; return TRUE;
} }
......
...@@ -221,12 +221,11 @@ public: ...@@ -221,12 +221,11 @@ public:
virtual HRESULT put_FontFaceIndex(const int& lFaceIndex) = 0; virtual HRESULT put_FontFaceIndex(const int& lFaceIndex) = 0;
//-------- Функции для вывода текста -------------------------------------------------------- //-------- Функции для вывода текста --------------------------------------------------------
virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) = 0; virtual HRESULT CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) = 0; virtual HRESULT CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) = 0; virtual HRESULT CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) = 0; virtual HRESULT CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT CommandDrawTextPdf(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const std::wstring& wsSrcCodeText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) { return 0; };
//-------- Маркеры для команд --------------------------------------------------------------- //-------- Маркеры для команд ---------------------------------------------------------------
virtual HRESULT BeginCommand(const DWORD& lType) = 0; virtual HRESULT BeginCommand(const DWORD& lType) = 0;
...@@ -245,12 +244,11 @@ public: ...@@ -245,12 +244,11 @@ public:
virtual HRESULT PathCommandStart() = 0; virtual HRESULT PathCommandStart() = 0;
virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y) = 0; virtual HRESULT PathCommandGetCurrentPoint(double* x, double* y) = 0;
virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) = 0; virtual HRESULT PathCommandTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset) = 0; virtual HRESULT PathCommandText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) = 0; virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextEx(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) = 0; virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT PathCommandTextPdf(const std::wstring& bsUnicodeText, const std::wstring& bsGidText, const std::wstring& bsSrcCodeText, const double& x, const double& y, const double& w, const double& h, const double& baselineOffset, const DWORD& lFlags) { return 0; };
//-------- Функции для вывода изображений --------------------------------------------------- //-------- Функции для вывода изображений ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0; virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
......
...@@ -493,6 +493,18 @@ namespace NSStructures ...@@ -493,6 +493,18 @@ namespace NSStructures
CharSpace = 0.0; CharSpace = 0.0;
FaceIndex = 0; FaceIndex = 0;
} }
LONG GetTextDecorationStyle()
{
if ((0 == Underline) && (0 == Strikeout))
return 0;
if ((1 == Underline) && (0 == Strikeout))
return 1;
if ((0 == Underline) && (1 == Strikeout))
return 2;
if ((1 == Underline) && (1 == Strikeout))
return 3;
return 4;
}
public: public:
......
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