Results 1 to 17 of 17

Thread: All font library has same glyph index for glyph ??

  1. #1
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Unhappy Glyph index are always fixed in font library ??

    Hi all,
    I have some issue in the internationalization of qte v3.3.8.There are various problem in devanagari (indian language) and those issues are fixed by me using hard coded glyph index of arial font library. My doubt is , if font library changed to some other library then my fix will work or not.
    Please confirm me, whether glyph index in all available font library will be same ??????



    Regards,
    Gaurav

  2. #2
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Thumbs down All font library has same glyph index for glyph ??

    Hi all,
    I have some issue in the internationalization of qte v3.3.8.There are various problem in devanagari (indian language) and those issues are fixed by me using hard coded glyph index of arial font library. My doubt is , if font library changed to some other library then my fix will work or not.
    Please confirm me, whether glyph index in all available font library will be same ??????



    Regards,
    Gaurav

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Glyph index are always fixed in font library ??

    From the FreeType documentation:
    • A font file contains a set of glyphs; each one can be stored as a bitmap, a vector representation or any other scheme (most scalable formats use a combination of mathematical representation and control data/programs). These glyphs can be stored in any order in the font file, and is typically accessed through a simple glyph index.


    • The font file contains one or more tables, called a character map (or charmap in short), which is used to convert character codes for a given encoding (e.g. ASCII, Unicode, DBCS, Big5, etc..) into glyph indices relative to the font file. A single font face may contain several charmaps. For example, most TrueType fonts contain an Apple-specific charmap as well as a Unicode charmap, which makes them usable on both Mac and Windows platforms.
    Therefore the charmap is used to achieve the glyph index for a certain character code(depending on the encoding).
    Why don't you make use of the charmap to map characters to indexes, instead of hardcoding them?

    Regards

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: All font library has same glyph index for glyph ??

    See your other post.
    You shouldn't have double posted .
    Someone would have moved your post in here, eventually...

    http://www.qtcentre.org/forum/f-qt-p...ary--8344.html

    Regards
    Last edited by marcel; 1st August 2007 at 11:08.

  5. #5
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Default Re: Glyph index are always fixed in font library ??

    Thanks for your valuable suggestion .
    but can you plz show me some way to get the CHARMAP from GLYPH INDEX

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Glyph index are always fixed in font library ??

    Well, if you use FreeType, then it's in the API.
    But it is not that easy.

    First you have to get familiar with the general API.
    I suggest reading this( won't take more than 10 minutes), especially paragraph 6.
    http://freetype.sourceforge.net/free...ial/step1.html

    If you have questions after reading that, then please ask them.

    BTW, what do you use now to get the glyph index and faces?

    Regards
    Last edited by marcel; 1st August 2007 at 12:40.

  7. #7
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Default Re: Glyph index are always fixed in font library ??

    Thanks again,
    but now,

    FT_Get_Glyph_Name( FT_Face face,
    FT_UInt glyph_index,
    FT_Pointer buffer,
    FT_UInt buffer_max )


    i am trying to use this API,
    Is it a correct API according to our problem

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Glyph index are always fixed in font library ??

    I don't think it is OK to use only that.
    I assume that you have the (unicode???) charcodes for you characters.

    So you could use:
    Qt Code:
    1. glyph_index = FT_Get_Char_Index( face, charcode );
    To copy to clipboard, switch view to plain text mode 
    This is how you get the glyph index for a charcode. Next you can use this index( instead of the hardcoded one you were using before).

    For FT library and face initialization please refer to the link in my previous post.
    Using that method for initializing the face from a font file is more generic, since you can change the font file.

    Also, you should consider all the error codes. For example, for a font file, there might not exists a face for a certain char code, so the index will be invalid. You should handle these errors( perhaps use another font file ?? ).

    EDIT: Forgot the link http://freetype.sourceforge.net/free...ial/step1.html

    Regards
    Last edited by marcel; 1st August 2007 at 12:40.

  9. #9
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Default Re: Glyph index are always fixed in font library ??

    FT_Get_Glyph_Name( FT_Face face,
    FT_UInt glyph_index,
    FT_Pointer buffer,
    FT_UInt buffer_max )

    we tried to use this API but it is giving an error code as 6.
    and we are unable to depict the meaning of it.
    can u plz try to help in this.

    and one more thing
    Where can we find out the place in Qt code where characters are mapped with charcodes (unicodes) of the characters ,actually, we are intended to use some characters whose unicode are not known to us.
    Last edited by Gaurav K SIngh; 1st August 2007 at 14:23.

  10. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Glyph index are always fixed in font library ??

    An error is returned if the face doesn't provide glyph names or if the glyph index is invalid. In all cases of failure, the first byte of ‘buffer’ is set to 0 to indicate an empty name.
    The glyph name is truncated to fit within the buffer if it is too long. The returned string is always zero-terminated.
    This function is not compiled within the library if the config macro ‘FT_CONFIG_OPTION_NO_GLYPH_NAMES’ is defined in ‘include/freetype/config/ftoptions.h’.
    Only in these situations an error is returned.

    What does FT_HAS_GLYPH_NAMES(face) returns for that face?
    Make sure the face is valid as well as the index!


    Regards

  11. #11
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Exclamation Re: Glyph index are always fixed in font library ??

    Please have a look on code, In case of FT_HAS_GLYPH_NAMES(myface) return 0.

    QGlyph render(glyph_t g)
    {
    FT_UInt glyph_index = 1434; // index for 0x0938 (charmap)
    FT_Pointer buffer;
    FT_UInt buffer_max=2;

    QGlyph result;

    FT_Error err;

    err= FT_HAS_GLYPH_NAMES(myface);
    qWarning("Face is failed %x",err);

    buffer = new FT_Pointer[buffer_max];
    err = FT_Get_Glyph_Name(myface,glyph_index,buffer,buffer _max);
    if(err)
    qFatal("Unable to get glyph name %x",err); // err is coming as 6
    else
    qFatal("glyph name %x",(QChar*)buffer);

    since i am getting 0 in FT_HAS_GLYPH_NAMES(face) problem of invalid parameter is coming.How to avoid this problem?? Means what need to be done to return true from
    FT_HAS_GLYPH_NAMES(face). Please explain to me . I am new to freetype....

    Thanks in advance.
    Last edited by Gaurav K SIngh; 1st August 2007 at 15:27.

  12. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: All font library has same glyph index for glyph ??

    FT_HAS_GLYPH_NAMES returns 1 when no error occurs.

    How do you construct the face?

    I still don't understand what are you trying to do.
    I thought that you have the charcodes and you need the glyph indexes for them

    Regards

  13. #13
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: All font library has same glyph index for glyph ??

    Do you instantiate the library and create the face in a similar manner?
    Qt Code:
    1. FT_Library library;
    2. FT_Face face;
    3. error = FT_Init_FreeType( &library );
    4. error = FT_New_Face( library, "/usr/share/fonts/truetype/arial.ttf", 0, &face );
    To copy to clipboard, switch view to plain text mode 


    Regards

  14. #14
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Exclamation Re: All font library has same glyph index for glyph ??

    Thanks for prompt reply.
    No i have glyph indexes not charmap or unicode.thats why i want to use the FT_Get_Glyph_Name to get the charmap.

    The face will construct like this ,

    class QRenderedFontFT : public QRenderedFont {
    public:
    QRenderedFontFT(QDiskFont* f, const QFontDef &d) :
    QRenderedFont(f,d)
    {
    QDiskFontFT *df = (QDiskFontFT*)(f->p);
    myface=df->face; // here FT_Face myface; which is private member of this class.

  15. #15
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: All font library has same glyph index for glyph ??

    But FT-Get_Glyph_Name returns only the glyph name.

    I thought the point was that you had some characters and you wanted to dynamically achieve their glyph indexes for a certain font file.

    I see now that you still use hardcoded indexes and want to get some glyph names. What would you do with those.

    As for the charmap, you don't need direct access to it.
    A charmap is actually a lookup table that translates, let's say a unicode char code to a glyph index in the current face.

    Regards

  16. #16
    Join Date
    Jun 2007
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt/Embedded

    Exclamation Re: All font library has same glyph index for glyph ??

    Now i got it FT_Get_Glyph_Name also won't help me. Earlier i thought FT_Get_Glyph_Name will give me the charmap for passed glyph index.which is not the
    case, am i correct ????

    See my problem is like this,
    In devanagairi language many glyphs are not showing and i know only glyph indexs for those glyphs to fix issue. I does not have charmap for those glyph index.
    Let's say char map 0x0938 return glyph index 1434 and i want to do reverse engineering to get charmap from given glyph index.
    I needed these for special combining characters,which is not available in Qte v 3.3.6.
    Can you help out to get charmap from glyph index. or provide any mapping table for charmap and glyph index.

    Thanks ..........

  17. #17
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: All font library has same glyph index for glyph ??

    I am afraid you cannot do that.
    Perhaps only with low-level access to the charmap table. But I am not sure since I never heard something like that.

    Anyway, FYI, to access the charmap you can use: face->num_charmaps and face->charmaps. It is an array of FT_CharMap structures.

    Regards

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.