Commit d896f09f authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

полная реализация FontConverter

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63607 954022d7-b5bf-4e40-9824-e11837661b57
parent 284e46d4
......@@ -6,8 +6,8 @@
class CFontConverter
{
public:
int ToOTF(std::wstring sFontIn, std::wstring sFontOut, unsigned int* pSymbols, int nCount, std::wstring sName, long nFlag);
int ToOTF2(std::wstring sFontIn, unsigned int* pSymbols, int nCount, std::wstring sName, long nFlag, long lFaceIndex, unsigned char*& pDstData, int& nDstLen);
bool ToOTF(std::wstring sFontIn, std::wstring sFontOut, unsigned int* pSymbols, int nCount, std::wstring sName, long nFlag);
bool ToOTF2(std::wstring sFontIn, unsigned int* pSymbols, int nCount, std::wstring sName, long nFlag, long lFaceIndex, unsigned char*& pDstData, int& nDstLen);
};
#endif /* _BUILD_FONT_CONVERTER_H */
......@@ -9,7 +9,7 @@ namespace NSFontConverter
{
//------------------------------------------------------------------------
typedef void (*FontFileOutputFunc)(void *pStream, char *sData, int nLen);
typedef void (*FontFileOutputFunc)(void *pStream, const char *sData, int nLen);
//------------------------------------------------------------------------
// CFontFileBase
......@@ -39,7 +39,7 @@ namespace NSFontConverter
{
m_nPos = 0;
}
static char *ReadFile(wchar_t *wsFileName, int *pnFileLen)
static char *ReadFile(const wchar_t *wsFileName, int *pnFileLen)
{
NSFile::CFileBinary oFile;
if ( !oFile.OpenFile(wsFileName) )
......
#include "FontFileEncodings.h"
#include "../../common/File.h"
namespace NSFontConverter
{
......@@ -5741,6 +5742,7 @@ namespace NSFontConverter
int Type1NameToUnicodeA(const char *sName)
{
return Type1NameToUnicodeW( A2W( sName ) );
std::wstring sUnicode = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sName, (LONG)strlen(sName));
return Type1NameToUnicodeW( sUnicode.c_str() );
}
}
#ifndef _ASC_FONTCONVERTER_FONNT_FILE_ENCODINGS_H
#define _ASC_FONTCONVERTER_FONNT_FILE_ENCODINGS_H
#include "../../common/Types.h"
#include <string>
namespace NSFontConverter
{
class CWCharWrapper
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,6 +2,8 @@
#define _ASC_FONT_CONVERTER_MEMORY_UTILS_H_
#include <stdio.h>
#include <limits>
#include <string>
namespace NSFontConverter
{
......
......@@ -101,7 +101,7 @@ namespace NSFontConverter
StringExt::StringExt(const char *sSrc)
{
int nLen = strlen( sSrc );
int nLen = (int)strlen( sSrc );
m_sData = NULL;
Resize(m_nLength = nLen);
......@@ -148,7 +148,7 @@ namespace NSFontConverter
char *pData = NULL;
int nLen;
FormatInt( nValue, sBuffer, sizeof( sBuffer ), FALSE, 0, 10, &pData, &nLen);
FormatInt( nValue, sBuffer, sizeof( sBuffer ), false, 0, 10, &pData, &nLen);
return new StringExt( pData, nLen );
}
......@@ -231,7 +231,7 @@ namespace NSFontConverter
{
StringExtFormatArg uArg;
int nIndex, nWidth, nPrecision;
BOOL bReverseAlign, bZeroFill;
bool bReverseAlign, bZeroFill;
StringExtFormatType eFormatType;
char sBuffer[65];
int nLen;
......@@ -266,11 +266,11 @@ namespace NSFontConverter
++pCur;
if ( *pCur == '-' )
{
bReverseAlign = TRUE;
bReverseAlign = true;
++pCur;
}
else
bReverseAlign = FALSE;
bReverseAlign = false;
nWidth = 0;
bZeroFill = *pCur == '0';
for (; *pCur >= '0' && *pCur <= '9'; ++pCur )
......@@ -415,10 +415,10 @@ namespace NSFontConverter
FormatUInt( uArg.ulValue, sBuffer, sizeof(sBuffer), bZeroFill, nWidth, 2, &sTemp, &nLen );
break;
case fmtDouble:
FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, FALSE, &sTemp, &nLen );
FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, false, &sTemp, &nLen );
break;
case fmtDoubleTrim:
FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, TRUE, &sTemp, &nLen );
FormatDouble( uArg.fValue, sBuffer, sizeof(sBuffer), nPrecision, true, &sTemp, &nLen );
break;
case fmtChar:
sBuffer[0] = uArg.cValue;
......@@ -474,10 +474,10 @@ namespace NSFontConverter
return this;
}
void StringExt::FormatInt ( long nValue, char *sBuffer, int nBufferSize, BOOL bZeroFill, int nWidth, int nBase, char **ppData, int *pnLen)
void StringExt::FormatInt ( long nValue, char *sBuffer, int nBufferSize, bool bZeroFill, int nWidth, int nBase, char **ppData, int *pnLen)
{
static char c_sValues[17] = "0123456789abcdef";
BOOL bNegative = FALSE;
bool bNegative = false;
int nStart;
int nCur = nBufferSize;
......@@ -513,7 +513,7 @@ namespace NSFontConverter
*pnLen = nBufferSize - nCur;
}
void StringExt::FormatUInt(unsigned long nValue, char *sBuffer, int nBufferSize, BOOL bZeroFill, int nWidth, int nBase, char **ppData, int *pnLen)
void StringExt::FormatUInt(unsigned long nValue, char *sBuffer, int nBufferSize, bool bZeroFill, int nWidth, int nBase, char **ppData, int *pnLen)
{
static char c_sValues[17] = "0123456789abcdef";
......@@ -541,9 +541,9 @@ namespace NSFontConverter
*pnLen = nBufferSize - nCur;
}
void StringExt::FormatDouble( double dValue, char *sBuffer, int nBufferSize, int nPrecision, BOOL bTrim, char **ppData, int *pnLen)
void StringExt::FormatDouble( double dValue, char *sBuffer, int nBufferSize, int nPrecision, bool bTrim, char **ppData, int *pnLen)
{
BOOL bNegative = FALSE, bStarted = FALSE;
bool bNegative = false, bStarted = false;
double dTemp = 0;
int nInt;
......@@ -560,7 +560,7 @@ namespace NSFontConverter
if ( bStarted || nInt != 0 )
{
sBuffer[--nCur] = '0' + nInt;
bStarted = TRUE;
bStarted = true;
}
dValue = dTemp;
}
......
......@@ -122,9 +122,9 @@ namespace NSFontConverter
void Resize(int nLength);
static void FormatInt ( long nValue, char *sBuffer, int nBufferSize, BOOL bZeroFill, int nWidth, int nBase, char **ppData, int *nLen);
static void FormatUInt (unsigned long nValue, char *sBuffer, int nBufferSize, BOOL bZeroFill, int nWidth, int nBase, char **ppData, int *nLen);
static void FormatDouble( double nValue, char *sBuffer, int nBufferSize, int nPrecision, BOOL bTrim, char **ppData, int *nLen);
static void FormatInt ( long nValue, char *sBuffer, int nBufferSize, bool bZeroFill, int nWidth, int nBase, char **ppData, int *nLen);
static void FormatUInt (unsigned long nValue, char *sBuffer, int nBufferSize, bool bZeroFill, int nWidth, int nBase, char **ppData, int *nLen);
static void FormatDouble( double nValue, char *sBuffer, int nBufferSize, int nPrecision, bool bTrim, char **ppData, int *nLen);
private:
......
......@@ -6,6 +6,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include "MemoryUtils.h"
#include <string>
......@@ -43,7 +44,7 @@ namespace NSFontConverter
sBuffer[nLen++] = nChar;
}
void Write(char *sString, int nStringLen = -1)
void Write(const char *sString, int nStringLen = -1)
{
if ( nStringLen < 0 )
nStringLen = strlen( sString );
......@@ -77,13 +78,13 @@ namespace NSFontConverter
}
};
static void CharBufferWrite(void *pBuffer, char *sData, int nLen)
static void CharBufferWrite(void *pBuffer, const char *sData, int nLen)
{
TCharBuffer *pCharBuffer = (TCharBuffer*)pBuffer;
pCharBuffer->Write( sData, nLen );
}
static void FileWrite(void* pFile, char *sData, int nLen)
static void FileWrite(void* pFile, const char *sData, int nLen)
{
::fwrite( sData, 1, nLen, (FILE*)pFile );
::fflush( (FILE*)pFile );
......@@ -111,7 +112,7 @@ namespace NSFontConverter
inline static int64_t GetHex (const std::wstring& string)
{
int64_t nResult = 0;
int nLen = string.length();
int nLen = (int)string.length();
const wchar_t* buf = string.c_str();
for ( int nIndex = 0; nIndex < nLen; ++nIndex )
{
......@@ -120,6 +121,25 @@ namespace NSFontConverter
return nResult;
}
inline static int GetInteger (const std::wstring& string)
{
return std::stoi(string);
}
inline static int GetInteger (const char* string)
{
return atoi(string);
}
inline static double GetDouble (const std::wstring& string)
{
return std::stod(string);
}
inline static double GetDouble (const char* string)
{
double d = 0;
sscanf(string, "%lf", &d);
return d;
}
}
// Функция взята из Graphics.dll
......
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