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
using namespace PoDoFo;
using namespace std;
const char* token;
const PdfFontMetrics *met;
PdfArray pArray; // for extracting text under TJ operator
//THE PURPOSE OF THIS SMALL PROGRAM IS TO SHOW HOW I AM EXTRACTING THE GLYPH ID.
int main(int argc, char **argv)
page_count = doc.GetPageCount();
for(int i = 0; i < page_count;i++)
page = doc.GetPage(i);
PdfContentsTokenizer tokenizer(page); // tokenize page
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();
size_of_array = pArray.GetSize();
for(int x = 0; x < size_of_array; x++)
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;
cout << "The Error is: " << err.what() << endl;
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. In case there is more than one solution then find the solution that gives the largest perfect square. Assume that each integer contains five or less number of digits. The total number of integers in the given set is twenty or less.
First line will be number of test cases
The input may contain multiple test cases.
For each test case there is a single input line. The line contains the given set of integers.
For each test case there is only one output line. The line simply prints the integers to be deleted in ascending order. There are two special cases; print output for these cases as indicated below.
Case 1: No integer is to be deleted: Print 0 as output.
Case 2: All integers are to be deleted: Print all integers in ascending order.
I am a MFC developer, my mission is porting from MFC to QT application. But I can not find the easy way to porting, it's so hard and maybe i lose my mission.
Can any know how to porting from MFC to QT. Please help me.
As others have eluded, I don't think there is an "easy way" to port the code over. You'll have to basically start re-writing things and solve problems as they come up. Having written things in both MFC and Qt, you may end up doing a lot of re-design since the frameworks can vary quite a bit with some things.
If you're looking for something that may be easier to port so that it works in other platforms (i.e.Linux), WxWidgets may be an easier port.
hello everyone, i made a tic tac toe in C language, using the minimax algorithm but i have some problem when i try to play with larger matrix more than 3x3 for example 4x4 and my program go out of memory.
So i search in the net and i discover the aplpha-beta pruning that reduce the computional coast and so i can play with 4x4 matrix whiteout problems but i have not idea to implement this algorithm to my minimax.
if there is a person who want to help me i would be grateful.
sorry for my bad english but i am italian
i can post my code if you want
Without actually trying this out.... you should be able to take the pointer to the first element and load it with whatever data you want. Assuming your data matches the size of the structure, there should be no issue, be ware of data packing/memory alignment though. Read this before you get yourself into trouble.[^]
Last Visit: 31-Dec-99 19:00 Last Update: 27-Feb-21 14:48