Skip to content

unresolved external symbol cairo_ft_fony_face_create_for_ft #1

@Prakash19921206

Description

@Prakash19921206

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions