Results 1 to 6 of 6

Thread: using freetype library with Qt

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default using freetype library with Qt

    To render text with OpenGL, I need the FreeType library. I found out that this library is included with Qt 3rd party packages, located in :
    Qt Code:
    1. /opt/Qt5.0.1/5.0.1/Src/qtbase/src/3rdparty/freetype/include/freetype
    To copy to clipboard, switch view to plain text mode 

    To test if the library is successfully working, I ran the below code snippet:
    Qt Code:
    1. #include <ft2build.h>
    2. #include FT_FREETYPE_H
    3.  
    4. FT_Library ft;
    5.  
    6. if(FT_Init_FreeType(&ft)) {
    7. fprintf(stderr, "Could not init freetype library\n");
    8. return 1;
    9. }
    To copy to clipboard, switch view to plain text mode 

    However, I get the following errors:
    Qt Code:
    1. /usr/local/include/freetype2/freetype/freetype.h:298: error: 'FT_Pos' does not name a type
    2. /usr/local/include/freetype2/freetype/freetype.h:34: error: #include expects "FILENAME" or <FILENAME>
    3. /usr/local/include/freetype2/freetype/freetype.h:656: error: a function call cannot appear in a constant-expression
    4. .
    5. .
    6. .
    To copy to clipboard, switch view to plain text mode 

    any hints would be appreciable.

    Cheers,

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: using freetype library with Qt

    Your code is invalid and apart from that you're not including proper files thus it does not work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: using freetype library with Qt

    Quote Originally Posted by wysota View Post
    Your code is invalid and apart from that you're not including proper files thus it does not work.
    Before reading your code, I thought the error was because headers are not included from fresh libraries installed, but rather it includes QT freetype headers. If I want to tell qt not to read its own freetype and read the one installed on the system, how can I do that?

    about your post, it is the first time I am dealing with freetype, how can I get a valid code? and what are the proper headers I should add? (by the way I followed this tutorial for the above code file:///home/saman/Desktop/OpenGL%20...en%20world.htm)

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: using freetype library with Qt

    Quote Originally Posted by saman_artorious View Post
    it is the first time I am dealing with freetype, how can I get a valid code?
    A good place to start would be reading compiler errors and correcting them, starting with e.g. this line:
    Qt Code:
    1. #include FT_FREETYPE_H
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    saman_artorious (28th August 2013)

  6. #5
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: using freetype library with Qt

    Quote Originally Posted by wysota View Post
    A good place to start would be reading compiler errors and correcting them, starting with e.g. this line:
    Qt Code:
    1. #include FT_FREETYPE_H
    To copy to clipboard, switch view to plain text mode 
    Yes, you are right, I change the include directives with their equivalent header files as such:

    Qt Code:
    1. //#include FT_CONFIG_CONFIG_H
    2. //#include FT_SYSTEM_H
    3. //#include FT_IMAGE_H
    4.  
    5. #include "freetype2/freetype/ftsystem.h"
    6. #include "freetype2/freetype/config/ftconfig.h"
    7. #include "freetype2/freetype/freetype.h"
    To copy to clipboard, switch view to plain text mode 

    That solved my problem Wysota, thanks for your hint.
    I still have one more quetions regarding this problem, when I changed the headers to their equivalents, there are two type of header, as an example for
    //#include FT_IMAGE_H
    I can add both:
    #include "freetype2/freetype/ftimage.h"
    or simply
    #include "ftimage.h"
    I think this is because, I have this library both on Qt 3rd party and have separately installed it as well. is that correct? So, now how do I know which one is for QWt and which one is what i Installed using apt-get .

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: using freetype library with Qt

    Your question is unrelated to Qt. Please post C++ questions in the General Programming forum. If you are having trouble understanding how your compiler works, then a good place to look for information would be to read the compiler manual. Assuming you are using GCC the manual can be found on gcc.gnu.org
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 20th December 2012, 12:48
  2. Dynamic library on Mac, Library not loaded
    By grayfox in forum Newbie
    Replies: 2
    Last Post: 2nd July 2011, 02:42
  3. Replies: 2
    Last Post: 19th February 2011, 11:26
  4. Replies: 0
    Last Post: 3rd October 2010, 20:51
  5. FreeType
    By Rayven in forum General Programming
    Replies: 6
    Last Post: 3rd May 2007, 18:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.