FT_Render_Glyph returning error INVALID_OUTLINE

"Jain, Ankit" via FreeType users <[email protected]> Fri, 17 Sep 2021 04:03:18 +0000
Newsgroups gmane.comp.fonts.freetype.user,gmane.comp.fonts.freetype.devel
Message-ID <VI1PR08MB3472BAAAA5AE55CC23227DE5AADD9@VI1PR08MB3472.eurprd08.prod.outlook.com>
Hello Team,

In our product we are in process to upgrade freeType library from 2.0.9 to 2.10.0 version and compiled the library in 64Bit..


Using the upgraded library I'm trying to convert the glyph image to FT_GLYPH_FORMAT_BITMAP format using FT_RENDER_MODE_MONO rendering mode, but the function FT_Render_Glyph is returning error INVALID_OUTLINE (Error#:20).

I have attached the font & sample test program for which it is giving me error.

Can you please give an advise on this.

Thanks

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
stbc39h.ttf (application/octet-stream, 713.6 KB) - not displayed
FreetypeTestProgram.cpp (text/plain, 2.3 KB)
// FreetyprTest.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <fstream>
#include <string>

#include "ft2build.h"
#include FT_FREETYPE_H

using namespace std;
char m_arrnMappingTable[] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
							16,17,18,19,20,21,22,23,24,25,26,27,28,29,
							30,31,32,33,34,35,36,37,38,39,40,41,42,43,
							44,45,46,47,48,49,50,51,52,53,54,55,56,57,
							58,59,60,61,62,63,64,65,66,67,68,69,70,71,
							72,73,74,75,76,77,78,79,80,81,82,83,84,85,
							86,87,88,89,90,91,92,93,94 };

struct FT_FaceRec_;
struct FT_LibraryRec_;

int main()
{
	char fontdata[732160] = { '\0' };

	FILE * fptr = fopen(".\\stbc39h.ttf", "rb");
	
	if (fptr == NULL)
	{
		printf("Cannot open file \n");
		exit(0);
	}

	// Read contents from file
	int len = 0;
	char c = fgetc(fptr);

	fseek(fptr, 0, SEEK_END);

	unsigned int uiSize = ftell(fptr) + 1;

	fseek(fptr, 0, SEEK_SET);

	size_t read = fread(fontdata, sizeof(char), uiSize, fptr);

	fclose(fptr);

	FT_Library m_ftlbLibrary;
	struct FT_FaceRec_    * m_ftfcFace;

	int nError = FT_Init_FreeType(&m_ftlbLibrary);

	if (nError)
	{
		cout << "ERROR - Failed to initialize FreeType library." << endl;
		cout << "\tError code: " << nError << endl;
		return false;
	}


	nError = FT_New_Memory_Face(m_ftlbLibrary,
		(unsigned char *)fontdata,
		uiSize,
		0,
		&m_ftfcFace);

	nError = FT_Set_Char_Size(
		m_ftfcFace,    /* handle to face object           */
		0,       /* char_width in 1/64th of points  */
		16 * 64,   /* char_height in 1/64th of points */
		300,     /* horizontal device resolution    */
		300);   /* vertical device resolution      */


	int nChar;
	int nGlyphIndex;
	bool bGlyphIndexFound = false;
	
	for (int i = 16; i < 36; i++)
	{
		nChar = m_arrnMappingTable[i];

		nGlyphIndex = FT_Get_Char_Index(m_ftfcFace, nChar);

		if (!nGlyphIndex)
		{
			continue;
		}

		nError = FT_Load_Glyph(m_ftfcFace,      /* handle to face object */
			nGlyphIndex,        /* glyph index           */
			FT_LOAD_DEFAULT);  /* load flags, see below */

		if (nError)
		{
			continue;
		}

		nError = FT_Render_Glyph(m_ftfcFace->glyph,  /* glyph slot  */
			ft_render_mode_mono); /* render mode */

		if (nError)
		{
			continue;
		}

	}
}