Exemplo n.º 1
0
Arquivo: zipk.cpp Projeto: wangch/zipk
static Gdiplus::Size getTxtSize(std::wstring txt) {
   Gdiplus::GraphicsPath path;
   Gdiplus::FontFamily ff;
   Gdiplus::Font* font = g_lv.f;
   font->GetFamily(&ff);

   Gdiplus::Rect rc;
   Gdiplus::Size sz;
   int len = txt.length();
   if (len == 0) {
      return sz;
   }

   bool is_space = false;
   if (txt[len - 1] == L' ') {
      txt[len - 1] = L'M';
      is_space = true;
   }

   path.AddString(txt.c_str(), 
      len, &ff, 
      font->GetStyle(), 
      font->GetSize(), 
      Gdiplus::Point(1, 0), 
      NULL);
   path.GetBounds(&rc);

   int sd = (int)(font->GetSize() / 4);
   sz.Width = rc.Width + sd;
   if (is_space) {
      sz.Width -= sd;
   }
   sz.Height = rc.Height;
   return sz;
}
Exemplo n.º 2
0
cgSizeF cgGdiplusRender::GetUICharSize( TCHAR ch, cgID idFont )
{
	Gdiplus::Font * pkFont = FindFont(idFont);
	if (pkFont)
	{
		int w = ch<128?pkFont->GetSize()/2:pkFont->GetSize();
		return cgSizeF(w, pkFont->GetSize());
	}
	return cgSizeF();
}
Exemplo n.º 3
0
int cgGdiplusRender::GetUICharWidth( TCHAR ch, cgID idFont )
{
	int nW = 0;
	Gdiplus::Font * pkFont = FindFont(idFont);
	if (pkFont)
	{
		int nSize = pkFont->GetSize(); 

		if (ch < 128)
			nW = nSize/2;
		else
			nW = nSize;
	}
	return nW;
}