Re: A few quick questions

From: <msevior_at_physics.unimelb.edu.au>
Date: Wed Aug 10 2005 - 15:52:40 CEST

>
>
> Hi guys,
>

Hi Roland,

> I'm working on a fix for #9240. Sadly, this requires a much bigger patch
> than I'd initially expected, so this will be another one to go in once
> 2.5 is branched. Nevertheless, I have a few questions that I was hoping
> someone would know the answers to.
>
> Firstly, if I get a pointer to a font like this...
>
> GR_Font *pFont;
> pFont = findFont("Times New Roman", ... , "15pt");
>
> Do I need to worry about subsequently freeing the font pointer. The
> impression I get from looking at the code is that the GR_Graphics
> class caches this pointer and frees it itself when necessary. Is that
> right?
>

Yes, that's right. The font is cached. You never need free it.

> Secondly, is there an agreed approach for handling out of memory and
> similar errors in class constructors? I gather there are portability
> issues for AbiWord with using exceptions for this. Can I use the
> UT_THROW() / UT_CATCH() macros as suggested in ut_exceptions.h ?
>

Early on in the AbiWord development process there was a whole of code like
this...

fl_BlockLayout * pBL = new fl_BlockLayout(...);
//
// TODO decide what to do about out of memory errors
//
UT_ASSERT(pBL);

In all the years I've been developing AbiWord I have not yet seen a single
out of memory crash so we've basically decided not to worry about these
any more. We'll let the operating system deal with out of mem issues.

> Finally, is there any way to accurately get the horizontal space
> that will be used by a string when displayed on a particular
> graphics context? The GR_Graphics::measureString() functions looks
> like it's meant to do this. However, it appears to neglect the
> inter-character space and so the values it returns rather
> underestimate the actual string width.

That is an interesting observation. As far as I know the characters are
meant to be placed at exactly the distance given by their character
widths. There should be no inter-character spacing at all. On the other
hand I know that characters move relative to each other at different zoom
levels. I always thought that this was due to rounding errors in placing
characters at whole pixel positions. If you have evidence that the
characters are being positioned in a different way, I'd very much like to
see it. It would be a fantastic fix if we can manage it.

On the other hand the spacing between words is a function of the
justification used.

Will you commit the patch to fix the names of Chinese fonts before 2.5?

Cheers

Martin
Received on Wed Aug 10 15:52:21 2005

This archive was generated by hypermail 2.1.8 : Wed Aug 10 2005 - 15:52:21 CEST