Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoiding dual hex encoding for TJ command #254

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions PDFWriter/AbstractContentContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,6 @@ EStatusCode AbstractContentContext::WriteTextCommandWithDirectGlyphSelection(con
stringStream.Write((const Byte*)formattingBuffer, 1);
formattingBuffer[0] = (*it) & 0x00ff;
stringStream.Write((const Byte*)formattingBuffer, 1);
//SAFE_SPRINTF_2(formattingBuffer,5,"%02x%02x",((*it)>>8) & 0x00ff,(*it) & 0x00ff);
//stringStream.Write((const Byte*)formattingBuffer,4);
}
inTextCommand->WriteHexStringCommand(stringStream.ToString());
}
Expand Down Expand Up @@ -1246,8 +1244,10 @@ EStatusCode AbstractContentContext::TJ(const GlyphUnicodeMappingListOrDoubleList
{
for(itEncoded = itEncodedList->begin();itEncoded!= itEncodedList->end();++itEncoded)
{
SAFE_SPRINTF_2(formattingBuffer,5,"%02x%02x",((*itEncoded)>>8) & 0x00ff,(*itEncoded) & 0x00ff);
stringStream.Write((const Byte*)formattingBuffer,4);
formattingBuffer[0] = ((*itEncoded) >> 8) & 0x00ff;
stringStream.Write((const Byte*)formattingBuffer, 1);
formattingBuffer[0] = (*itEncoded) & 0x00ff;
stringStream.Write((const Byte*)formattingBuffer, 1);
}
stringOrDoubleList.push_back(StringOrDouble(stringStream.ToString()));
stringStream.Reset();
Expand Down
3 changes: 2 additions & 1 deletion PDFWriterTesting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ endif(APPLE)

# Add all the ADD_TEST for each test (reusing the create_test_sourcelist list minus the generated executable)
set (TestsToRun ${Tests})
remove (TestsToRun PDFWriterTesting.cpp)
list(REMOVE_AT TestsToRun 0) # removing first item which is PDFWriterTesting. started getting a full path for it, so moved to REMOVE_AT instead of REMOVE_ITEM with the file name

foreach (test ${TestsToRun})
get_filename_component (TName ${test} NAME_WE)
add_test (NAME ${TName} COMMAND PDFWriterTesting ${TName} ${CMAKE_CURRENT_SOURCE_DIR}/Materials ${CMAKE_BINARY_DIR}/Testing/Output)
Expand Down
14 changes: 13 additions & 1 deletion PDFWriterTesting/UnicodeTextUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,19 @@ int UnicodeTextUsage(int argc, char* argv[])

EStatusCode encodingStatus = contentContext->Tj("hello \xD7\x92");
if (encodingStatus != PDFHummus::eSuccess)
cout << "Could not find some of the glyphs for this font";
cout << "Could not find some of the glyphs for this font Tj";

contentContext->Tm(30, 0, 0, 30, 78.4252, 562.8997);
StringOrDoubleList textAndPos;

textAndPos.push_back(StringOrDouble("hell"));
textAndPos.push_back(-50*30);
textAndPos.push_back(StringOrDouble("o \xD7\x92"));

encodingStatus = contentContext->TJ(textAndPos);
if (encodingStatus != PDFHummus::eSuccess)
cout << "Could not find some of the glyphs for this font using TJ";


// continue even if failed...want to see how it looks like
contentContext->ET();
Expand Down
Loading