Exemplo n.º 1
0
void CSFastFont::DrawCharSC(int fontcode,int x,int y,float scx,float scy,DWORD FontColor,SIZE *pSize)
{
	StSFontCacheInfo *pCache;
	DPRINTF( ("%08X:fontcode=%08X\n",this,fontcode) );
	pCache = GetCacheData(fontcode);

	float w,h;
	w = (int)pCache->w * scx;
	h = (int)pCache->h * scy;

	pSize->cx = (LONG)w;
	pSize->cy = (LONG)h;

	w = (int)(pCache->w-1) * scx;
	h = (int)(pCache->h-1) * scy;

	D3DTLVERTEX v[]=
	{
	  { (float)x     , (float)y     , 0.0f, 1.0f, FontColor,   0, ((pCache->u            )+0.5f)/m_MaxImageWidth, ((pCache->v            )+0.5f)/m_MaxImageHeight},
	  { (float)(x+w) , (float)y     , 0.0f, 1.0f, FontColor,   0, ((pCache->u+pCache->w-1)+0.5f)/m_MaxImageWidth, ((pCache->v            )+0.5f)/m_MaxImageHeight}, 
	  { (float)x     , (float)(y+h) , 0.0f, 1.0f, FontColor,   0, ((pCache->u            )+0.5f)/m_MaxImageWidth, ((pCache->v+pCache->h-1)+0.5f)/m_MaxImageHeight}, 

	  { (float)(x+w) , (float)y     , 0.0f, 1.0f, FontColor,   0, ((pCache->u+pCache->w-1)+0.5f)/m_MaxImageWidth, ((pCache->v            )+0.5f)/m_MaxImageHeight}, 
	  { (float)(x+w) , (float)(y+h) , 0.0f, 1.0f, FontColor,   0, ((pCache->u+pCache->w-1)+0.5f)/m_MaxImageWidth, ((pCache->v+pCache->h-1)+0.5f)/m_MaxImageHeight},
	  { (float)x     , (float)(y+h) , 0.0f, 1.0f, FontColor,   0, ((pCache->u            )+0.5f)/m_MaxImageWidth, ((pCache->v+pCache->h-1)+0.5f)/m_MaxImageHeight}, 
	};

	if( (MAX_SSF_VERTEX-1) > m_SSF_Vertex_index ){
		memcpy( &m_SFF_Vertex[m_SSF_Vertex_index],v,6*sizeof(D3DTLVERTEX) );
		m_SSF_Vertex_index+=6;
	}
}
Exemplo n.º 2
0
void BuildChar16(int XPos,int YPos,Wchar Code,int CFont,
          int Width,int Height,int Slant,int RotateAngle,int Color)
{
   unsigned char *pImage;
   int ImageLen,ImageW,ImageH;
   unsigned char *CharBuffer;

   assert(CFont==0);

   ImageH=Height;
   ImageW=(Width+7)/8;
   ImageLen=ImageW*ImageH;
   pImage=(unsigned char *)malloc(ImageLen);
   //if(pImage==NULL)
   if(pImage<0x1000)
   {
       ReportMemoryError("bld16");
       return;
   }

   if(Width!=Height
   || GetCacheData(Code,CFont,Width,pImage,ImageLen)!=OpOK)
   {
      CharBuffer=GetChineseDot(Code);
      memset(pImage,0,ImageLen);        // clear it
      ZoomCharBuffer(CharBuffer,CHINESEWIDTH,CHINESEHIGHT,
          (float)Width/CHINESEWIDTH,(float)Height/CHINESEHIGHT,pImage,ImageW);

      if(Width==Height)
         PutCacheData(Code,CFont,Width,pImage,ImageLen);
   }

   BuildImage(pImage,XPos,YPos,Width,Height,Slant,RotateAngle,Color);
   free(pImage);
}
Exemplo n.º 3
0
void BuildChar24(int XPos,int YPos,Wchar Code,int CFont,
                  int Width,int Height,int Slant,
                  int RotateAngle,int Color)
{
   char str[32];
   FILE *fp;
   unsigned char *pImage;
   int ImageLen,ImageW,ImageH;
   char buffer[24*24/8];
   int qq,ww;

   //assert(Code>=0xb0a1 && CFont>=0 && CFont<4);
   ImageH=Height;
   ImageW=(Width+7)/8;
   ImageLen=ImageW*ImageH;
   pImage=(unsigned char *)malloc(ImageLen);
   //if(pImage==NULL)
   if(pImage<0x1000)
   {
      ReportMemoryError("bld24");
      goto lbl_disp_end;
   }

   if(Width!=Height
   || GetCacheData(Code,CFont,Width,pImage,ImageLen)!=OpOK)
   {
      strcpy (str,Dotlib24FileName);
      str[19] = SKHF_Name[CFont];

      fp = fopen(str,"rb");
      if (NULL==fp)
         goto lbl_disp_end;

      qq=(Code>>8)-0xb0;  ww=(Code&0xff)-0xa1;
      fseek(fp,72L*(qq*94+ww),SEEK_SET);
      qq=fread(buffer,1,72,fp);
      fclose(fp);
      if(qq!=72)
         goto lbl_disp_end;

      memset(pImage,0,ImageLen);        // clear it
      ZoomCharBuffer(buffer,24,24,
                (float)Width/24,(float)Height/24,pImage,ImageW);

      if(Width==Height)
         PutCacheData(Code,CFont,Width,pImage,ImageLen);
   }
Exemplo n.º 4
0
void BuildSymbol24(int XPos,int YPos,Wchar Code,
                  int Width,int Height,int Slant,
                  int RotateAngle,int Color)
{
   FILE *fp;
   unsigned char *pImage;
   int ImageLen,ImageW,ImageH;
   char buffer[24*24/8];
   int qq,ww;

   //assert(Code<0xb0a1 && Code>0xa1a1);
   ImageH=Height;
   ImageW=(Width+7)/8;
   ImageLen=ImageW*ImageH;
   pImage=(unsigned char *)malloc(ImageLen);
   //if(pImage==NULL)
   if(pImage<0x1000)
   {
      ReportMemoryError("bldsymb24");
      return;
   }

   if(Width!=Height
   || GetCacheData(Code,SYMBOL_LIB,Width,pImage,ImageLen)!=OpOK)
   {
      fp = fopen(Symbol24FileName,"rb");
      if (NULL==fp)
        goto lbl_disp_end;

      qq=(Code>>8)-0xa1;  ww=(Code&0xff)-0xa1;
      fseek(fp,72L*(qq*94+ww),SEEK_SET);
      qq=fread(buffer,1,72,fp);
      fclose(fp);
      if(qq!=72)
         goto lbl_disp_end;

      memset(pImage,0,ImageLen);        // clear it
      ZoomCharBuffer(buffer,24,24,
                (float)Width/24,(float)Height/24,pImage,ImageW);

      if(Width==Height)
         PutCacheData(Code,SYMBOL_LIB,Width,pImage,ImageLen);
   }