Lazarus

Programming => Packages and Libraries => LazUtils => Topic started by: circular on March 22, 2012, 02:15:30 am

Title: [LazFreeType] Patches
Post by: circular on March 22, 2012, 02:15:30 am
Here is a patch for LazFreeType, which adds :
- multiple font support
- rasterizer is now a class
- font metrics : ascent, descent, linespacing, linefullheight (which are pixel metrics)
- line ending support
- text alignment (left/center/right, top/baseline/bottom)
- charsPosition : returns the position of each char (x, width, top, bottom) taking alignment and line endings into account
- smalllinepadding : true by default, can be set to false to have the same result as in word processors
- textwidth/textheight
- drawing on lazintfimage optimized
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 22, 2012, 11:58:19 am
Hello, thanks a lot, this will greatly help LCL-CustomDrawn =)

But there are some errors which I don't know how to solve:

    if (left > length(LineEnding)) and (pstr^ = LineEnding[1]) then
and
        if (pstr+(i-1))^ <> LineEnding[ i ] then

The [] array access is refused in platforms where the LineEnding is a single char like Mac OS X and Linux and prevents compilation.

/home/felipe/Programas/lazarus/components/lazutils/easylazfreetype.pas(976,40) Error: Illegal qualifier

And I'd prefer if we could work in the bug tracker. thanks,
Title: Re: [LazFreeType] Patches
Post by: circular on March 22, 2012, 04:26:29 pm
You can define a global string variable that is assigned the value of LineEnding.

I am a little bit lost with the bugtracker. If I apply the filter "LazFreeType", I get 3 entries. Is it right ?
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 23, 2012, 07:52:45 am
thanks, I applied in rev 36242, but the example fails with multiple errors.

First I can't compile because of routiens which don't exist:

Code: [Select]
  drawer.FillPixels(TColorToFPColor(clWhite));
and
  drawer.DrawHorizLine(round(x+p[i].x),round(y+p[i].yBase),round(x+p[i].x+p[i].width), TColorToFPColor(clBlue));
Also it uses the font "MS Comic Sans" which obviously does not exist in other platforms.

And also uses fonts which I can't easily find in my system:
    //ftFont2.Name := 'timesi.ttf';
    //ftFont3.Name := 'verdana.ttf';

And even if I correct all of that it still crashes =/

