コード例 #1
0
ファイル: FontCacheEntry.cpp プロジェクト: mariuz/haiku
bool
FontCacheEntry::Init(const ServerFont& font)
{
	if (fGlyphCache == NULL)
		return false;

	glyph_rendering renderingType = _RenderTypeFor(font);

	// TODO: encoding from font
	FT_Encoding charMap = FT_ENCODING_NONE;
	bool hinting = font.Hinting();

	if (!fEngine.Init(font.Path(), 0, font.Size(), charMap,
			renderingType, hinting)) {
		fprintf(stderr, "FontCacheEntry::Init() - some error loading font "
			"file %s\n", font.Path());
		return false;
	}
	if (fGlyphCache->Init() != B_OK) {
		fprintf(stderr, "FontCacheEntry::Init() - failed to allocate "
			"GlyphCache table for font file %s\n", font.Path());
		return false;
	}

	return true;
}
コード例 #2
0
ファイル: WorkspacesView.cpp プロジェクト: mmanley/Antares
void
WorkspacesView::_DrawWorkspace(DrawingEngine* drawingEngine,
	BRegion& redraw, int32 index)
{
	BRect rect = _WorkspaceAt(index);

	Workspace workspace(*Window()->Desktop(), index);
	bool active = workspace.IsCurrent();
	if (active) {
		// draw active frame
		rgb_color black = (rgb_color){ 0, 0, 0, 255 };
		drawingEngine->StrokeRect(rect, black);
	} else if (index == fSelectedWorkspace) {
		rgb_color gray = (rgb_color){ 80, 80, 80, 255 };
		drawingEngine->StrokeRect(rect, gray);
	}

	rect.InsetBy(1, 1);

	rgb_color color = workspace.Color();
	if (!active)
		_DarkenColor(color);

	// draw windows

	BRegion backgroundRegion = redraw;

	// TODO: would be nice to get the real update region here

	BRect screenFrame = _ScreenFrame(index);

	BRegion workspaceRegion(rect);
	backgroundRegion.IntersectWith(&workspaceRegion);
	drawingEngine->ConstrainClippingRegion(&backgroundRegion);

	ServerFont font = fDrawState->Font();
	font.SetSize(fWindow->ServerWindow()->App()->PlainFont().Size());
	float reducedSize = ceilf(max_c(8.0f,
		min_c(Frame().Height(), Frame().Width()) / 15));
	if (font.Size() > reducedSize)
		font.SetSize(reducedSize);
	fDrawState->SetFont(font);
	drawingEngine->SetFont(font);

	// We draw from top down and cut the window out of the clipping region
	// which reduces the flickering
	::Window* window;
	BPoint leftTop;
	while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
		_DrawWindow(drawingEngine, rect, screenFrame, window,
			leftTop, backgroundRegion, active);
	}

	// draw background
	drawingEngine->FillRect(rect, color);

	drawingEngine->ConstrainClippingRegion(&redraw);
}
コード例 #3
0
void
RemoteMessage::AddFont(const ServerFont& font)
{
	Add(font.Direction());
	Add((uint8)font.Encoding());
	Add(font.Flags());
	Add((uint8)font.Spacing());
	Add(font.Shear());
	Add(font.Rotation());
	Add(font.FalseBoldWidth());
	Add(font.Size());
	Add(font.Face());
	Add(font.GetFamilyAndStyle());
}
コード例 #4
0
void
CanvasMessage::AddFont(const ServerFont& font)
{
	//TODO:Use TTF/WOFF URL
	Add(font.Direction());
	Add((uint8)font.Encoding());
	Add(font.Flags());
	Add((uint8)font.Spacing());
	Add(font.Shear());
	Add(font.Rotation());
	Add(font.FalseBoldWidth());
	Add(font.Size());
	Add(font.Face());
	Add(font.GetFamilyAndStyle());
}
コード例 #5
0
ファイル: DrawState.cpp プロジェクト: SummerSnail2014/haiku
//! sets the font to be already scaled by fScale
void
DrawState::SetFont(const ServerFont& font, uint32 flags)
{
	if (flags == B_FONT_ALL) {
		fFont = font;
		fUnscaledFontSize = font.Size();
		fFont.SetSize(fUnscaledFontSize * fCombinedScale);
	} else {
		// family & style
		if ((flags & B_FONT_FAMILY_AND_STYLE) != 0)
			fFont.SetFamilyAndStyle(font.GetFamilyAndStyle());
		// size
		if ((flags & B_FONT_SIZE) != 0) {
			fUnscaledFontSize = font.Size();
			fFont.SetSize(fUnscaledFontSize * fCombinedScale);
		}
		// shear
		if ((flags & B_FONT_SHEAR) != 0)
			fFont.SetShear(font.Shear());
		// rotation
		if ((flags & B_FONT_ROTATION) != 0)
			fFont.SetRotation(font.Rotation());
		// spacing
		if ((flags & B_FONT_SPACING) != 0)
			fFont.SetSpacing(font.Spacing());
		// encoding
		if ((flags & B_FONT_ENCODING) != 0)
			fFont.SetEncoding(font.Encoding());
		// face
		if ((flags & B_FONT_FACE) != 0)
			fFont.SetFace(font.Face());
		// flags
		if ((flags & B_FONT_FLAGS) != 0)
			fFont.SetFlags(font.Flags());
	}
}
コード例 #6
0
ファイル: FontCacheEntry.cpp プロジェクト: mariuz/haiku
/*static*/ void
FontCacheEntry::GenerateSignature(char* signature, size_t signatureSize,
	const ServerFont& font)
{
	glyph_rendering renderingType = _RenderTypeFor(font);

	// TODO: read more of these from the font
	FT_Encoding charMap = FT_ENCODING_NONE;
	bool hinting = font.Hinting();
	uint8 averageWeight = gSubpixelAverageWeight;

	snprintf(signature, signatureSize, "%ld,%u,%d,%d,%.1f,%d,%d",
		font.GetFamilyAndStyle(), charMap,
		font.Face(), int(renderingType), font.Size(), hinting, averageWeight);
}
コード例 #7
0
ファイル: FontCacheEntry.cpp プロジェクト: mariuz/haiku
/*static*/ glyph_rendering
FontCacheEntry::_RenderTypeFor(const ServerFont& font)
{
	glyph_rendering renderingType = gSubpixelAntialiasing ?
		glyph_ren_subpix : glyph_ren_native_gray8;

	if (font.Rotation() != 0.0 || font.Shear() != 90.0
		|| font.FalseBoldWidth() != 0.0
		|| font.Flags() & B_DISABLE_ANTIALIASING
		|| font.Size() > 30
		|| !font.Hinting()) {
		renderingType = glyph_ren_outline;
	}

	return renderingType;
}