我是新手,刚开始编程,所以如果有人回答或解释过这个问题,我深表歉意。基本上,我一直在查看 SFML 库的文档并遇到一些 sf::Font 类公共(public)成员函数。一个例子是这样的:
bool sf::Font::loadFromFile ( const std::string & filename )
接下来是函数的作用:
/// \brief Load the font from a file
///
/// The supported font formats are: TrueType, Type 1, CFF,
/// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.
/// Note that this function know nothing about the standard
/// fonts installed on the user's system, thus you can't
/// load them directly.
///
/// \warning SFML cannot preload all the font data in this
/// function, so the file has to remain accessible until
/// the sf::Font object loads a new font or is destroyed.
///
/// \param filename Path of the font file to load
///
/// \return True if loading succeeded, false if it failed
///
/// \see loadFromMemory, loadFromStream
///
我已经下载了库并查看了头文件,但我似乎无法找到 loadFromFile 函数实际上是如何完成加载的(换句话说,我正在寻找函数体或 完成工作的函数定义)。该文档仅解释了函数的作用,而不是如何。
如果这是一个愚蠢的问题或应该显而易见的问题,我很抱歉。我只是非常好奇函数的核心在哪里。
顺便说一下,here是指向我所指文档的页面和部分的确切链接。
感谢所有回答的人。
最佳答案
您正在寻找的方法可以在公共(public) Github 存储库中找到。
它在文件 Font.cpp 中,从第 122 行开始:
https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L122
文档不会提及这一点,因为文档是关于此功能的用户可以依赖的行为。方法如何实现此行为是用户不需要知道的私有(private)实现细节。
关于c++ - 定位函数的函数定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40336855/