void GCode::fatalError(FSTRINGPARAM(message)) {
	fatalErrorMsg = message;
#if SDSUPPORT
	if(sd.sdmode != 0)	{ // stop sd print to prevent damage
		sd.stopPrint();
	}
#endif	
	if(Printer::currentPosition[Z_AXIS] < Printer::zMin + Printer::zLength - 15)
		PrintLine::moveRelativeDistanceInStepsReal(0,0,10*Printer::axisStepsPerMM[Z_AXIS],0,Printer::homingFeedrate[Z_AXIS],true,true);
	EVENT_FATAL_ERROR_OCCURED		
	Commands::waitUntilEndOfAllMoves();
	Printer::kill(true);		
	reportFatalError();
}
/* create a tree, return root node */
SearchTree createTree()
{
	SearchTree tree;

	tree=createNode();
	if(tree==NULL)
	{
		reportFatalError("Out of space");
	}
	else
	{
		tree->m_left=NULL;
		tree->m_right=NULL;
	}

	return tree;
}
Beispiel #3
0
/**
* Init and load font
**/
OpenGLFont::OpenGLFont(RenderOpenGL* render, string name, Mod* mod, float size)
{
	int error;

	// Basics
	this->pmpl = new OpenGLFont_Implementation();
	this->render = render;
	this->size = size;

	// Init freetype
	// TODO: Should we share the tf ptr between OpenGLFont instances
	error = FT_Init_FreeType(&this->pmpl->ft);
	if (error) {
		reportFatalError("Freetype: Unable to init library.");
	}

	// On Linux, the system font is found using fontconfig
	#if defined(__linux__)
		FcConfig* config = FcInitLoadConfigAndFonts();

		FcPattern* pat = FcPatternBuild(
			NULL,
			FC_FAMILY, FcTypeString, reinterpret_cast<const char*>(name.c_str()),
			NULL
		);
		FcConfigSubstitute(config, pat, FcMatchPattern);
		FcDefaultSubstitute(pat);

		FcResult result;
		FcPattern* font = FcFontMatch(config, pat, &result);
		if (font == NULL) {
			reportFatalError("Fontconfig: Unable to find font " + name);
		}

		FcChar8* filename = NULL;
		if (FcPatternGetString(font, FC_FILE, 0, &filename) != FcResultMatch) {
			reportFatalError("Fontconfig: No filename in fontconfig match");
		}

		error = FT_New_Face(this->pmpl->ft, reinterpret_cast<const char*>(filename), 0, &this->pmpl->face);

		FcPatternDestroy(font);
		FcPatternDestroy(pat);

	#else
		// All other systems use a file in the cr/ mod
		Sint64 len;
		name.append(".ttf");
		this->pmpl->buf = mod->loadBinary(name, &len);
		if (this->pmpl->buf == NULL) {
			reportFatalError("Freetype: Unable to load data");
		}

		error = FT_New_Memory_Face(this->pmpl->ft, (const FT_Byte *) this->pmpl->buf, (FT_Long)len, 0, &this->pmpl->face);
	#endif

	// Handle errors
	if (error == FT_Err_Unknown_File_Format) {
		reportFatalError("Freetype: Unsupported font format");
	} else if (error) {
		reportFatalError("Freetype: Unable to load font");
	}

	// Set character size
	error = FT_Set_Char_Size(this->pmpl->face, 0, size * 64, 72, 72);
	if (error) {
		reportFatalError("Freetype: Unable to load font size");
	}
}