#0 SYSTEM_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER at :0
#1 SYSTEM_HANDLEERRORFRAME$LONGINT$POINTER at :0
#2 TFREETYPEDRAWER__DRAWTEXT((ANSISTRING) 0x1993f68, (TFREETYPERENDERABLEFONT) 0x1988560, 72.6666641, 54.84375, {RED = 0, GREEN = 0, BLUE = 0, ALPHA = 65535}, [FTARIGHT], (TFREETYPEDRAWER) 0x1995700) at easylazfreetype.pas:296
#3 TFREETYPEDRAWER__DRAWTEXT((ANSISTRING) 0x2c7168, (TFREETYPERENDERABLEFONT) 0x1988560, 172, 54.84375, {RED = 0, GREEN = 0, BLUE = 0, ALPHA = 65535}, [FTARIGHT], (TFREETYPEDRAWER) 0x1995700) at easylazfreetype.pas:283
#4 TFORM1__FORMPAINT((^TOBJECT) 0x197f630, (TFORM1) 0x197f630) at :0
#5 TCUSTOMCONTROL__PAINT((TCUSTOMCONTROL) 0x197f630) at ./include/customcontrol.inc:79
#6 TCUSTOMFORM__PAINTWINDOW(30624256, (TCUSTOMFORM) 0x197f630) at ./include/customform.inc:1115
#7 TWINCONTROL__PAINTHANDLER({MSG = 15, DC = 30624256, PAINTSTRUCT = 0x19a8b10, RESULT = 0}, (TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:4721
#8 TWINCONTROL__WMPAINT({MSG = 15, DC = 30624256, PAINTSTRUCT = 0x19a8b10, RESULT = 0}, (TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:6606
#9 TCUSTOMCONTROL__WMPAINT({MSG = 15, DC = 30624256, PAINTSTRUCT = 0x19a8b10, RESULT = 0}, (TCUSTOMCONTROL) 0x197f630) at ./include/customcontrol.inc:112
#10 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
#11 TWINCONTROL__WNDPROC({MSG = 15, WPARAM = 30624256, LPARAM = 26905360, RESULT = 0, WPARAMLO = 18944, WPARAMHI = 467, LPARAMLO = 35600, LPARAMHI = 410, RESULTLO = 0, RESULTHI = 0}, (TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:5276
#12 TCUSTOMFORM__WNDPROC({MSG = 15, WPARAM = 30624256, LPARAM = 26905360, RESULT = 0, WPARAMLO = 18944, WPARAMHI = 467, LPARAMLO = 35600, LPARAMHI = 410, RESULTLO = 0, RESULTHI = 0}, (TCUSTOMFORM) 0x197f630) at ./include/customform.inc:1414
#13 DELIVERMESSAGE((^TOBJECT) 0x197f630, void) at lclmessageglue.pas:117
#14 LCLSENDPAINTMSG((^TCONTROL) 0x197f630, 30624256, (PPAINTSTRUCT) 0x19a8b10) at lclmessageglue.pas:796
#15 CARBONCOMMON_DRAW((CFSTRINGREF) 0xbfffefc0, (CFSTRINGREF) 0x1b0f200, (^TCARBONWIDGET) 0x19cb060) at ./carbon/carbonprivatecommon.inc:117
#16 DispatchEventToHandlers at :0
#17 SendEventToEventTargetInternal at :0
#18 SendEventToEventTargetWithOptions at :0
#19 HIView::SendDraw at :0
#20 HIView::RecursiveDrawComposited at :0
#21 HIView::RecursiveDrawComposited at :0
#22 HIView::RecursiveDrawComposited at :0
#23 HIView::RecursiveDrawComposited at :0
#24 HIView::DrawComposited at :0
#25 HIView::Draw at :0
#26 HIView::Render at :0
#27 WindowData::PrepareForVisibility at :0
#28 _ShowHideWindows at :0
#29 ShowWindow at :0
#30 TCARBONWINDOW__SHOWHIDE(true, (TCARBONWINDOW) 0x19cb060) at ./carbon/carbonprivatewindow.inc:1697
#31 TCARBONWSCUSTOMFORM__SHOWHIDE((^TWINCONTROL) 0x197f630, (pvmt) 0x1e4f8a0) at ./carbon/carbonwsforms.pp:293
#32 TWINCONTROL__DOSENDSHOWHIDETOINTERFACE((TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:8139
#33 TWINCONTROL__CMSHOWINGCHANGED({MSG = 45081, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:8323
#34 TCUSTOMFORM__CMSHOWINGCHANGED({MSG = 45081, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TCUSTOMFORM) 0x197f630) at ./include/customform.inc:622
#35 SYSTEM_TOBJECT_$__DISPATCH$formal at :0
#36 TWINCONTROL__WNDPROC({MSG = 45081, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:5276
#37 TCUSTOMFORM__WNDPROC({MSG = 45081, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TCUSTOMFORM) 0x197f630) at ./include/customform.inc:1414
#38 TCONTROL__PERFORM(45081, 0, 0, (TCONTROL) 0x197f630) at ./include/control.inc:1464
#39 CHANGESHOWING(true, (POINTER) 0xbffff838) at ./include/wincontrol.inc:4269
#40 TWINCONTROL__UPDATESHOWING((TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:4319
#41 TCUSTOMFORM__UPDATESHOWING((TCUSTOMFORM) 0x197f630) at ./include/customform.inc:2630
#42 TWINCONTROL__DOALLAUTOSIZE((TWINCONTROL) 0x197f630) at ./include/wincontrol.inc:3535
#43 TCONTROL__ENABLEAUTOSIZING((TCONTROL) 0x197f630) at ./include/control.inc:5402
#44 TCONTROL__SETVISIBLE(true, (TCONTROL) 0x197f630) at ./include/control.inc:4248
#45 TCUSTOMFORM__SETVISIBLE(true, (TCUSTOMFORM) 0x197f630) at ./include/customform.inc:472
#46 TCUSTOMFORM__SHOW((TCUSTOMFORM) 0x197f630) at ./include/customform.inc:2164
#47 TAPPLICATION__RUN((TAPPLICATION) 0x1940360) at ./include/application.inc:1401
#48 PASCALMAIN at lazfreetypetest.lpr:17
#49 SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR at :0
#50 _start at :0
#51 start at :0

