Question

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). QT has QFontMetrics. Is there any way I can get similar data in C.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top