I really appreciate the help with this, thanks very much.  I realize you're
probably very busy.

Unfortunately your code snipped produced the same result.  The GetGlyphID
function returned 0 again so I placed some messages in the source code to
see what was going on.

As the PdfFontMetrics object doesn't contain a definition for GetGlyphID
(I'm assuming that this is because it's only an abstract class), the
PdfFontMetricsObject::GetGlyphID function is being called.

Here's the definition of this method: * It explains why I'm getting a
zero. *

long PdfFontMetricsObject::GetGlyphId( long ) const
{
    // TODO
cout << "PdfFontMetricsObject_GetGlyphID Returning" << endl;
    return 0; // OC 13.08.2010 BugFix: Avoid microsoft compiler error
}

My coding skills aren't as advanced as any of yours so I'm not sure I
understand what the reason is for this?  I'm assuming that it's yet to be
completed.

On the other hand, my program could be referencing this method instead of
the method contained in PdfFontMetricsFreetype because of something I've
done wrong.

Domonik ... The code I posted wasn't just some snipped.  It was a small
functioning (or malfunctioning) program I wrote to highlight a point.

On Tue, Oct 20, 2015 at 1:49 PM, Svetlana Watkins <
svetlana.watk...@gmail.com> wrote:

> I am having trouble getting the PdfFontMetrics::GetGlyphID(long lunicode)
> function to work.  I have pasted some very simplified code below.  For the
> current font some functions are working as shown below.  For example I can
> successfully get the Char Width and Font Size for each character but for
> some reason not the Glyph ID.  I am using the latest version on the Podofo
> website 0.9.3 but am having trouble with the subversion link (i'm using SV
> Tortoise to download the files.  Could it be that this issue has already
> been fixed with a patch that is only incorporated in the latest SVN version?
>
> Could someone please test my code below and maybe indicate what I have
> done wrong here?   If you look down to the inline comment
> "// NOW ATTEMPT TO EXTRACT GLYPH INFORMATION" just below that is where I
> have applied the GetGlyphID method.   Thanks
>
>
>
>
> #include <iostream>
> #include <string>
> #include <cstdlib>
> #include <podofo/podofo.h>
> #include <stack>
>
>
> using namespace PoDoFo;
> using namespace std;
>
>
> PdfMemDocument doc;
> int page_count;
> PdfPage *page;
>
> EPdfContentsType type;
> PdfVariant var;
> const char* token;
>
> PdfFont *Font;
> const PdfFontMetrics *met;
>
> PdfArray pArray; // for extracting text under TJ operator
> int size_of_array;
> string TJ_string;
>
> stack<PdfVariant> PdfStack;
>
> // THE PURPOSE OF THIS SMALL PROGRAM IS TO SHOW HOW I AM EXTRACTING THE
> GLYPH ID.
> long GlyphID;
>
>
> int main(int argc, char **argv)
> {
> try{
>
> doc.Load(argv[1]);
> page_count = doc.GetPageCount();
>
> for(int i = 0; i < page_count;i++)
> {
>     page = doc.GetPage(i);
>     PdfContentsTokenizer tokenizer(page); // tokenize page
>
>
>
> while(tokenizer.ReadNext(type,token,var))
> {
>
>     if(type==ePdfContentsType_Keyword)
>     {
>         string keyword;
>         keyword = token;
>
>        if(keyword == "Tf")
>        {
>
>            PdfStack.pop(); //pop the font size off the stack.
>            PdfName name_of_font = PdfStack.top().GetName();
>            PdfObject *ofont =
> page->GetFromResources(PdfName("Font"),name_of_font);
>            Font = doc.GetFont(ofont);
>            met = Font->GetFontMetrics(); // get the font metrics for
> current font.
>            //met is global.
>        }
>
>        if(keyword == "TJ")
>         {
>
>             pArray = PdfStack.top().GetArray();
>             PdfStack.pop();
>             size_of_array = pArray.GetSize();
>
>             for(int x = 0; x < size_of_array; x++)
>             {
>                 if(pArray[x].IsHexString()|| pArray[x].IsString())
>                 {
>                     TJ_string = pArray[x].GetString().GetString();
>
>                     // Now to test the font metrics.
>                    for (int s = 0; s < TJ_string.length(); s++)
>                     {
>                         unsigned char individual_character = TJ_string[s];
>
>                     //THE BELOW CALL TO CURRENT FONT DATA WORKS FINE
>                     cout << "Font Size is: " << met->GetFontSize() << endl;
>                     cout << "Character Width is: " <<
> met->CharWidth(individual_character) << endl;
>
>                     // NOW ATTEMPT TO EXTRACT GLYPH INFORMATION
>                     GlyphID = met->GetGlyphId((long)individual_character);
>                     cout << "************************* THE GLYPH ID IS: "
> << GlyphID << endl;
>
>
>                     }
>
>                 }
>             }
>
>
>         }
>
>
>     }
>     else if(type==ePdfContentsType_Variant)
>     {
>         PdfStack.push(var);
>     }
>
>
> }
>
> }
> }
> catch(PdfError &err)
> {
>     cout << "The Error is: " << err.what() << endl;
> }
>
>
> }
>
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to