[PB 6.10 beta 2] PdfVectorOutput() and CJK characters

Post bugreports for the Windows version here
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

[PB 6.10 beta 2] PdfVectorOutput() and CJK characters

Post by breeze4me »

In the code below, Chinese, Japanese, and Korean characters are not displayed correctly. (Viewed in MS Edge browser and SumatraPDF.)
They all appear as squares, as if they don't have fonts.

Code: Select all

LoadFont(0, "Arial", 20)

If StartVectorDrawing(PdfVectorOutput("z:\test.pdf", 595, 842))
  VectorFont(FontID(0), 25)
  MovePathCursor(20, 20)
  DrawVectorText("한글, ひらがな, カタカナ, 简体中文")
  StopVectorDrawing()
EndIf

Using certain fonts causes a "Division by zero" error on Windows 10 Korean.
However, on English Windows, it shows the same result as the above code without any errors.

Code: Select all

;"Division by zero" error in all of the fonts below.
Debug LoadFont(0, "MS Sans Serif", 20)
;Debug LoadFont(0, "맑은고딕", 20)
;Debug LoadFont(0, "굴림", 20)

If StartVectorDrawing(PdfVectorOutput("z:\test.pdf", 595, 842))
  ;Debug FontID(0)
  VectorFont(FontID(0), 25)
  MovePathCursor(20, 20)
  DrawVectorText("한글, ひらがな, カタカナ, 简体中文")    ; Division by zero.
  StopVectorDrawing()
EndIf
Some fonts generate a very small empty file(705 bytes) with no errors. This issue also does not occur on English Windows.
(There is some binary content in the PDF file, but when the document is opened in Edge browser or something, no characters display.)

Code: Select all

Debug LoadFont(0, "굴림체", 20)
;Debug LoadFont(0, "돋움체", 20)

If StartVectorDrawing(PdfVectorOutput("z:\test.pdf", 595, 842))
  ;Debug FontID(0)
  VectorFont(FontID(0), 25)
  MovePathCursor(20, 20)
  DrawVectorText("한글, ひらがな, カタカナ, 简体中文")
  StopVectorDrawing()
EndIf
%PDF-1.3
%����
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
3 0 obj
<<
/Producer (Haru Free PDF Library 2.4.4)
>>
endobj
4 0 obj
<<
/Type /Page
/MediaBox [ 0 0 595 842 ]
/Contents 5 0 R
/Resources <<
/ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ]
>>
/Parent 2 0 R
>>
endobj
5 0 obj
<<
/Length 6 0 R
/Filter [ /FlateDecode ]
>>
stream
x�3T0 B]C aab����U���e�6P��2rL�LL--�BR�\C�� V��
endstream
endobj
6 0 obj
55
endobj
xref
0 7
0000000000 65535 f
0000000015 00000 n
0000000064 00000 n
0000000123 00000 n
0000000184 00000 n
0000000338 00000 n
0000000472 00000 n
trailer
<<
/Root 1 0 R
/Info 3 0 R
/Size 7
>>
startxref
490
%%EOF
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: [PB 6.10 beta 2] PdfVectorOutput() and CJK characters

Post by juergenkulow »

Only Incscape and LibreOffice Draw can handle the file correctly:
Image

SumatraPDF:
Image
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: [PB 6.10 beta 2] PdfVectorOutput() and CJK characters

Post by juergenkulow »

Code: Select all

; Find DrawVectorText Division by zero on korean Windows
OnErrorGoto(?ErrorHandler)
LoadFont(0, "맑은고딕", 20)

If StartVectorDrawing(PdfVectorOutput( GetTemporaryDirectory()+"test.pdf", 595, 842))
  VectorFont(FontID(0), 25)
  MovePathCursor(20, 20)
  DrawVectorText("한글, ひらがな, カタカナ, 简体中文")    ; Division by zero on korean Windows
  StopVectorDrawing()
  ; ! int3  
EndIf
End

