Re: GtkSpinButton Patch





On Tue, 2 May 2000, Nils Barth wrote:

> Wouldn't it simply be best to take the maximum width of all numerical
> characters in the font, in case of weird fonts?
> It's not that hard, is it?
> 

No... it shouldn't be.  In addition to i18n issues (as you mentioned),
there is another problem, see below. 

> That is, set the width of the box to be:
> max_number_of_digits*max(width(0..9))
> + (if applicable) width(decimal delimiter) + (if applicable) width("-")
> 
>   does it allow instead a (2) for -2, or a red 2 or whatever (though
>   these are ugly).
> 
> Are there any further i18n questions? Do we only want to render Roman
> numerals?

There's actually another issue here.  When we get to things like GtkEntry
we can't possibly check every single possible renderable character - it
feels like there should be a GDK function that gets the maximum
advance for the font...  Of course if everything gets switched to Pango I
don't know how that effects thing's yet...

(gdk_font_get_max_advance()??)

> 
> Side note: kernel-traffic's latest issue had a note on a possible
> problem with a simple MAX a la GLib, namely that it evaluates
> functions twice, which can be bad for some functions (say, if they
> return different values on repeated calls). Someone suggested
> replacing it with a dummy variable assignment, then
> comparing/assigning with those variables. This might also be a bit
> faster...
> The exact code was (for MIN):
> #define min(x, y) ({typeof (x) x_ = (x); \
>                     typeof (y) y_ = (y); \
>                     x_ < y_ ? x_ : y_;})
> 
> Message reference in which this is discussed further:
> http://kernelnotes.org/lnxlists/linux-kernel/lk_0004_03/msg00537.html
> 
> If this is changed, we'd also likely want to change MIN ABS and CLAMP

On the other hand I can just write code that doesn't have functions inside
macros - always a safer thing :)

So I'll send a big patch in a couple days for the other stuff.  I'll be
careful only to use variables in MAX and concerning character widths: I'll
write something similar to what I did rather than putting loops in
everywhere, b/c I really feel that the code for finding the max width
belongs elsewhere.


Cheers,
Ryan Willhoit
willhoit@andrew.cmu.edu

> 
> -- 
>   -nils
> Public key: http://www.fas.harvard.edu/~nbarth/pub-key.txt
> 



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