From dc3a642d5f48fd637ed27ed259ba6a8afa94979b Mon Sep 17 00:00:00 2001 From: gal kahana Date: Fri, 31 May 2024 17:47:33 +0300 Subject: [PATCH 1/4] avoiding dual hex encoding for TJ command --- PDFWriter/AbstractContentContext.cpp | 8 ++++---- PDFWriterTesting/UnicodeTextUsage.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/PDFWriter/AbstractContentContext.cpp b/PDFWriter/AbstractContentContext.cpp index 4d62f407..5482c2ad 100644 --- a/PDFWriter/AbstractContentContext.cpp +++ b/PDFWriter/AbstractContentContext.cpp @@ -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()); } @@ -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(); diff --git a/PDFWriterTesting/UnicodeTextUsage.cpp b/PDFWriterTesting/UnicodeTextUsage.cpp index 1798415a..a259674d 100644 --- a/PDFWriterTesting/UnicodeTextUsage.cpp +++ b/PDFWriterTesting/UnicodeTextUsage.cpp @@ -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(); From 2799b38865be3a26f624cb0d43a7db15da5dadd4 Mon Sep 17 00:00:00 2001 From: gal kahana Date: Fri, 31 May 2024 18:10:47 +0300 Subject: [PATCH 2/4] ci seems to still include PDFWriterTesting as a file..lets try newer method --- PDFWriterTesting/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PDFWriterTesting/CMakeLists.txt b/PDFWriterTesting/CMakeLists.txt index af6190a4..96c8eee5 100644 --- a/PDFWriterTesting/CMakeLists.txt +++ b/PDFWriterTesting/CMakeLists.txt @@ -100,7 +100,7 @@ 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_ITEM TestsToRun PDFWriterTesting.cpp) 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) From 4dec0b27d4be6e17e73f25792247d7214371325e Mon Sep 17 00:00:00 2001 From: gal kahana Date: Fri, 31 May 2024 18:15:45 +0300 Subject: [PATCH 3/4] lets debug this --- PDFWriterTesting/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PDFWriterTesting/CMakeLists.txt b/PDFWriterTesting/CMakeLists.txt index 96c8eee5..5abe3ed5 100644 --- a/PDFWriterTesting/CMakeLists.txt +++ b/PDFWriterTesting/CMakeLists.txt @@ -101,6 +101,9 @@ endif(APPLE) # Add all the ADD_TEST for each test (reusing the create_test_sourcelist list minus the generated executable) set (TestsToRun ${Tests}) list(REMOVE_ITEM TestsToRun PDFWriterTesting.cpp) + +message("${TestsToRun}") + 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) From 49029ff70d9552e52929d557accd20a5184530f7 Mon Sep 17 00:00:00 2001 From: gal kahana Date: Fri, 31 May 2024 18:24:30 +0300 Subject: [PATCH 4/4] use index instead of file name. seems like CI started putting there a full path --- PDFWriterTesting/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PDFWriterTesting/CMakeLists.txt b/PDFWriterTesting/CMakeLists.txt index 5abe3ed5..f082ad69 100644 --- a/PDFWriterTesting/CMakeLists.txt +++ b/PDFWriterTesting/CMakeLists.txt @@ -100,9 +100,7 @@ endif(APPLE) # Add all the ADD_TEST for each test (reusing the create_test_sourcelist list minus the generated executable) set (TestsToRun ${Tests}) -list(REMOVE_ITEM TestsToRun PDFWriterTesting.cpp) - -message("${TestsToRun}") +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)