ErrorHandler:
CompilerIf #PB_Compiler_Processor=#PB_Processor_x86
  *eip.Quad=ErrorAddress()
  *esp.Long=ErrorRegister(#PB_OnError_ESP)
  s.s="eip:"+Hex(*eip)+" "+Hex(*eip\q,#PB_Quad)+#CRLF$
  If ExamineAssembly(*eip, *eip+8)
    If NextInstruction()
      s+InstructionString() + #CRLF$
    EndIf 
  EndIf
  s+"eax:"+Hex(ErrorRegister(#PB_OnError_EAX),#PB_Long)+
    " ebx:"+Hex(ErrorRegister(#PB_OnError_EBX),#PB_Long)+
    " ecx:"+Hex(ErrorRegister(#PB_OnError_ECX),#PB_Long)+
    " edx:"+Hex(ErrorRegister(#PB_OnError_EDX),#PB_Long)+
    " ebp:"+Hex(ErrorRegister(#PB_OnError_EBP),#PB_Long)+
    " esi:"+Hex(ErrorRegister(#PB_OnError_ESI),#PB_Long)+
    " edi:"+Hex(ErrorRegister(#PB_OnError_EDI),#PB_Long)+#CRLF$
  i=0 
  s+"Stack: "
  Repeat
    s+Hex(*esp\l,#PB_Long)+" "
    If *esp\l=0
      i+1
    Else 
      i=0 
    EndIf 
    *esp+4
  Until i>=5
CompilerElseIf #PB_Compiler_Processor=#PB_Processor_x64
  *rip.Quad=ErrorAddress()
  *rsp.Quad=ErrorRegister(#PB_OnError_RSP)
  s.s="rip:"+Hex(*rip)+" "+Hex(*rip\q,#PB_Quad)+#CRLF$
  If ExamineAssembly(*rip, *rip+8)
    If NextInstruction()
      s+InstructionString() + #CRLF$
    EndIf 
  EndIf
  s+  "rax:"+Hex(ErrorRegister(#PB_OnError_RAX),#PB_Quad)+" rbx:"+Hex(ErrorRegister(#PB_OnError_RBX),#PB_Quad)+
      " rcx:"+Hex(ErrorRegister(#PB_OnError_RCX),#PB_Quad)+" rbx:"+Hex(ErrorRegister(#PB_OnError_RDX),#PB_Quad)+
      " rbp:"+Hex(ErrorRegister(#PB_OnError_RBP),#PB_Quad)+" rsi:"+Hex(ErrorRegister(#PB_OnError_RSI),#PB_Quad)+ 
      " rdi:"+Hex(ErrorRegister(#PB_OnError_RDI),#PB_Quad)+" r8:" +Hex(ErrorRegister(#PB_OnError_R8 ),#PB_Quad)+
      " r9:" +Hex(ErrorRegister(#PB_OnError_R9 ),#PB_Quad)+" r10:"+Hex(ErrorRegister(#PB_OnError_R10),#PB_Quad)+
      " r11:"+Hex(ErrorRegister(#PB_OnError_R11),#PB_Quad)+" r12:"+Hex(ErrorRegister(#PB_OnError_R12),#PB_Quad)+
      " r13:"+Hex(ErrorRegister(#PB_OnError_R13),#PB_Quad)+" r14:"+Hex(ErrorRegister(#PB_OnError_R14),#PB_Quad)+
      " r15:"+Hex(ErrorRegister(#PB_OnError_R15),#PB_Quad)+#CRLF$
  i=0 
  s+"Stack: "
  Repeat
    s+Hex(*rsp\q,#PB_Quad)+" "
    If *rsp\q=0
      i+1
    Else 
      i=0 
    EndIf 
    *rsp+8
  Until i>=5
  
CompilerEndIf  
OpenConsole()
Print(s)
SetClipboardText(s)
Input()
End 

CompilerIf #PB_Compiler_ExecutableFormat<> #PB_Compiler_Console 
  CompilerError "Please use Console."
CompilerEndIf
CompilerIf #PB_Compiler_LineNumbering=0
  CompilerError "Please switch Compiler Option OnError on."
CompilerEndIf
CompilerIf #PB_Compiler_Debugger=1
  CompilerError "Please switch Compiler Option Start Debugger off."
CompilerEndIf
What is displayed?
breeze4me
Enthusiast
Enthusiast
Posts: 633
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: [PB 6.10 beta 2] PdfVectorOutput() and CJK characters

Post by breeze4me »

x64

Code: Select all

rip:7FF640440DB7 8B48C02A0FF3F9F7
idiv ecx
rax:0 rbx:502480 rcx:0 rbx:0 rbp:7FF64040120A rsi:0 rdi:4F8E90 r8:2 r9:11 r10:0 r11:516E80 r12:0 r13:0 r14:0 r15:0
Stack: 502480 0 14FB54 7FF640433BC5 800000000 5650A0 512790 512840 7FF600CE7818 7FF64043FD9C 5203F0 0 0 7FF6404323A5 0 5650A0 5650A0 7FF600000100 0 4896858 5203F0 5650A0 300CE7818 7FF64043E88F 5203F0 515570 1 0 14FC20 5203F0 0 7FF640420DB0 509510 515570 1 3BAF040 CE7818 515570 0 0 9315B0 7FF64041F7CC 4F92F0 515570 7FF600000001 0 515570 0 4F8E90 7FF640417CCB 4F92F0 3BAF040 1F7FFF0000CE7818 1 6C4B00CE7818 0 CE7818 0 11A FFFFFFFFA2010C9A 1 9315B0 0 3BAF040 0 25C0000 7FF64040120A 0 0 3910A70 25CEE40 7FF9B57366CC 25CEE40 0 1F80 0 0 7FF9B577F7A9 3 7FF64041A5DE 930BA0 690A1DE6 25CEE40 7FF9B57A938C 1F80 7FF9B57BA9CE 1F80 3F80 4F8E90 7FF640457AC6 0 25C24D8 4F8E90 7FF640456D22 25C23B0 0 14FE98 690A1DE6 4039000000000000 7FF640456899 930BA0 7FF6404BE0DE 4034000000000000 0 930A90 391A4D0 391A370 7FF640457E94 930A90 0 0 0 4034000000000000 7FF6404011E2 7FF6404BE0DE 4034000000000000 14 7FF600000004 0 7FF640402218 0 7FF640402291 0 0 0 0 0
x86

Code: Select all

eip:F67343 558BC02A0FF3F9F7
idiv ecx
eax:0 ebx:2D2000 ecx:0 edx:0 ebp:19FD58 esi:679398 edi:67C680
Stack: 68B590 8 0 68FB98 19FD90 F66613 68F6A8 160 19FD84 F5B417 160 19FD88 F5B588 68FCF8 19FD9C F654E1 68FB98 0 19FDB0 F6553E 68F6A8 68AE08 1 0 68AE08 68F6A8 19FDD0 F4CEAA 685C00 68AE08 1 68AE08 3BC9020 CE7818 19FDF0 F4BD2A 675338 68AE08 1 0 67C680 68AE08 19FE8C F45B49 675338 3BC9020 CE7818 1 0 7 2570000 28 19FF60 7734AF30 FD9A57D5 FFFFFFFE 19FE84 77357AED 0 77357B14 2571A70 2570000 65BF5D44 0 1C 0 0 2570000 2 0 19FE80 77315E1E 1 0 3BC9020 10A 0 F10D28 CE7818 8E012869 0 19FEFC F47BD2 F107A0 670A2769 2571A70 2571A70 0 65BF5D44 65B1067F 43F FFFFF3C0 65B1027F 19FEDC 65B5518F 65B551AB 67C680 679398 0 25716FC 2571610 19FEEC F78F2B 0 2571610 19FEF8 F79AEC F106F8 19FF14 19FF20 F78C43 F107A0 FD006A 0 0 0 0 F106F8 F3119B F31173 FD006A F321DB 1 679398 67C680 34C84218 F32263 F32263 2D2000 0 C0000094 0 19FF3C 19F6F8 19FFCC F41DB0 342D5BE8 0 19FF80 756AFCC9 2D2000 756AFCB0 19FFDC 77337C6E 2D2000 8ABE6AA1 0 0 2D2000 C0000094 0 761327B0 1807712A 1DC4A86 0 FFFFFFFF 19F6DC 6E14569A 0 19FF8C 19F6DC FFFFFFFF 7734AF30 FD9A5C3D 0 19FFEC 77337C3E 0 0 0 0 F32263 2D2000 0 78746341 20 1 331C DC 0 20 0 14 1 7 34 17C 1 0 0 0 0 0
Post Reply