Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
RUSSIAN_CHARSET |
Post Reply ![]() |
Author | |
AlexCasual ![]() Beginner ![]() Joined: 10 Feb 12 Location: Belarus,Minsk Status: Offline Points: 13 |
![]() ![]() ![]() ![]() ![]() Posted: 16 Feb 12 at 6:31PM |
Why when I add TrueType font with RUSSIAN_CHARSET to pdf file I can draw ENGLISH AND RUSSIAN chars? RUSSIAN_CHARSET - it's 255 chars [0x0400 - 0x4FF] or not? Please help me to understand charsets! |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi Alex!
I THINK that english always works without doing anything. If you want russian characters you have to add a charset but english always works... ;-) Cheers, Ingo |
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Alex,
charsets are translationtables. With charsets you may switch between groups of 256 glyphs. It was the first answer to allow languages with other glyphs as in english. The same code denotes in different charsets a different glyph. The next bigger step to be open for much more is unicode. To understand the concepts look into wikipedia. It is not a real (Quick)PDF-problem. Here a bad example: QP.SetOrigin(0); // Bottomleft QP.SetMeasurementUnits(1); // Millimeter // establish fonts only 1x per PDF sid := QP.AddStandardFont(4); // Helvetica for english cid := QP.AddTrueTypeFont('Czar{1251}', 0); // and for russian // output text with correct font QP.SelectFont(sid); QP.DrawText(25, 260, 'russian has own letters:'); QP.SelectFont(cid); // now change font to a russian QP.DrawText(100, 260, #$50#$72#$70#$70#$69#$68#$68); QP.SelectFont(sid); // switch back QP.DrawText(25, 250, 'and back to english'); The PDF looks not so nice, because of wrong letterspace. And in this font is (for example) no i-kratkoje (short i). Here is much more to do, it shows only a principle way. You have a lot to try to get the feeling for this. More usefull is to read over unicode and to use a unicode-font. It makes the PDF (if embedded) bigger, but is much more powerfull. So you dont need to switch between font depending on charset. There are some posts for this. Werner Edited by edvoigt - 06 Jun 12 at 9:57AM |
|
![]() |
|
AlexCasual ![]() Beginner ![]() Joined: 10 Feb 12 Location: Belarus,Minsk Status: Offline Points: 13 |
![]() ![]() ![]() ![]() ![]() |
Werner,you are right,but for me very important pdf file size....
|
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
Werner, you seem to hold some valuable experience/knowledge with encoding issues, so I hope I can extract some related help from this tread too. Working from your sample, I tried to resolve inserting Russian text into a system built for Nordic text. It has flaws when used with Polish (some letters with extra lines/diphthongs are just normal letters, but it's readable), but fail totally with Russian — that I now need to implement in this report system. The readable Russian text, is already in the template, but dynamic text elements fail — as you can see from the question marks. The first line is from testing/debugging and show the font handle ID, some Russian and the return value (success) from SelectFont that I really should not need as I use it immediately after adding it. The code for that line is; RUSTTF = QPDF.AddTrueTypeFont( "Calibri [Bold] {1251}", 0 ) RetVal = QPDF.SelectFont( RUSTTF ) 'Just for double checking RetVal = QPDF.DrawText( 5, 5, "FontID= " & RUSTTF & " Сделаны" & " " & RetVal ) I'm currently working on 7.25 locally and the on-line component is 5.11 (pre Debenu version), that both support the Russian codepage according to the documentation. Any thoughts that could help me out? ![]() |
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
I can see the Russian text in the code fails to show in the forum as well.
|
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Autodidact,
in the moment I'm very short of time. I have something to produce and I'm so fare from the goal. My first intention goes in the direction, that your font is unable for russian. Is it really the same, as for the russian readable like "podkladka" (looks nice in latin letters), which you use for the inputvalue after this? Maybe you have to switch between differents fonts/charsets depending from your text. Maybe too, that I'm here on a very wrong way... Cheers, Werner |
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
That is OK Werner, thank you for spending a little time on me anyway. I am after thoughts to follow up on, not a full solution, so any ideas are welcome - if they lead to solving the issue or not.
The top line in the image is the result of explicitly trying to use Calibri to dynamically produce Russian text in the PDF file. The text in the image that is readable Russian is set in the same font in Corel Draw and exported as a template PDF file that I need to populate with more text. |
|
Haakon 8o)
|
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Haakon,
here a dirty working entry with Calibri-Font, using unicode. It is made by Delphi 7 under XP. sid, cid: integer; Chars: widestring; // for the chars we need in Calibri k: integer; p: double; // position, because of of Charwidth-problem begin QP := TQuickPDF.Create; QP.UnlockKey({$I PDFkey.inc}); QP.SetOrigin(0); // Bottomleft QP.SetMeasurementUnits(1); // Millimeter sid := QP.AddStandardFont(4); // Helvetica for english // build a string with all needed chars for k:=$0400 to $0420 do Chars := Chars+wideChar(k); // only a first part cid := QP.AddTrueTypeSubsettedFont('Calibri', Chars, 0); // and for russian // output text with correct font QP.SelectFont(sid); QP.DrawText(25, 260, 'russian has own letters:'); QP.SelectFont(cid); // now change font to a russian p := 0; for k:=1 to Length(Chars) do begin QP.DrawText(80+p, 260, Chars[k]); p := p+ 3; // CharWidth or TextWidth return 0 - why, unknown end; // QP.DrawText(80, 260, Chars); dont work, puts all on the same position QP.SelectFont(sid); // switch back QP.DrawText(25, 250, 'and back to english'); It works, but there is something wrong. With Drawtext all glyphs go one above the other on the same position. So I used the fixed value of 3 only for this demonstration. So you get the right glyphs, but you have something to do for better quality. Cheers, Werner Edited by edvoigt - 06 Jun 12 at 9:59AM |
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
Thank you very much Werner!
After looking a bit on your code, almost taking a plunge to convert and test in PowerBasic, I decided to run tests as clean and simple as possible, in the environment it is needed to work. To my dismay, testing revealed that it did not even work with fonts that the library (7.25) reported to be capable of using the necessary charset. I had the library list the capable fonts, where Calibri is omitted, although we know it can handle Russian. The conclusion after my last testing, just now, is that early versions of the library (I have tried 5.11 and 7.25) are incapable of performing as intended/documented. After trying 8.15, I luckily/finally got the expected result — Russian output from both DrawText and DrawHTMLTextBox, without obvious kerning issues as you indicated possibly could be the next challenge to overcome. Now I just need to go through the process of having my web host update the library they installed for me years back. Meaning I have to rewrite the the old 5.11 syntax and purchase my license upgrade. |
|
Haakon 8o)
|
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Haakon,
now you understand, that I'm not too proud about my help. Because I'm unable to get a Charwidthinfo for Calibri. The value 3 mm in my loop over the string is only to show, that it works with russian output. Maybe you can get for a given fontsize (as big as possible for quality) from any other program for every glyph its width, you would have a foot in the door. This solution would be without kerning, but better than nothing. On http://www.microsoft.com/typography/FreeToolsOverview.mspx you find a lot of information, but I think it's not your intent to learn all about font-inside. Maybe there is something to do for the QPL-developers, because I have seen, that older TTF-Tools dont like Calibri.TTF. Cheers, Werner |
|
![]() |
|
edvoigt ![]() Senior Member ![]() ![]() Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
![]() ![]() ![]() ![]() ![]() |
Hi Haakon,
here is a nice helper: http://stackoverflow.com/questions/1833062/how-to-measure-the-pixel-width-of-a-digit-in-a-given-font-size-c There is fine solution for exactly determing charwidth of single chars in a given font in pixel. The trick is to build the difference between a single char ('0') and a double of it ('00'). Because in the reported width is ever a padding around, the minus is eliminating it.I would take a a very big fontsize to get for every glyph a good estimation for its pure width on this size. Then you may build your own small textoutroutine, which "knows" the charwidth. How much padding is then your choice. Happy coding, Werner Edited by edvoigt - 09 Jun 12 at 6:10PM |
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
I appreciate you taking the time never the less. Sometimes the treasure is not a solution but that someone spends their time to try helping out.
Often a thought that didn't cross my mind, can be the path to a solution. And, one day someone else find the info here of good value to them. Personally I find most of my answers by searching and reading, rather than posting a question.
|
|
Haakon 8o)
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Some further information
QPL 8.xx is now compiled with Unicode strings internally. So when you call AddTrueTypeSubsettedFont you pass in Unicode characters and then also use Unicode characters for DrawText, DrawHTMLText etc.. With QPL 7 - QP.AddTrueTypeFont('Czar{1251}', 0) would create a 255 character font using the 1251 character set and would require 1251 encoded strings to be passed to DrawText This forum doesn't display foreign characters correctly unfortunately.
Andrew. |
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
Interesting detail. I wonder what that dictates in Classic ASP. One should think; nothing, as the same variable data is passed to the browser correctly ... |
|
Haakon 8o)
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store