This affects only the example ... LCL-CustomDrawn works normally.

thanks,
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 23, 2012, 07:55:54 am
Ah, also, it would be good to have a second drawer for Lazarus (in the same unit) which is based in TLazCanvas instead of TLazIntfImage. This is a good idea because TLazCanvas enforces clipping while TLazIntfImage leaves you free to draw everywhere (which violates clipping).
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 23, 2012, 08:19:15 am
I am a little bit lost with the bugtracker. If I apply the filter "LazFreeType", I get 3 entries. Is it right ?

Yes, probably right. If you say how you are called in the bug tracker then I can simply assign the issues to you. Then you can just search for issues assigned to you.
Title: Re: [LazFreeType] Patches
Post by: circular on March 23, 2012, 01:56:24 pm
thanks, I applied in rev 36242, but the example fails with multiple errors.

First I can't compile because of routiens which don't exist:

Code: [Select]
  drawer.FillPixels(TColorToFPColor(clWhite));
and
  drawer.DrawHorizLine(round(x+p[i].x),round(y+p[i].yBase),round(x+p[i].x+p[i].width), TColorToFPColor(clBlue));
I've added these units in LazFreeTypeIntfDrawer. It is not in the patch ? Anyway here is a copy of it.
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 23, 2012, 02:44:59 pm
I think I had some old PPUs somewhere because I tryed to apply your new unit but the diff result was empty, so it is already in SVN. But still, requiring having arial.ttf, timesi.ttf and verdana.ttf will make sure this can only be used in Windows ...
Title: Re: [LazFreeType] Patches
Post by: circular on March 23, 2012, 04:55:02 pm
I don't mind if you change this. I do not "want" it to be only on Windows. These are files that worked for me. What do you propose ? Maybe we could find automatically the font folder.

So did you manage to make it work ?
Title: Re: [LazFreeType] Patches
Post by: circular on March 24, 2012, 08:36:18 pm
Here is a second patch that adds the feature of getting information about a font.

New properties : VersionNumber, Family, and Information.
Title: Re: [LazFreeType] Patches
Post by: felipemdc on March 26, 2012, 02:29:42 pm
Thanks, applied in rev 36345
Title: Re: [LazFreeType] Patches
Post by: felipemdc on April 03, 2012, 09:55:34 am
@circular

What is you name in the Lazarus Bug Tracker?
Title: Re: [LazFreeType] Patches
Post by: circular on April 08, 2012, 05:20:22 pm
@felipemdc: it's "circular"

I wonder how to integrate font collection in LazFreeType. I propose this :

there would be a global collection, automatically created, called for example FreeTypeCollection. It would be possible to add a directory of font at program startup.

the TFreeTypeFont would have a Collection property which would be initialized with the global collection. But it could be assigned to another object, allowing to work with multiple font collections. When a collection with font is available, the TFreeTypeFont object could interpret the Name property as a familiy name, and take styles into account.

What do you think ?
Title: Re: [LazFreeType] Patches
Post by: felipemdc on April 09, 2012, 02:24:36 pm
In general yes, it would be great of LazFreeType could do the work of searching for the best font to use with a given set o characteristics (monospace, italic, bold, serif vs non-serif), although it should also still support simply giving the direct full path for the font like now.

About the directory of fonts, it should be a list of directories, never suppose that only 1 directory will contain all fonts.

Giuliano might have more feedback on this. Note also that we already have some code which does font selection in LCL-CustomDrawn.
Title: Re: [LazFreeType] Patches
Post by: circular on April 09, 2012, 08:20:47 pm
In general yes, it would be great of LazFreeType could do the work of searching for the best font to use with a given set o characteristics (monospace, italic, bold, serif vs non-serif), although it should also still support simply giving the direct full path for the font like now.
Of course.

Quote
About the directory of fonts, it should be a list of directories, never suppose that only 1 directory will contain all fonts.
Yes, multiple call to AddFolder.

Quote
Giuliano might have more feedback on this.
Ok.

Quote
Note also that we already have some code which does font selection in LCL-CustomDrawn.
Which code ?
Title: Re: [LazFreeType] Patches
Post by: felipemdc on April 09, 2012, 10:15:35 pm
Which code ?

See in this file:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/customdrawn/customdrawnproc.pas?view=markup&root=lazarus

these routines:

procedure VerifyAndCleanUpFontDirectories(AFontDirectories: TStringList);
procedure FontsScanForTTF(APath: string; var AFontTable: THashedStringList);
procedure FontsScanDir(APath: string; var AFontPaths: TStringList; var AFontList: THashedStringList);

And then for each backend there are the routines:

procedure TCDWidgetSet.BackendListFontPaths(var AFontPaths: TStringList; var AFontList: THashedStringList);
function TCDWidgetSet.BackendGetFontPath(const LogFont: TLogFont; const LongFontName: string): string;

For example for Windows they are in this file:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/customdrawn/customdrawnwinapi_win.inc?view=markup&root=lazarus

And similar files exist for X11, Cocoa and Android.
Title: Re: [LazFreeType] Patches
Post by: circular on April 10, 2012, 01:06:17 pm
I see. What I did is slightly different, but should be ok too.
Title: Re: [LazFreeType] Patches
Post by: circular on April 12, 2012, 04:17:29 pm
Here is a patch that includes font collection, font style and family name.

How to use :
Code: [Select]
uses EasyLazFreeType, IntfGraphics, LazFreeTypeIntfDrawer, LazFreeTypeFontCollection;

var
  lazimg: TLazIntfImage;
  drawer: TIntfFreeTypeDrawer;   

begin
  FontCollection.AddFolder('c:\windows\fonts');  //for example

  lazimg := TLazIntfImage.Create(...);
  drawer := TIntfFreeTypeDrawer.Create(lazimg);     

  ft := TFreeTypeFont.Create;
  ft.Name := 'Arial';
  ft.Style := [ftsBold];     
  ft.LineFullHeight := 50; // height in pixels
  drawer.DrawText('The quick brown fox jumps over the lazy dog.',ft,0,0,colBlack,[ftaLeft,ftaTop]); 
  ft.Free;

  lazimg.free;
  drawer.free;
end;   
Title: Re: [LazFreeType] Patches
Post by: felipemdc on April 13, 2012, 09:04:24 am
Thanks, applied in rev 36741
Title: Re: [LazFreeType] Patches
Post by: circular on April 14, 2012, 10:29:56 pm
Now I can try to solve some bugs that are already reported.
Title: Re: [LazFreeType] Patches
Post by: circular on January 30, 2013, 10:00:25 pm
Here is a new patch :
- extended characters handled correctly
- bug fix in case freetype font collection is freed before the drawer (added listeners when font collection item is destroyed)
- SetDefaultFreeTypeFontCollection in LazFreeTypeFontCollection unit, so it is not necessary to mention EasyLazFreeType in uses clause if font collection is used
- textrect and wordwrap for freetype
Title: Re: [LazFreeType] Patches
Post by: Ask on January 31, 2013, 11:39:25 pm
Applied in r40104.

However, since I am not the maintainer of LazFreeType,
I did not fully understand your code and only tested that it does not break existing example.

A few notes from quick browsing of the patch:
1) If I were LazFreeType maintainer, I would prefer a set of smaller patches, one for each logical change.
2) What does change to ttcmap do? It seems to me that you replaced code by equivalent one.
Or was it just refactoring?
Title: Re: [LazFreeType] Patches
Post by: circular on February 01, 2013, 12:46:16 am
Applied in r40104.

However, since I am not the maintainer of LazFreeType,
I did not fully understand your code and only tested that it does not break existing example.
Ok. New features will be used in next version of BGRABitmap, I already tested it on my computer.

EDIT : here is the link : http://www.lazarus.freepascal.org/index.php/topic,12390.msg112895.html#msg112895

Quote
A few notes from quick browsing of the patch:
1) If I were LazFreeType maintainer, I would prefer a set of smaller patches, one for each logical change.
I thought it was more convenient for update.

