issue-#96 Rendering unicode strings

issue-#96 Rendering unicode strings

Postby Ivan Denisov » Mon Jan 18, 2016 4:43 pm

http://redmine.blackboxframework.org/issues/96

I had tried to optimize output of Cyrillic text and found that all the texts go to HostFonts.StringWidth letter by letter. This makes the output slow and not accurate.

During the text output the GatherString procedure from TextSetters extensively used. So I am thinking that it is the location of problem.
Code: Select all
   PROCEDURE GatherString (rd: StdReader);
      VAR i, len: INTEGER; ch: CHAR;
   BEGIN
      i := 1; len := LEN(rd.string) - 1; ch := rd.r.char;
      WHILE (i < len)
         & (rd.r.view = NIL) & (rd.r.attr = rd.attr)
         & (    (" " < ch) & (ch <= "~") & (ch # "-")
            OR  (ch = digitspace)
            OR  (ch >= nbspace) & (ch < 100X) & (ch # softhyphen)
            )
      DO   (* rd.r.char > " " => ~rd.eot *)
         rd.string[i] := ch; INC(i);
         rd.eot := rd.r.eot;
         rd.r.Read; ch := rd.r.char; INC(rd.pos)
      END;
      rd.string[i] := 0X; rd.setterOpts := {wordJoin};
      IF i = 1 THEN
         IF WordPart(rd.string[0], 0X) THEN INCL(rd.setterOpts, wordPart) END
      END;
      rd.w := rd.attr.font.StringWidth(rd.string); rd.endW := rd.w
   END GatherString;
You can see here, that any Unicode letter will raise the "exception" call (IF i = 1 THEN).

Code: Select all
Oleg N. Cher has found, that replacing the "~" to 0FFFFX
& (    (" " < ch) & (ch <= 0FFFFX) & (ch # "-")
let words to come to HostFonts.StringWidth, however this is temporary solution.

The WordPart procedure should check for such case, but somehow algorithm is broken now.
Ivan Denisov
 
Posts: 1692
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#96 Rendering unicode strings

Postby Zinn » Tue Feb 02, 2016 5:26 pm

I can't see any change in the save set. So what would you like to do?
- Helmut
Zinn
 
Posts: 470
Joined: Tue Mar 25, 2014 5:56 pm
Location: Frankfurt am Main

Re: issue-#96 Rendering unicode strings

Postby Ivan Denisov » Tue Feb 02, 2016 5:48 pm

Yesterday with Oleg N. Cher. we had found the solution!
We should add one string, please, take a look on this diff
http://redmine.blackboxframework.org/pr ... 73062d3201

This is test version:
http://blackboxframework.org/unstable/i ... a1.415.zip

I also prepared DevProfiler test. I opened big document with Russian text and scrolled it from top to bottom and then back to the top.
I had started profiler before scrolling and stopped after. Visually after the fix text moving much faster and smoother.
There is the result of profiler, where you can see that "picture" is changing drastically.

compare.png
compare.png (44.79 KiB) Viewed 3274 times


Reader.ReadPrevView is also an bottleneck, however I do not know how to fix this. And it is not related to this issue-#96.
Ivan Denisov
 
Posts: 1692
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: issue-#96 Rendering unicode strings

Postby Josef Templ » Wed Feb 03, 2016 8:51 am

looks good to me. I didn't test it, though.
Hopefully, it does not affect the word and line breaking behavior.

TextSetters docu: we should remove sString because it does no longer exist.

- Josef
User avatar
Josef Templ
 
Posts: 1990
Joined: Tue Sep 17, 2013 6:50 am


Return to Resolved (Bugs)

Who is online

Users browsing this forum: No registered users and 2 guests

cron