bug-gnustep
[Top][All Lists]
Advanced

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

Re: Text drawing bug - gaps after 16th character in scaled view


From: Alexander Malmberg
Subject: Re: Text drawing bug - gaps after 16th character in scaled view
Date: Fri, 27 Jun 2003 14:39:26 +0200

Pete French wrote:
> I am trying to draw some text into a scaled view. The view has been scaled
> so that the same co-ordinates can always be used for drawing the diagram,
> no matter what the actual size of the view is.
> 
> I find that if I render text of more than 16 characters then I get a gap
> between the 16th and subsequent character. e.g. the text "Isotropic antenna"
> appears on the screen as "Isotropic antenn a". This is under back-art. using
> the xlib backend the pproblem is far worse and the text appears something
> like "Istotropic antenn     a".
[snip]
> The bug appears to be related to the font size - if I make the
> drawing area twice as big the the text doubles in size but the bug remains.
> If I keep the drawing area the same but change the font size from '10'
> to '20' however then the text becomes twice as big but the problem goes away!
> The expected result would be for the text to be identical in both cases.

This is expected (at least currently), although the situation is a bit
complex.

In *step, there are two kinds of fonts: printer fonts and screen fonts.
Printer fonts are pure outline fonts and can be rotated, scaled,
printed, etc. Screen fonts may only be used when drawing on the screen,
and can't (safely) be rotated, scaled, or printed. NSFont will (most of
the time) return printer fonts, and there are methods for getting the
corresponding screen font, if there is one. Depending on the font and
the backend, a screen font may be a normal outline font, or it may be a
hinted outline or a bitmap font.

Most of -gui will use screen fonts when available as screen fonts have
better legibility.

The problem in this case is that, although the hinted outlines can be
scaled, the scaled metrics don't match the scaled outlines. At small
sizes, hinting tends to distort the glyph shapes a lot (to make them
more legible), and layout is done using the metrics for these hinted
glyphs. When you scale things up, the glyph outlines will be less
distorted (relatively), so there'll be a gap between the metrics of the
scaled outline, and the scaled metrics.

The text system currently draws glyphs in batches of (up to) 16. The
small gaps add up, so when the text system sets the position for the
17th glyph explicitly (using the layout information), there'll be a big
gap.

The solution is to not use screen fonts when drawing scaled or rotated
text. If there was a safe and reasonably efficient way of checking
whether the current coordinate system was scaled or rotated, I could
check this in the NSStringDrawing methods and automatically call
[NSLayoutManager -setUsesScreenFonts:]. Otherwise, I'd suggest using the
text system directly (ie. do what NSStringDrawing does, but handle these
issues yourself).

- Alexander Malmberg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]