Click here to Skip to main content
15,899,556 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: how do you create a gamelogfile in c using program secure shell Pin
David Crow25-Oct-15 15:12
David Crow25-Oct-15 15:12 
AnswerRe: how do you create a gamelogfile in c using program secure shell Pin
Member 1208455925-Oct-15 15:52
Member 1208455925-Oct-15 15:52 
GeneralRe: how do you create a gamelogfile in c using program secure shell Pin
John Torjo26-Oct-15 19:53
professionalJohn Torjo26-Oct-15 19:53 
GeneralRe: how do you create a gamelogfile in c using program secure shell Pin
Richard MacCutchan25-Oct-15 22:20
mveRichard MacCutchan25-Oct-15 22:20 
GeneralGuidelines to code and create a service account to enable/disable wireless ? Pin
namerg22-Oct-15 9:01
namerg22-Oct-15 9:01 
SuggestionRe: Guidelines to code and create a service account to enable/disable wireless ? Pin
David Crow22-Oct-15 10:51
David Crow22-Oct-15 10:51 
GeneralRe: Guidelines to code and create a service account to enable/disable wireless ? Pin
namerg22-Oct-15 11:47
namerg22-Oct-15 11:47 
QuestionPodofo Pdf Library GetGlyphID? Pin
Svetlana Watkins21-Oct-15 5:59
Svetlana Watkins21-Oct-15 5:59 
I'm not sure if I can ask this here because it is for an open source library called Podofo. I'm asked this on their mailing lists but it could be some time before someone responds. If this is the wrong place to ask this question then please let me know and I'll just remove it. I was hoping that maybe someone else out there uses this library and has some experience in dealing with this problem.

The function PdfFontMetrics::GetGlyphID should return the Glyph ID for a given character represented by it's unicode codepoint (as a long).

To make things easier I have written a small program greatly simplifying and hopefully clarifying my problem. I hope I haven't over simplified things but the PdfFontMetrics object seems to work in some case but not when looking for the Glyph ID. This is a small command line program. For now, it's whole purpose is to find the Glyph ID for each character handed to the GetGlyphID function. There are some other output messages in there to prove that the PdfFont has been loaded.

This library uses Freetype2 as a dependency and when using the GetGlyphID function it eventually calls the FT_Get_Char_Index( FontFace(this is preloaded), Unicode(unicode value codepoint) ) which is a Freetype function as part of it's API. One of the fonts, represented as Font Name: LNCKCK+TimesNewRomanPSMT represents the one of the preloaded font names my program searches for when seeking the Glyph ID. I'm assuming that this isn't found because the GetGlyphID function is telling me that it can't find the Glyph ID by returning Zero. It is highly likely that there is some problem with the font name and thus the glyph search ends early.

Here's the code. Please see the comments below where I have extracted the TJ array and attempt to find the Glyph ID for individual characters. The line commented with
"// NOW ATTEMPT TO EXTRACT GLYPH INFORMATION" is where I try to get the Glyph ID. I just can't see where I'm going wrong. Can anyone help? 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;
}


}

QuestionI Want to Know about dangling else , Territory operators and Logical operator in switch in c++ Please Give me Articles that Help me ! am learning this first time Pin
Member 1203224018-Oct-15 7:28
Member 1203224018-Oct-15 7:28 
AnswerRe: I Want to Know about dangling else , Territory operators and Logical operator in switch in c++ Please Give me Articles that Help me ! am learning this first time Pin
Richard MacCutchan18-Oct-15 7:31
mveRichard MacCutchan18-Oct-15 7:31 
AnswerRe: I Want to Know about dangling else , Territory operators and Logical operator in switch in c++ Please Give me Articles that Help me ! am learning this first time Pin
Richard MacCutchan18-Oct-15 7:32
mveRichard MacCutchan18-Oct-15 7:32 
QuestionDelete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. Pin
Member 1206640717-Oct-15 8:01
Member 1206640717-Oct-15 8:01 
AnswerRe: Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. Pin
Richard MacCutchan17-Oct-15 21:06
mveRichard MacCutchan17-Oct-15 21:06 
QuestionRe: Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. Pin
CPallini18-Oct-15 21:38
mveCPallini18-Oct-15 21:38 
QuestionRe: Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. Pin
Paul Conrad25-Oct-15 5:13
professionalPaul Conrad25-Oct-15 5:13 
QuestionPorting from MFC to QT Pin
HoanNguyen.UiT15-Oct-15 2:10
HoanNguyen.UiT15-Oct-15 2:10 
AnswerRe: Porting from MFC to QT Pin
CPallini15-Oct-15 2:14
mveCPallini15-Oct-15 2:14 
AnswerRe: Porting from MFC to QT Pin
Jochen Arndt15-Oct-15 2:30
professionalJochen Arndt15-Oct-15 2:30 
AnswerRe: Porting from MFC to QT Pin
Albert Holguin19-Oct-15 8:26
professionalAlbert Holguin19-Oct-15 8:26 
Questionget the a 2days time dif fromcurrent time. Pin
ramina sen11-Oct-15 20:21
ramina sen11-Oct-15 20:21 
AnswerRe: get the a 2days time dif fromcurrent time. Pin
Daniel Pfeffer11-Oct-15 21:07
professionalDaniel Pfeffer11-Oct-15 21:07 
AnswerRe: get the a 2days time dif fromcurrent time. Pin
Jochen Arndt11-Oct-15 21:23
professionalJochen Arndt11-Oct-15 21:23 
GeneralRe: get the a 2days time dif fromcurrent time. Pin
Peter_in_278011-Oct-15 21:31
professionalPeter_in_278011-Oct-15 21:31 
GeneralRe: get the a 2days time dif fromcurrent time. Pin
Jochen Arndt11-Oct-15 21:33
professionalJochen Arndt11-Oct-15 21:33 
AnswerRe: get the a 2days time dif fromcurrent time. Pin
CPallini11-Oct-15 21:35
mveCPallini11-Oct-15 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.