Recent

Author Topic: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....  (Read 7196 times)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #15 on: May 24, 2019, 11:37:05 pm »
For start, you must run it with three font name as parameters!
What parameters should I use in a Linux system? The program always complains whatever I feed it. Not a good demo program IMO.

Maybe a stupid question but how does the OnCompare handler help with memory consumption?
 FGlyphTable.OnCompare := @GlyphTableOnCompare;
I understand it speeds up searches because the items get ordered.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #16 on: May 25, 2019, 12:18:12 am »
What parameters should I use in a Linux system? The program always complains whatever I feed it. Not a good demo program IMO.
If you are in the correct example project, The "LazFreeTypeTest"
You can use mine one:[I'd just passed one thing as three time]
"/usr/share/fonts/TTF/DejaVuSans.ttf" "/usr/share/fonts/TTF/DejaVuSans.ttf" "/usr/share/fonts/TTF/DejaVuSans.ttf"
 
Maybe a stupid question but how does the OnCompare handler help with memory consumption?
 FGlyphTable.OnCompare := @GlyphTableOnCompare;

It's simple, As I know the AVLTree sort and makes a tree base on the difference of the added Data,
And not need to mention that the TAVLTree have not any idea about our Data/Object we trying to add.
When you set GlyphTableOnCompare, You'd just learn it how to measure them, sort them and put them the right position on the tree!
In the other hand, When the glyphs  get right position on the tree we can find them with GetGlyphs, But without GlyphTableOnCompare they(The Glyphs) are put somewhere unknown and looking inside a messed up place got you nothing.

After all, GetGlyph tries to find the right glyph inside the tree based on logic that not implemented, when it failed, tries to add it again thas it.
Code: Pascal  [Select][+][-]
  1. function TFreeTypeFont.GetGlyph(Index: integer): TFreeTypeGlyph;
  2. var
  3.   node: TAvlTreeNode;
  4.   lGlyph: TFreeTypeGlyph;
  5. begin
  6.   if not CheckInstance then
  7.   begin
  8.     result := nil;
  9.     exit;
  10.   end;
  11.   node := FindGlyphNode(Index);//Tries to find glyph base on index, But it failes cause on glyphs compared and sorted by FontFaceName!
  12.   if node = nil then
  13.   begin
  14.     lGlyph := TFreeTypeGlyph.Create(self, Index);//So It will add more times as ever as program darw a glyph!
  15.     FGlyphTable.Add(lGlyph);
  16.   end else
  17.     lGlyph := TFreeTypeGlyph(node.Data);
  18.   result := lGlyph;
  19. end;
  20.  
« Last Edit: May 25, 2019, 12:59:47 am by ϻαϻɾΣɀО »
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #17 on: May 25, 2019, 12:27:03 am »
Just for note,  AvlTree.OnCompare is same as TStringList custom sort.
That means you must identify how the List/Holder/Tree/Collection/HashList or everything has this handler, Must face to and measure what you added to it.
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #18 on: May 25, 2019, 12:33:56 am »
Thanks for finding that bug. That's probably my mistake as I wrote this unit.

I remember reading that the AVL tree was buggy so that it was the reason it was acting strangely. Well at least there was some error on my side.

Note: I don't have access to the code so please file a bug report.

Sorry for the mistake, There are some compare methods, Id just tries to trace the code when it wants to add glyphs, Id just finds "TFreeTypeFontCollection.CompareFamilyName", But that is wrong!
What happening is a huge mistake! The code sort the glyphs by the font name, And when tries to find them, Searching them by Index!
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #19 on: May 25, 2019, 12:50:29 am »
Hey guys, after all of these replies,
There is the first public screenshot of the fpGUI wit BGRABitmap, Transparent roundrected controls, BidiMode enabled, RTL, And Arabic/Persian Font corrections with the minibidi! And platform independent rendering widget(Antialiased lines, Antialiased roundrect) with simple API instead of AggPass!
The font rendering is awesome, Special thanks to developers of LazFreeType and BGRABitmap.
I will turn it(the fpGUI) to a modern look like Applicable and operational widgetset.
Just not judge me with it, Its first tries  8).
I did these all with native canvas but the result was not acceptable for me!

A BGRAfpGUICanvas implemented, and a new theme that read Theme data from a file, It will read CSS (My Next challenge).
The FPC world needs something like Swing like Java or Qt for GUI.
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #20 on: May 25, 2019, 01:07:33 am »
OK - please note this in the bug report.

Reported as https://bugs.freepascal.org/view.php?id=35627.

You cannot expect a developer to install any third party libraries in order to see a bug. That's the background of Juha's request. Always provide a demo (as simple as possible) to show the bug.
I don't expect them to do that!
Just look at the Lazarus examples folder "lazfreetype", The sample project provided by the Lazarus!
I have SVN one, And I don't know if it's with your installation vesion.
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #22 on: May 25, 2019, 02:13:28 pm »
Reported as https://bugs.freepascal.org/view.php?id=35627.
Please test.
Testd, And problem solved. Thanks.

