Found an error in cairo.mod
BlitzMax Forums/Brucey's Modules/Found an error in cairo.mod
| ||
Is this is a bug report? I use CAIRO.MOD to build PDF documents. But I use the it too to build the preview screenshots of this PDF. Everything works fine, but if I build a preview document, which has a lot of... cairo.ShowText ...it builds 3 or 4 times the complete 2 pages document. But then it crashes with this error message: t Assertion failed: !unscaled->from_face, file C:/BlitzMax/mod/BaH.mod/cairo.mod/src/cairo-ft-font.c, line 558 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Now I don't know, whether this a a CAIRO bug or a bug of the CAIRO.MOD? Or a bug of me :) . I am not really firm in C and a noobie in CAIRO. This it what I do in cairo: Type PDF_TYP Global cairo:TCairo , normalizeMat:TCairoMatrix Global CairoBild:TImage[9] , Page%=0 , AktScale#=1 Function CreateFirstPreview(Scale#) Print "FUNKTION CreateFirstPreview" AktScale=Scale CreateNextPreview End Function Function CreateNextPreview() Print "FUNKTION CreateNextPreview Next Page" cairo = TCairo.Create(TCairoImageSurface.CreateForPixmap(TCairoPaperSize.PAPER_A4.width, TCairoPaperSize.PAPER_A4.height)) normalizeMat = TCairoMatrix.CreateScale(AktScale , AktScale ) cairo.SetMatrix(normalizeMat) End Function Function CheckNewLine(Y#) If Y>TCairoPaperSize.PAPER_A4.Height/AktScale Then 'new page cairo.destroy() CairoBild[page] = LoadImage(TCairoImageSurface(cairo.getTarget()).pixmap()) CreateNextPreview() Page:+1 EndIf End Function Function FinishPDF() Print "FUNKTION FinishPDF " + AlsPreview cairo.destroy() CairoBild[Page] = LoadImage(TCairoImageSurface(cairo.getTarget()).pixmap()) End Function Function TextOut (x#,y#,t$) cairo.Save() Print "cairo textout X=" + x + " Y=" + y + " T=" + t +"!" cairo.Translate(x, y) cairo.SelectFontFace( "arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) cairo.SetFontSize(25) cairo.ShowText t cairo.Restore() End Function End Type In the complete code I do much more than this on the document: images, paintings,... but they are not relevant for reproducing the bug. The bug appears after third or fourth document refresh. Each document I call ~100-200 times TextOut(), in total >400. Maybe it is only a stupid mistake by me? Maybe I forget to "Delete" any object, is it only a stack overrun? Perhaps someone can help me? |
| ||
here is a little work-around, which reduces the problem... This makes clear, that the problem is in one of these four lines: cairo.Save() ... cairo.SelectFontFace( "arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) .... cairo.SetFontSize(25) .... cairo.Restore() This causes less crashes, because I'm now collecting all TextOut()-Calls and sending them in one package to CAIRO. At first I print al elements as usuall. Then I open the surface , "print" all texts, and after this I close the surface. This makes it more unflexible, but it is working. Nevertheless we should find the reason for the crash and send a bug report to cairographics.org 'first all other elements For Local loc:BildElement = EachIn BildListe If (loc.Typ<>105) PDF_Typ.Male loc.X , loc.Y loc.T EndIf Next 'now the strings: PDF_Typ.WorkAroundTextStart For Local loc:BildElement = EachIn BildListe If (loc.Typ=105) PDF_Typ.WorkAroundTextOut loc.X , loc.Y loc.T EndIf Next PDF_Typ.WorkAroundTextFinish Type PDF_Typ .... Function WorkAroundTextStart() cairo.Save() cairo.SelectFontFace( "arial", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL) cairo.SetFontSize(25) End Function Function WorkAroundTextOut (x#,y#,t$) cairo.Translate(x, y) cairo.MoveTo( -0, 24) cairo.ShowText t cairo.MoveTo( -0, -24) cairo.Translate(-x, -y) End Function Function WorkAroundTextFinish() cairo.Restore() End Function ... End Type |
| ||
I've just released 1.24 of BaH.Cairo. Main changes to the module are : * Cairo update to 1.10.2. * Pixman update to 0.22.2. * Added support for TStream surface writing (PDF, PS, etc) * Fixed CopyPath and CopyPathFlat not returning value. * Added TCairoRegion and TCairoRectangleInt. Hopefully this makes things a bit better in general. |