mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Improve calculation of line height and baseline.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15907 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4648c930ce
commit
e06aff244d
3 changed files with 23 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
|||
2003-02-08 22:53 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/GSFontInfo.m (-defaultLineHeightForFont),
|
||||
Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): Improve
|
||||
calculation of line height and make it match the baseline calculation
|
||||
when typesetting.
|
||||
|
||||
2003-02-08 22:29 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSWindow.m (-sendEvent:): On right mouse down, check if
|
||||
|
|
|
@ -342,8 +342,16 @@ static GSFontEnumerator *sharedEnumerator = nil;
|
|||
|
||||
- (float) defaultLineHeightForFont
|
||||
{
|
||||
// ascent plus descent plus some suitable linegap
|
||||
return [self ascender] - [self descender] + ceil([self pointSize]/ 11.0);
|
||||
/*
|
||||
Generally, roman text is centered in the line disregarding the descender,
|
||||
and the descender height is added above and below. Thus, the line height
|
||||
should be ascender_height+2*descender_height. (Note that descender is
|
||||
negative below the baseline.)
|
||||
|
||||
This calculation should match the baseline calculation in
|
||||
GSHorizontalTypesetter, or text will look odd.
|
||||
*/
|
||||
return [self ascender] - 2 * [self descender];
|
||||
}
|
||||
|
||||
- (NSSize) advancementForGlyph: (NSGlyph)aGlyph
|
||||
|
|
|
@ -367,10 +367,14 @@ typedef struct
|
|||
(TODO (optimization): if we're dealing with a "simple rectangular
|
||||
text container", we should try to extend the existing line frag in place
|
||||
before jumping back to do all the expensive checking).
|
||||
|
||||
Normally, baseline==ascender.
|
||||
*/
|
||||
|
||||
/*
|
||||
This calculation should match the calculation in [GSFontInfo
|
||||
-defaultLineHeightForFont], or text will look odd.
|
||||
*/
|
||||
#define COMPUTE_BASELINE baseline = line_height - descender
|
||||
|
||||
line_frag_t *line_frags = NULL;
|
||||
int num_line_frags = 0;
|
||||
|
||||
|
@ -394,8 +398,6 @@ typedef struct
|
|||
ascender = [cache->font ascender];
|
||||
descender = -[cache->font descender];
|
||||
|
||||
#define COMPUTE_BASELINE baseline = ascender
|
||||
|
||||
COMPUTE_BASELINE;
|
||||
|
||||
if (line_height < min)
|
||||
|
|
Loading…
Reference in a new issue