当前位置: 首页>>代码示例>>C++>>正文


C++ FontStyle::Acquire方法代码示例

本文整理汇总了C++中FontStyle::Acquire方法的典型用法代码示例。如果您正苦于以下问题:C++ FontStyle::Acquire方法的具体用法?C++ FontStyle::Acquire怎么用?C++ FontStyle::Acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FontStyle的用法示例。


在下文中一共展示了FontStyle::Acquire方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/*!
	\brief Sets the ServerFont instance to whatever font is specified
	This method will lock the font manager.

	\param familyID ID number of the family to set
	\param styleID ID number of the style to set
	\return B_OK if successful, B_ERROR if not
*/
status_t
ServerFont::SetFamilyAndStyle(uint16 familyID, uint16 styleID)
{
	FontStyle* style = NULL;

	if (gFontManager->Lock()) {
		style = gFontManager->GetStyle(familyID, styleID);
		if (style != NULL)
			style->Acquire();

		gFontManager->Unlock();
	}

	if (style == NULL)
		return B_ERROR;

	SetStyle(style);
	style->Release();

	return B_OK;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: FamilyID

status_t
ServerFont::SetFace(uint16 face)
{
	// TODO: This needs further investigation. The face variable is actually
	// flags, but some of them are not enforcable at the same time. Also don't
	// confuse the Be API "face" with the Freetype face, which is just an
	// index in case a single font file exports multiple font faces. The
	// FontStyle class takes care of mapping the font style name to the Be
	// API face flags in FontStyle::_TranslateStyleToFace().

	FontStyle* style = NULL;
	uint16 familyID = FamilyID();
	if (gFontManager->Lock()) {
		int32 count = gFontManager->CountStyles(familyID);
		for (int32 i = 0; i < count; i++) {
			style = gFontManager->GetStyleByIndex(familyID, i);
			if (style == NULL)
				break;
			if (style->Face() == face) {
				style->Acquire();
				break;
			} else
				style = NULL;
		}

		gFontManager->Unlock();
	}

	if (!style)
		return B_ERROR;

	SetStyle(style);
	style->Release();

	return B_OK;
}
开发者ID:,项目名称:,代码行数:36,代码来源:


注:本文中的FontStyle::Acquire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。