Quote
2) What does change to ttcmap do? It seems to me that you replaced code by equivalent one.
Or was it just refactoring?
There was a sign error, it's refactored too to make it more understandable.
Title: Re: [LazFreeType] Patches
Post by: circular on February 01, 2013, 10:31:01 am
Here is an updated test program for LazFreeTypeIntfDrawer (not using BGRABitmap), for examples/lazfreetype .
Title: Re: [LazFreeType] Patches
Post by: Ask on February 01, 2013, 10:55:49 am
Thank you.

In the future, please update your checkout before changing files.
Your change reverted by last commit (r40103).

Also, it would be preferable to receive changes as patches as opposed to whole files.
Patches are easier to review before applying.

Merged and committed your changes in r40109.
Title: Re: [LazFreeType] Patches
Post by: circular on February 01, 2013, 11:29:43 am
Thank you.

In the future, please update your checkout before changing files.
Your change reverted by last commit (r40103).
Sorry for that. It was the $R option, wasn't it?

Quote
Also, it would be preferable to receive changes as patches as opposed to whole files.
Patches are easier to review before applying.
Ok.

In fact I'm working with Lazarus 1.0 so it was not easy. I tried to switched to lastest subversion of Lazarus some time ago, but I was swamped in compilation issues.
Title: Re: [LazFreeType] Patches
Post by: Ask on February 01, 2013, 11:56:44 am
Quote
It was the $R option, wasn't it?
No, it was small visual fix (https://github.com/graemeg/lazarus/commit/3b0b23f4ad04364f81558f95e79d9030408eff0b).

Quote
I tried to switched to lastest subversion of Lazarus some time ago, but I was swamped in compilation issues.
I use Lazarus trunk, and BGRABitmap works fine with it.
Title: Re: [LazFreeType] Patches
Post by: circular on February 01, 2013, 12:03:29 pm
Quote
It was the $R option, wasn't it?
No, it was small visual fix (https://github.com/graemeg/lazarus/commit/3b0b23f4ad04364f81558f95e79d9030408eff0b).
Oh ok. It's a good idea to avoid flickering.

I thought you were talking about LazUtils units. There was a $R option in the beggining TTCMap unit, I don't know if it was removed by the patch.

Quote
Quote
I tried to switched to lastest subversion of Lazarus some time ago, but I was swamped in compilation issues.
I use Lazarus trunk, and BGRABitmap works fine with it.
Ok. I had no problem with compiling BGRABitmap itself, but with other things.

Another reason is that I wanted BGRABitmap to be compatible with Lazarus 1.0, so that people do not have to update with subversion. This principle is broken with the latest version of BGRABitmap 6.5, so I guess I can try to switch again to latest subversion of Lazarus.

This is more about TAChart : i've added one bug report, and i'm adding a second one.

EDIT: last version is 6.5
Title: Re: [LazFreeType] Patches
Post by: Ask on February 01, 2013, 01:13:40 pm
Quote
principle is broken with the latest version of BGRABitmap 6.4
I think it would be good to document Lazarus version requirements somewhere
in BGRABitmap documentation, stating that 6.3 is the last version compatible with 1.0, and you need 1.1 for later versions.

If you want, you can even branch "stable" BGRABitmap version, similar to Lazarus "fixes" branch.
Title: Re: [LazFreeType] Patches
Post by: circular on February 01, 2013, 01:54:58 pm
Ok. In fact, latest version is 6.5 and version 6.4 should still be compatible with Lazarus 1.0.

I've mentionned it on the wiki :
http://wiki.freepascal.org/BGRABitmap
Title: Re: [LazFreeType] Patches
Post by: circular on February 02, 2013, 12:50:00 am
Here is a new patch :
- external access about hinted option
- font hinting when text center
- OnRenderText event added
- line ending when splitting
Title: Re: [LazFreeType] Patches
Post by: Ask on February 02, 2013, 01:52:26 pm
I have applied first part of the patch in r40120.

I have few questions about other parts:

>external access about hinted option
Are there other descendants of TFreeTypeRenderableFont?
If so, they should be updated to be compilable after this change.

>line ending when splitting
I can not understand what this change is supposed to do.
Can you write a commit message for it?

Also, code of RemoveLineEnding function seems too complicated.
Is not it equivalent to the following?
Code: [Select]
Result := (index <= Length(s)) and (s[index] in [#13, #10]);
if Result then
  if (index + 1 <= Length(s))  and ([s[index + 1], s[index]] = [#13, #10]) then
    Delete(s, index, 2)
  else
    Delete(s, index, 1);
Title: Re: [LazFreeType] Patches
Post by: circular on February 02, 2013, 06:30:32 pm
>external access about hinted option
Are there other descendants of TFreeTypeRenderableFont?
If so, they should be updated to be compilable after this change.
No.

Quote
>line ending when splitting
I can not understand what this change is supposed to do.
Can you write a commit message for it?
When there are #13#10 chars in a string, they are taking into account when splitting the text, i.e. text goes to a new line before reaching the maximum width.

Quote
Also, code of RemoveLineEnding function seems too complicated.
Is not it equivalent to the following?
Code: [Select]
Result := (index <= Length(s)) and (s[index] in [#13, #10]);
if Result then
  if (index + 1 <= Length(s))  and ([s[index + 1], s[index]] = [#13, #10]) then
    Delete(s, index, 2)
  else
    Delete(s, index, 1);
I would say so, but this part seems slower (more complicated for the compiler) :
Code: [Select]
[s[index + 1], s[index]] = [#13, #10]
Title: Re: [LazFreeType] Patches
Post by: circular on February 02, 2013, 06:40:44 pm
Here is another patch to apply to easylazfreetype.pas :
- OnRenderText event moved upwards to be accessible from TFreeTypeRenderableFont
Title: Re: [LazFreeType] Patches
Post by: circular on February 02, 2013, 06:44:23 pm
And another to add text decoration (underline and strikout) in TIntfFreeTypeDrawer :
Title: Re: [LazFreeType] Patches
Post by: Ask on February 03, 2013, 01:06:39 am
Quote
Quote
Are there other descendants of TFreeTypeRenderableFont?
No.
Ok, committed in r40130

Quote
text goes to a new line before reaching the maximum width.
Quote
... but this part seems slower (more complicated for the compiler)
Ok, I have taken a look from the optimization point of view.
Committed modified version of this change in r40131-40133. Main differences are:
1) No extra calls to "Delete" (note that "Delete" contains a loop)
2) No extra loop variable (in you version, "p" did the same as "left")

Quote
OnRenderText event moved upwards to be accessible from TFreeTypeRenderableFont

Committed in r40134. Please create patches from "lazarus" or "lazutils" directory, not from the disk root. Otherwise, patches include absolute paths which I have to edit manually before applying.

Quote
add text decoration (underline and strikout)
Committed with minor modification in r40135.
However, I have doubts about design -- should not underline/strike-out be a property of a font?
Title: Re: [LazFreeType] Patches
Post by: circular on February 03, 2013, 10:53:54 am
Thanks.

Quote
Quote
add text decoration (underline and strikout)
Committed with minor modification in r40135.
However, I have doubts about design -- should not underline/strike-out be a property of a font?
Oh you're right. I'll try to move it there.
Title: Re: [LazFreeType] Patches
Post by: circular on February 03, 2013, 11:24:05 am
Here is the patch to move text decoration into font :
Title: Re: [LazFreeType] Patches
Post by: Ask on February 03, 2013, 11:48:29 am
Applied in r40147.
In the future, please update your working copy before creating a patch --
the one you sent reverted changes I made in r40131.
Title: Re: [LazFreeType] Patches
Post by: circular on February 03, 2013, 01:54:59 pm
Alright.
Title: Re: [LazFreeType] Patches
Post by: circular on February 03, 2013, 04:12:05 pm
This is not exactly about FreeType, but there are drawing routines in the drawer that could be moved to FPCanvas.
Title: Re: [LazFreeType] Patches
Post by: Ask on February 04, 2013, 03:25:41 am
I have no commit access to the FPCanvas. You can create a feature request on the bug tracker.

Note, however, that FPC releases are very rare, and Lazarus traditionally allows some lag in FPC version, so even if those routines are copied to FPCanvas, they must remain in LazFreeType until FPC 2.8 comes out *and* becomes a minimum required version for Lazarus.
Title: Re: [LazFreeType] Patches
Post by: circular on February 04, 2013, 11:41:00 am
I understand.

Just in case, to whom could I submit patches for that?
Title: Re: [LazFreeType] Patches
Post by: BigChimp on February 04, 2013, 12:04:14 pm
The bugtracker.

Note: while I agree with ask's post, if it makes sense architecturally to move stuff into FPC, I think it should be done. Yes, it will take some time to filter through to Lazarus stable releases but better late than never.

You can then use conditional compilation to check for FPC version in order to support old and new FPC up to the time a new stable FPC is released... or alternatively just live with duplicate code for a while... (which I wouldn't recommend)

Title: Re: [LazFreeType] Patches
Post by: circular on February 04, 2013, 09:37:16 pm
If I apply some modifications to the FP code, it is not compiled again, object files stay the same and added functions are not available. How to recompile FP?
Title: Re: [LazFreeType] Patches
Post by: Ask on February 05, 2013, 01:23:12 am
It is more complicated (http://wiki.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows).

I recommend to read and understand the whole process before starting it --
the instructions should probably be adjusted to your configuration.
Title: Re: [LazFreeType] Patches
Post by: circular on February 16, 2013, 01:50:47 pm
Here are two patches for LazFreeType.

- minimum size of 1 point, to avoid error with underlying procedures
- interpreter of true type program moved into one class (so it can be multithreaded) and dynamic stack size (this solves many fonts that use more stack than they declare)

EDIT : note that for multithreading to be ok, it is needed that an execution context be created for each thread
Title: Re: [LazFreeType] Patches
Post by: circular on February 17, 2013, 05:44:20 pm
Here is a patch for file access :
Title: Re: [LazFreeType] Patches
Post by: zamtmn on February 22, 2013, 01:49:08 pm
this may include another small patch http://bugs.freepascal.org/view.php?id=23887

>>Here is a patch for file access :
I recently created a bug report about it http://bugs.freepascal.org/view.php?id=23888

interpreter_class.patch gives these errors on fpc2.7.1:
Code: [Select]
C:\lazarus\components\lazutils\ttinterp.pas(736,23) Hint: Mixing signed expressions and longwords gives a 64bit result
C:\lazarus\components\lazutils\ttinterp.pas(1140,51) Error: Incompatible types: got "TInterpreter.procedure Round_None(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1141,51) Error: Incompatible types: got "TInterpreter.procedure Round_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1142,51) Error: Incompatible types: got "TInterpreter.procedure Round_Up_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1143,51) Error: Incompatible types: got "TInterpreter.procedure Round_Down_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1144,51) Error: Incompatible types: got "TInterpreter.procedure Round_To_Half_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1145,51) Error: Incompatible types: got "TInterpreter.procedure Round_To_Double_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1146,51) Error: Incompatible types: got "TInterpreter.procedure Round_Super(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1147,51) Error: Incompatible types: got "TInterpreter.procedure Round_Super_45(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1288,27) Error: Incompatible types: got "TInterpreter.procedure Project_x(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1294,27) Error: Incompatible types: got "TInterpreter.procedure Project_y(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1299,27) Error: Incompatible types: got "TInterpreter.procedure Direct_Move(PGlyph_Zone;LongInt;LongInt);" expected "<procedure variable type of procedure(PGlyph_Zone;LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1300,27) Error: Incompatible types: got "TInterpreter.procedure Free_Project(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1305,53) Error: Incompatible types: got "TInterpreter.procedure Project_x(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1307,53) Error: Incompatible types: got "TInterpreter.procedure Project_y(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1309,53) Error: Incompatible types: got "TInterpreter.procedure Project(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1311,54) Error: Incompatible types: got "TInterpreter.procedure Project_x(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1313,54) Error: Incompatible types: got "TInterpreter.procedure Project_y(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1315,54) Error: Incompatible types: got "TInterpreter.procedure Dual_Project(var TT_Vector;var TT_Vector):LongInt;" expected "<procedure variable type of function(var TT_Vector;var TT_Vector):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1317,19) Error: Incompatible types: got "TInterpreter.procedure Direct_Move(PGlyph_Zone;LongInt;LongInt);" expected "<procedure variable type of procedure(PGlyph_Zone;LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1321,50) Error: Incompatible types: got "TInterpreter.procedure Direct_Move_X(PGlyph_Zone;LongInt;LongInt);" expected "<procedure variable type of procedure(PGlyph_Zone;LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(1323,50) Error: Incompatible types: got "TInterpreter.procedure Direct_Move_Y(PGlyph_Zone;LongInt;LongInt);" expected "<procedure variable type of procedure(PGlyph_Zone;LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2725,25) Error: Incompatible types: got "TInterpreter.procedure Round_To_Half_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2735,25) Error: Incompatible types: got "TInterpreter.procedure Round_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2745,25) Error: Incompatible types: got "TInterpreter.procedure Round_To_Double_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2755,25) Error: Incompatible types: got "TInterpreter.procedure Round_Up_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2765,25) Error: Incompatible types: got "TInterpreter.procedure Round_Down_To_Grid(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2775,25) Error: Incompatible types: got "TInterpreter.procedure Round_None(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2786,25) Error: Incompatible types: got "TInterpreter.procedure Round_Super(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(2797,25) Error: Incompatible types: got "TInterpreter.procedure Round_Super_45(LongInt;LongInt):LongInt;" expected "<procedure variable type of function(LongInt;LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4751,32) Error: Incompatible types: got "TInterpreter.procedure Read_CVT_Stretched(LongInt):LongInt;" expected "<procedure variable type of function(LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4752,32) Error: Incompatible types: got "TInterpreter.procedure Write_CVT_Stretched(LongInt;LongInt);" expected "<procedure variable type of procedure(LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4753,32) Error: Incompatible types: got "TInterpreter.procedure Move_CVT_Stretched(LongInt;LongInt);" expected "<procedure variable type of procedure(LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4757,32) Error: Incompatible types: got "TInterpreter.procedure Read_CVT(LongInt):LongInt;" expected "<procedure variable type of function(LongInt):LongInt;Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4758,32) Error: Incompatible types: got "TInterpreter.procedure Write_CVT(LongInt;LongInt);" expected "<procedure variable type of procedure(LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4759,32) Error: Incompatible types: got "TInterpreter.procedure Move_CVT(LongInt;LongInt);" expected "<procedure variable type of procedure(LongInt;LongInt);Register>"
C:\lazarus\components\lazutils\ttinterp.pas(4952,13) Error: identifier idents no member "interpreter"
C:\lazarus\components\lazutils\ttinterp.pas(4955,12) Error: identifier idents no member "interpreter"
C:\lazarus\components\lazutils\ttinterp.pas(4957,40) Error: identifier idents no member "interpreter"
C:\lazarus\components\lazutils\ttinterp.pas(4972) Fatal: There were 38 errors compiling module, stopping
Title: Re: [LazFreeType] Patches
Post by: circular on February 22, 2013, 02:29:52 pm
The patch changes not only ttinterpreter, but also ttobjs. Make sure you applied it to ttobjs.
Title: Re: [LazFreeType] Patches
Post by: zamtmn on February 22, 2013, 02:49:19 pm
Thank you. You are right
Title: Re: [LazFreeType] Patches
Post by: circular on March 02, 2013, 04:52:38 pm
Patch for symbol fonts (WebDings, WebDings, WingDings) :
Title: Re: [LazFreeType] Patches
Post by: circular on March 02, 2013, 04:54:15 pm
Patch to avoid exception when creating TFreeTypeStream :
Title: Re: [LazFreeType] Patches
Post by: circular on March 02, 2013, 05:18:47 pm
Precalculate and check range start :
Title: Re: [LazFreeType] Patches
Post by: circular on March 02, 2013, 07:04:14 pm
Handling TTC files, which are small collections. Called internal collections in this patch, to differentiate from font collection class.
Title: Re: [LazFreeType] Patches
Post by: circular on March 03, 2013, 08:52:25 am
Line spacing fix (especially top margin).
Title: Re: [LazFreeType] Patches
Post by: zamtmn on December 03, 2015, 12:57:15 am
Fix TFreeTypeFont variables destructor calling if EasyLazFreeType.finalization section already worked
Title: Re: [LazFreeType] Patches
Post by: Graeme on December 04, 2015, 11:54:30 am
Has all these patches been applied - there seems to be no confirmation on any of them? Why don't you guys use Mantis where patches can be more easily tracked. Or use Git or something so patches can be even easier tested by others.
TinyPortal © 2005-2018