Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ FreeType错误:FT_Load_Char返回36_C++_C_Freetype - Fatal编程技术网

C++ FreeType错误:FT_Load_Char返回36

C++ FreeType错误:FT_Load_Char返回36,c++,c,freetype,C++,C,Freetype,我一直在尝试让FreeType在我的游戏中工作,但每当我尝试从字体加载角色时,它似乎都不起作用。我在网上看过很多教程,据我所知,代码似乎没有任何问题 我试过使用不同的字体,但它们产生相同的错误 这是失败的代码: int errorCode = FT_New_Face(freetype, filename.c_str(), 0, &face); if (errorCode != 0) { std::cerr << "Failed to load font: " <

我一直在尝试让FreeType在我的游戏中工作,但每当我尝试从字体加载角色时,它似乎都不起作用。我在网上看过很多教程,据我所知,代码似乎没有任何问题

我试过使用不同的字体,但它们产生相同的错误

这是失败的代码:

int errorCode = FT_New_Face(freetype, filename.c_str(), 0, &face);
if (errorCode != 0)
{
    std::cerr << "Failed to load font: " << filename << ". Error code: " << errorCode << std::endl;
}

for (char i = 0; i < 256; i++)
{
    errorCode = FT_Load_Char(face, i, FT_LOAD_RENDER); // This returns 36 when i is 0
    if (errorCode != 0)
    {
        std::cerr << filename << ": Failed to load character '" << i << "'. Error code: " << errorCode << std::endl;
    }
}
int errorCode=FT_New_Face(freetype,filename.c_str(),0,&Face);
如果(错误代码!=0)
{

我曾经收到过相同的错误代码。我猜“无效大小句柄”意味着字体大小而不是内存大小设置无效


我通过在FT\u New\u Face之后添加对FT\u Set\u Char\u Size的调用解决了这个问题。希望能有所帮助。

我曾经收到过相同的错误代码。我猜“无效大小句柄”意味着字体大小而不是内存大小设置无效


我通过在FT\u New\u Face之后添加对FT\u Set\u Char\u Size的调用来修复此问题。希望这能有所帮助。

加载人脸后尝试设置字体大小:

int errorCode = FT_New_Face(freetype, filename.c_str(), 0, &face);
if (!errorCode)
    std::cerr << "Failed to load font: " << filename << ". Error code: " << errorCode << std::endl;

int pensize = 64;
FT_Set_Pixel_Sizes(face, pensize, 0);

// you can now load the glyphs
int errorCode=FT_New_Face(freetype,filename.c_str(),0,&Face);
如果(!错误代码)

加载人脸后,尝试设置字体大小:

int errorCode = FT_New_Face(freetype, filename.c_str(), 0, &face);
if (!errorCode)
    std::cerr << "Failed to load font: " << filename << ". Error code: " << errorCode << std::endl;

int pensize = 64;
FT_Set_Pixel_Sizes(face, pensize, 0);

// you can now load the glyphs
int errorCode=FT_New_Face(freetype,filename.c_str(),0,&Face);
如果(!错误代码)

我应该被强制转换为FT_ULONGI,同样的结果。不要强制转换,而是用该类型实例化对象。将1字节的值强制转换为8字节的值也不正确,我得到了相同的结果…为什么你认为该字体包含NUL字符的信息(那是什么信息?没有宽度,没有轮廓)。你可以通过调用
FT\u Get\u Char\u Index
来检查字体是否包含字符。我应该被强制转换为FT\u ULONGI尝试过,同样的结果。不要强制转换,而是用该类型实例化对象。将1字节的值强制转换为8字节的值也不正确,我得到了同样的结果…你为什么认为类型eface包含NUL字符的信息(这是什么信息?没有宽度,没有轮廓)。您始终可以通过调用
FT\u Get\u Char\u Index
检查字体是否包含字符。