Ejemplo n.º 1
0
bool xDistanceFontGenerator::generate(const wchar_t* ttfFile , const wchar_t* _distFileName)
{
	InitFilterKernel();
	static bool sb_isInited = false;
	if(sb_isInited == false) 
	{
		if (FT_Init_FreeType( &g_FT2Lib )) 
		{
			XEVOL_LOG(eXL_DEBUG_HIGH,"FT_Init_FreeType failed\n");
			assert(0);
		}
	}
	sb_isInited = true;

	char strFontFile[1024] = {0};
	XEvol_UnicodeToFsEnc(ttfFile,strFontFile,1024);
	//加载一个字体,取默认的Face,一般为Regualer
	if (FT_New_Face( g_FT2Lib, strFontFile, 0, (FT_Face*)&m_FT_Face )) 
	{
		XEVOL_LOG(eXL_DEBUG_HIGH,"FT_New_Face failed (there is probably a problem with your font file\n   <font = %s> \n" , strFontFile);
		return false;
	}
	FT_Select_Charmap( (FT_Face)m_FT_Face, FT_ENCODING_UNICODE);
	//大小要乘64.这是规定。照做就可以了。
	//FT_Set_Char_Size( m_FT_Face , 0 , m_w << 6, 96, 96);
	FT_Set_Pixel_Sizes( (FT_Face)m_FT_Face,m_ttfSize, m_ttfSize);

	std::wstring distFileName = std::wstring(_distFileName) + L".dff";
	FILE* file = _wfopen(distFileName.c_str(),L"wb+");
	std::wstring descFileName = std::wstring(_distFileName) + L".dfd";
	FILE* descFile = _wfopen(descFileName.c_str() ,L"wb+");
	if(file == NULL || descFile == NULL)
		return false;

	int Offset = 0;
	int nChar  =  m_Last - m_Begin;
	fwrite(&nChar , sizeof(nChar) , 1 , descFile );
	printf("Bengin........\n");
	for(wchar_t ch = m_Begin ; ch < m_Last ; ch ++)
	{
		xDFFCharDesc desc;
		
		float _noffset = gen(ch , file , Offset , desc);
		desc.m_offset = Offset;
		fwrite(&desc , sizeof(desc) , 1 , descFile );
		Offset += _noffset;
		int _nCH = ch ;
		printf("Total %d char passed\n" , _nCH);
	}
	printf("Finish........\n");
	fclose(descFile);
	fclose(file);
	return true;
}
Ejemplo n.º 2
0
result MultiFrame::InitKernels(
    const int &sample_expand,
    const int &linear,
    const int &correction,
    const int &balanced) {

    result status = FILTER_OK;

    status = InitFilterKernel(sample_expand, linear, correction, balanced);
    if (status != FILTER_OK) return status;

    status = InitSortKernel(linear);
    if (status != FILTER_OK) return status;

    return status;
}