本文整理汇总了C++中Font::GetFamily方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::GetFamily方法的具体用法?C++ Font::GetFamily怎么用?C++ Font::GetFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Font
的用法示例。
在下文中一共展示了Font::GetFamily方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextBounds
SizeF GDIPluseExt::GetTextBounds(const Font& font,const StringFormat& strFormat,CString szText)
{
#ifndef _UNICODE
//字符转换
int str_len = szText.GetLength();
WCHAR* pstr_w = new WCHAR[str_len];
MultiByteToWideChar(CP_ACP,0,szText.GetBuffer(),-1,pstr_w,str_len);
szText.ReleaseBuffer();
GraphicsPath graphicsPathObj;
FontFamily fontfamily;
font.GetFamily(&fontfamily);
graphicsPathObj.AddString(pstr_w,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);
DEL_P(pstr_w);
#else
GraphicsPath graphicsPathObj;
FontFamily fontfamily;
font.GetFamily(&fontfamily);
graphicsPathObj.AddString(szText,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);
#endif
RectF rcBound;
// 获取边界范围
graphicsPathObj.GetBounds(&rcBound);
// 返回文本的宽高
return SizeF(rcBound.Width,rcBound.Height);
}
示例2: UpdateInfo
void GlyphInfoPanel::UpdateInfo()
{
if (m_entry.IsOK())
{
Font font = FontManager::GetFont(m_entry.GetFamily(),
m_entry.GetStyle(), m_entry.GetSize());
font.SelectEncoding(m_entry.GetEncodingID());
wxUint32 glyph = font.GetGlyphIndex(m_entry.GetCode());
m_codeLabel->SetLabel(wxString::Format(_("%s, 0x%x"),
m_entry.GetEncoding(), m_entry.GetCode()));
m_fontLabel->SetLabel(wxString::Format(_("%s, %s, %g"),
font.GetFamily(), font.GetStyle(), font.GetSize()));
wxSize size = font.GetGlyphSize(glyph);
int width, height;
int dataSize = font.GetGlyphBitmap(glyph, NULL, &width, &height);
m_sizeLabel->SetLabel(wxString::Format(_("Size: %dpx x %dpx"),
width, height));
m_dataSizeLabel->SetLabel(wxString::Format(_("Data size: %d bytes"), dataSize));
}
else {
m_codeLabel->SetLabel(_(""));
m_fontLabel->SetLabel(_(""));
m_sizeLabel->SetLabel(_("Size: "));
m_dataSizeLabel->SetLabel(_("Data size: "));
}
}
示例3: GetTextBounds
// 获取文字需要的显示区域
Size GetTextBounds(const Font& font,const StringFormat& strFormat,const CString& strText)
{
GraphicsPath path;
FontFamily fontfamily;
font.GetFamily(&fontfamily);
BSTR bsText = strText.AllocSysString();
path.AddString(bsText,-1,&fontfamily,font.GetStyle(),font.GetSize(),PointF(0,0),&strFormat);
::SysFreeString(bsText);
RectF rcBound;
path.GetBounds(&rcBound);
REAL rHeight = font.GetHeight(0.0f);
return Size((int)(rcBound.Width > (int)rcBound.Width ? rcBound.Width + 1 : rcBound.Width),
(int)(rHeight > (int)rHeight ? rHeight + 4 : rHeight + 1));
//return Size((int)(rcBound.Width > (int)rcBound.Width ? rcBound.Width + 1 : rcBound.Width),
// (int)(rcBound.Height > (int)rcBound.Height ? rcBound.Height + 2 : rcBound.Height + 1));
}