[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: auto-scaling text dia .94



On Tue, 26 Oct 2004 00:21:08 +0200 (MEST), Robert Ögren <gtk roboros com> wrote:
> 
> I can always reproduce the problem by following these steps:
> 
> 1. Start dia
> 2. Create a new diagram
> 3. Zoom in to 200 %
> 4. Add a flowchart symbol, for example a process (box)
> 5. Add the following two letters: ad
> 
> When I type the first letter in step 5, the a is shown in the correct
> size. When I then type d, the text is shrunk to half the size. Adding some
> other letters then makes the text normal size again. The choice of letters
> is important and also depends on the zoom level, for example at 400 % zoom
> I have to type adf for the problem to appear.
> 
> As far as I can see from my very limited knowledge of the dia sources and
> some gdb:ing, the problem seems to be with the layout cache used by
> dia_font_build_layout. The cache only stores a reference to the font
> object used to create the layout, but it may be modified by subsequent
> calls to dia_font_build_layout with different heights so that font->pfd
> no longer matches the cached layout.
> 
> Example, end of dia_font_build_layout (string=0x14630c8 "ad",
>     font=0x13ea240, height=1.6000000000000001), font.c:
> (gdb) n
> 638           return cached->layout;
> (gdb) p *cached->font->pfd
> $52 = {family_name = 0x14f28c0 "sans", style = PANGO_STYLE_NORMAL,
>   variant = PANGO_VARIANT_NORMAL, weight = PANGO_WEIGHT_NORMAL,
>   stretch = PANGO_STRETCH_NORMAL, mask = 43, static_family = 0, size =
> 22937}
> (gdb) p *((PangoAttrFontDesc
> *)cached->layout->attrs->attributes->data)->desc
> $53 = {family_name = 0x14f0658 "sans", style = PANGO_STYLE_NORMAL,
>   variant = PANGO_VARIANT_NORMAL, weight = PANGO_WEIGHT_NORMAL,
>   stretch = PANGO_STRETCH_NORMAL, mask = 43, static_family = 0, size =
> 11468}
> (gdb)
> 
> A solution which appears to work in a brief test is to replace the
> dia_font_ref call in dia_font_build_layout by
>     item->font = dia_font_copy(font);
> 
> but I don't know if this is the right way to do it or not.
> Reverting to rev 1.122 of lib/font.c also seems to make this problem go
> away, but probably unfixes other bugs.

I believe it introduces a major memory leak.  If we can combine the
dia_font_copy above with proper deallocation, we may have a fix.  The
test for memory leak should include having a huge diagram, zooming it
way out, and then making it redraw repeatedly (bug from 0.93).

I miss garbage collection.

OTOH, newer Pango versions have a way of forcing the width of the
text, which would eliminate the entire tweaking thing.  Would be good
to look at.

> Btw, thanks for a great program!

You're welcome!

-Lars


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK