mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 05:40:56 +00:00
Corrected baseline for font with different point size. Added primitiv
support for super/subscript as baseline change of 3 points. The baseline correction is only done for the current chunk not for the whole line. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1443b2f132
commit
884ca03135
1 changed files with 17 additions and 6 deletions
|
@ -484,13 +484,12 @@ drawRun(GSTextRun *run, NSPoint origin, GSDrawInfo *draw)
|
||||||
*/
|
*/
|
||||||
if (draw->flip)
|
if (draw->flip)
|
||||||
{
|
{
|
||||||
origin.y += (run->height - run->baseline);
|
origin.y -= run->base;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
origin.y -= (run->height - run->baseline);
|
origin.y += run->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set current font and color if necessary.
|
* Set current font and color if necessary.
|
||||||
*/
|
*/
|
||||||
|
@ -602,14 +601,18 @@ setupRun(GSTextRun *run, unsigned length, unichar *chars, unsigned pos,
|
||||||
// Get superscript
|
// Get superscript
|
||||||
num = (NSNumber*)[attr objectForKey: NSSuperscriptAttributeName];
|
num = (NSNumber*)[attr objectForKey: NSSuperscriptAttributeName];
|
||||||
if (num == nil)
|
if (num == nil)
|
||||||
run->superscript = 0;
|
run->base = 0.0;
|
||||||
|
//run->superscript = 0;
|
||||||
else
|
else
|
||||||
run->superscript = [num intValue];
|
// interprete as a baseline change without font change
|
||||||
|
run->base = 3.0 * [num intValue];
|
||||||
|
//run->superscript = [num intValue];
|
||||||
|
|
||||||
// Get baseline offset
|
// Get baseline offset
|
||||||
num = (NSNumber*)[attr objectForKey: NSBaselineOffsetAttributeName];
|
num = (NSNumber*)[attr objectForKey: NSBaselineOffsetAttributeName];
|
||||||
if (num == nil)
|
if (num == nil)
|
||||||
run->base = 0.0;
|
; // Use value from superscript!
|
||||||
|
//run->base = 0.0;
|
||||||
else
|
else
|
||||||
run->base = [num floatValue];
|
run->base = [num floatValue];
|
||||||
|
|
||||||
|
@ -716,6 +719,14 @@ drawChunk(GSTextChunk *chunk, NSPoint origin, GSDrawInfo *draw)
|
||||||
GSTextRun *run = &chunk->run0;
|
GSTextRun *run = &chunk->run0;
|
||||||
|
|
||||||
origin.x += chunk->xpos;
|
origin.x += chunk->xpos;
|
||||||
|
if (draw->flip)
|
||||||
|
{
|
||||||
|
origin.y += (chunk->height - chunk->baseline);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
origin.y -= (chunk->height - chunk->baseline);
|
||||||
|
}
|
||||||
while (run != 0)
|
while (run != 0)
|
||||||
{
|
{
|
||||||
drawRun(run, origin, draw);
|
drawRun(run, origin, draw);
|
||||||
|
|
Loading…
Reference in a new issue