Forum > LazUtils

[LazFreeType] Patches

(1/12) > >>

circular:
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

felipemdc:
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,

circular:
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 ?

felipemdc:
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: ---  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));

--- End code ---
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,

felipemdc:
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).

Navigation

[0] Message Index

[#] Next page

Go to full version