Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unresolved external symbol cairo_ft_fony_face_create_for_ft #1

Open
Prakash19921206 opened this issue Nov 14, 2016 · 2 comments
Open

Comments

@Prakash19921206
Copy link

i think this build is not compiled with freetype library.
i referenced cairo in a project where freetype Library is also used.
i was used freetype to load font into cairo, using below code

FT_Library lib;
FT_Face face;
FT_Init_FreeType(&lib);
FT_New_Face(lib, "D:\\Segoe.ttf", 0, &face);
cairo_font_face_t *cairo_ft_font_face_create_for_ft_face(FT_Face face, int load_flags);
cairo_font_face_t *myfont_face;
myfont_face = cairo_ft_font_face_create_for_ft_face(face,0);

before it was pointing error in the file cairo-ft.h (line 115)

#error Cairo was not compiled with support for the freetype font backend

now , i'm getting compiler error,

LNK2019 unresolved external symbol "struct_cairo_font_face* cdecl cairo_ft_fony_face_create_for_ft(struct FT FaceRec *,int)" (?cairo_ft_fony_face_create_for_ft@@YAPAU_cario_font_face@@PAUFT_FaceREcc@@h@Z) referenced in function "public:_thiscall cairoText::cairoText(Void)"(??0cairoText@@QAE@XZ)

below is the code for putting text on imageusing cairo

cv::Mat cairoText::putTextCairo(
	cv::Mat &targetImage,
	std::string const& text,
	cv::Point2d centerPoint,
	std::string const& fontFace,
	double fontSize,
	cv::Scalar textColor,
	bool fontItalic,
	bool fontBold)
{
	// Create Cairo
	cairo_surface_t* surface =
cairo_image_surface_create( CAIRO_FORMAT_ARGB32,
targetImage.cols,
targetImage.rows);

	cairo_t* cairo = cairo_create(surface);

	// Wrap Cairo with a OpenCV Mat
	cv::Mat cairoTarget(
		cairo_image_surface_get_height(surface),
		cairo_image_surface_get_width(surface),
		CV_8UC4,
		cairo_image_surface_get_data(surface),
		cairo_image_surface_get_stride(surface));

	// Put image onto Cairo
	cv::cvtColor(targetImage, cairoTarget, cv::COLOR_BGR2BGRA);

	
	// Set font and write text
	cairo_select_font_face(
		cairo,
		fontFace.c_str(),
		fontItalic ? CAIRO_FONT_SLANT_ITALIC : CAIRO_FONT_SLANT_NORMAL,
		fontBold ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL);

	cairo_set_font_size(cairo, fontSize);
	//cairo_set_source_rgb(cairo, textColor[2], textColor[1], textColor[0]);
	cairo_set_source_rgba(cairo, textColor[2], textColor[1], textColor[0], 25);
	cairo_text_extents_t extents;
	cairo_text_extents(cairo, text.c_str(), &extents);

	cairo_move_to(
		cairo,
		centerPoint.x - extents.width / 2 - extents.x_bearing,
		centerPoint.y - extents.height / 2 - extents.y_bearing);
	cairo_show_text(cairo, text.c_str());

	// Copy the data to the output image
	cv::cvtColor(cairoTarget, targetImage, cv::COLOR_BGRA2BGR);

	cairo_destroy(cairo);
	cairo_surface_destroy(surface);
	return targetImage;
}

how to build cairo with freetype library support?
Thanks & Regards.

@tordex
Copy link
Owner

tordex commented Nov 15, 2016

Yes, this build is compiled without freetype support. Look into cairo-ft.h, you have to define CAIRO_HAS_FT_FONT when compile cairo library.

@Prakash19921206
Copy link
Author

thanks for your reply.
How to build Cairo with freetype support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants