Font Metrics in C
I wanted to know if there is any library in C available for calculating the Font Metrics (Basically i wanted to know the width of a string of Particular Font). Q开发者_JAVA技巧T has QFontMetrics. Is there any way I can get similar data in C.
I wouldn't say just use FreeType, unless you are on a system that uses X as the graphics display. If you are on Windows, use the Windows API to get font metrics information and on Mac use whatever Cocoa provides.
It might also help if you told us what you are trying to do.
EDIT: Since the output of your library is intended to be consumed by a particular GUI app, you will probably want to use the same GUI library to get the font metrics information as the app is using. Even better would be to have the app provide metrics information to the library, or a callback method that can provide that information. Then the library doesn't even have to know how the font metrics were derived, reducing an unnecessary dependency. This also means that you can use Qt (C++) in your GUI app, but still write your library in C and not have to figure out a way to call C++ from C, which is very difficult, especially if you are trying to make it cross-platform.
C is (just) a programming language. By design C has no embedded functions at all, not even for File I/O.
So you will have to indicate what Graphics/GUI platform you are using.
You can use freetype2 : http://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Glyph_Metrics
Check out FreeType: http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
精彩评论