But what did you mean by "Widgetset should not be CustomDrawn but it cannot be removed for some reason."
As I know I'm just developing theme/style or whatever fpGUI call it the way they did it. Is that what you mentioned "Widgetset"?
"cannot be removed for some reason" What?
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #23 on: May 25, 2019, 09:10:06 pm »
Hi ϻαϻɾΣɀО

Beautiful work you did there.  :)

Happy you like the font rendering of LazFreeType and BGRABitmap.

I am wondering for what purpose you need minibidi as bidi is now handled by BGRABitmap?

EDIT: Oh I think I know. TFreeTypeFont does not reorder the glyphs.

I wonder one thing, as it renders glyph by glyph, how do you get the ligatures?
« Last Edit: May 25, 2019, 11:08:46 pm by circular »
Conscience is the debugger of the mind

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #24 on: May 25, 2019, 09:43:41 pm »
But what did you mean by "Widgetset should not be CustomDrawn but it cannot be removed for some reason."
As I know I'm just developing theme/style or whatever fpGUI call it the way they did it. Is that what you mentioned "Widgetset"?
The issue was about LazUtils package which has nothing to do with LCL or its widgetsets.
As you know LCL binds into one native widgetset at a time. "CustomDrawn" is one of those widgetsets, maintained by Felipe, but unrelated to this FreeType font issue.
fpGUI is an external GUI library unrelated to LCL, although it has a beta-state widgetset binding for LCL.
Thus, widgetset in the bug report should have been empty, not CustomDrawn.

Quote
"cannot be removed for some reason" What?
It cannot be removed from the bug report. There is no way to deselect it.
Maybe this is due to the updated Mantis version configuration, I don't know.
« Last Edit: May 25, 2019, 09:48:42 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #25 on: May 26, 2019, 07:40:20 pm »
Beautiful work you did there.  :)
Thakns Alot.

Happy you like the font rendering of LazFreeType and BGRABitmap.
It's my pleasure.

I am wondering for what purpose you need minibidi as bidi is now handled by BGRABitmap?
I read that code, It seems too heavy, I like what the minibidi did, Light and applicable.
But I have got a plan to speed up that, All of Shapetaypes will be cached into memory, About 192KB of ram instead of a quick search of shapetype for every charachter!

How do you get the ligatures?
Thats about minibidi, he "Zaher Dirkey" did it but it's not complete yet, I will do it.

Hah I have a long long todo list  :o, But that's so lovely 8-)
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

circular

  • Hero Member
  • *****
  • Posts: 4196
    • Personal webpage
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #26 on: May 27, 2019, 12:23:07 pm »
Ok.

So minibidi replaces with ligatured glyphs. So I suppose there are Unicode characters that represent the ligature?

So implementing bidi and ligatures in TFreeTypeFont could interfere with minibidi?

By the way is there a link to your code?
Conscience is the debugger of the mind

benohb

  • Full Member
  • ***
  • Posts: 213
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #27 on: May 27, 2019, 02:41:18 pm »
Hello .ϻαϻɾΣɀО …

BGRATextBidi ???

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #28 on: May 31, 2019, 12:35:35 pm »
So minibidi replaces with ligatured glyphs. So I suppose there are Unicode characters that represent the ligature?
Yes, it dose. Unicode characters of course. But no fully implementation!

So implementing bidi and ligatures in TFreeTypeFont could interfere with minibidi?
I think yes!
Currently, I use it mine function that passes my usual arguments and a new one that prevents it from reordering ar/fa strings(For controlling cursor/caret inside memo/edit box)!

By the way is there a link to your code?
May be, I will check is there a space on my website's host!
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

ϻαϻɾΣɀО

  • Jr. Member
  • **
  • Posts: 54
  • MaMrEzO
Re: [SOLVED] EasyLazFreeType, Memory Load on drawing any charachter....
« Reply #29 on: May 31, 2019, 12:39:29 pm »
   
      I am wondering for what purpose you need minibidi as bidi is now handled by BGRABitmap?
   
         I read that code, It seems too heavy, I like what the minibidi did, Light and applicable.
         But I have got a plan to speed up that, All of Shapetaypes will be cached into memory, About 192KB of ram instead of a quick search of shapetype for every charachter!

Hello .ϻαϻɾΣɀО …

BGRATextBidi ???

Another thing that circular point to it: The minibidi provides ligatures and join characters even reorder them!
Debio-Sql is a new brand of GUI Database tool for the Firebird RDBMS.
http://debio-sql.ariaian.com/

 

TinyPortal © 2005-2018