Author: fredkiefer
Date: Sun Oct 23 22:13:37 2016
New Revision: 40167
URL: http://svn.gna.org/viewcvs/gnustep?rev=40167&view=rev
Log:
* Source/GSLayoutManager.m (-advancementForGlyphAtIndex:):
Simplify this method and move it in the file.
* Source/NSLayoutManager.m: Use the pre-computed advancement
instead of calculating it every time.
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/GSLayoutManager.m
libs/gui/trunk/Source/NSLayoutManager.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=40167&r1=40166&r2=40167&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Sun Oct 23 22:13:37 2016
@@ -1,3 +1,10 @@
+2016-10-23 Fred Kiefer <[email protected]>
+
+ * Source/GSLayoutManager.m (-advancementForGlyphAtIndex:):
+ Simplify this method and move it in the file.
+ * Source/NSLayoutManager.m: Use the pre-computed advancement
+ instead of calculating it every time.
+
2016-10-22 Fred Kiefer <[email protected]>
* Source/GSLayoutManager.m: Don't try to get the advancement for
Modified: libs/gui/trunk/Source/GSLayoutManager.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/GSLayoutManager.m?rev=40167&r1=40166&r2=40167&view=diff
==============================================================================
--- libs/gui/trunk/Source/GSLayoutManager.m (original)
+++ libs/gui/trunk/Source/GSLayoutManager.m Sun Oct 23 22:13:37 2016
@@ -984,43 +984,6 @@
}
return cpos + r->glyphs[glyphIndex - pos].char_offset;
-}
-
-/**
- * GNUstep extension
- */
-- (NSSize) advancementForGlyphAtIndex: (unsigned int)glyphIndex
-{
- glyph_run_t *r;
- unsigned int pos, cpos;
-
- if (glyphs->glyph_length <= glyphIndex)
- {
- [self _generateGlyphsUpToGlyph: glyphIndex];
- if (glyphs->glyph_length <= glyphIndex)
- {
- [NSException raise: NSRangeException
- format: @"%s glyph index out of range",
__PRETTY_FUNCTION__];
- return NSMakeSize(0,0);
- }
- }
-
- r = run_for_glyph_index(glyphIndex, glyphs, &pos, &cpos);
- if (!r)
- {
- [NSException raise: NSRangeException
- format: @"%s glyph index out of range",
__PRETTY_FUNCTION__];
- return NSMakeSize(0,0);
- }
-
- if (r->head.glyph_length <= glyphIndex - pos)
- {
- [NSException raise: NSRangeException
- format: @"%s internal error!", __PRETTY_FUNCTION__];
- return NSMakeSize(0,0);
- }
-
- return r->glyphs[glyphIndex - pos].advancement;
}
- (NSRange) characterRangeForGlyphRange: (NSRange)glyphRange
@@ -1677,6 +1640,15 @@
if (range)
*range = NSMakeRange(pos, r->head.glyph_length);
return r->font;
+}
+
+/**
+ * GNUstep extension
+ */
+- (NSSize) advancementForGlyphAtIndex: (unsigned int)idx
+{
+ GET_GLYPH
+ return r->glyphs[idx].advancement;
}
- (void) insertGlyph: (NSGlyph)aGlyph
Modified: libs/gui/trunk/Source/NSLayoutManager.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSLayoutManager.m?rev=40167&r1=40166&r2=40167&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSLayoutManager.m (original)
+++ libs/gui/trunk/Source/NSLayoutManager.m Sun Oct 23 22:13:37 2016
@@ -193,7 +193,6 @@
{
NSRange r;
NSPoint p;
- NSFont *f;
NSUInteger i;
r = [self rangeOfNominallySpacedGlyphsContainingIndex: glyphIndex
@@ -205,19 +204,9 @@
return NSMakePoint(0, 0);
}
- i = r.location;
- f = [self effectiveFontForGlyphAtIndex: i
- range: &r];
- /* TODO: this is rather inefficient and doesn't deal with non-shown
- glyphs */
- for (; i < glyphIndex; i++)
- {
- if (i == r.location + r.length)
- {
- f = [self effectiveFontForGlyphAtIndex: i
- range: &r];
- }
- p.x += [f advancementForGlyph: [self glyphAtIndex: i]].width;
+ for (i = r.location; i < glyphIndex; i++)
+ {
+ p.x += [self advancementForGlyphAtIndex: i].width;
}
return p;
}
@@ -330,7 +319,7 @@
if (!r->glyphs[i].isNotShown && r->glyphs[i].g &&
r->glyphs[i].g != NSControlGlyph)
{
- x0 += [r->font advancementForGlyph: r->glyphs[i].g].width;
+ x0 += r->glyphs[i].advancement.width;
}
GLYPH_STEP_FORWARD(r, i, gpos, cpos)
}
@@ -377,7 +366,7 @@
if (!r->glyphs[i].isNotShown && r->glyphs[i].g &&
r->glyphs[i].g != NSControlGlyph)
{
- x1 += [r->font advancementForGlyph: r->glyphs[i].g].width;
+ x1 += r->glyphs[i].advancement.width;
}
GLYPH_STEP_FORWARD(r, i, gpos, cpos)
}
@@ -777,7 +766,7 @@
}
last_visible = j + glyph_pos;
- cur = prev + [r->font advancementForGlyph: r->glyphs[j].g].width;
+ cur = prev + r->glyphs[j].advancement.width;
if (j + glyph_pos + 1 == lp->pos + lp->length && next > cur)
cur = next;
@@ -960,7 +949,7 @@
if (!r->glyphs[i].isNotShown && r->glyphs[i].g &&
r->glyphs[i].g != NSControlGlyph)
{
- x0 += [r->font advancementForGlyph: r->glyphs[i].g].width;
+ x0 += r->glyphs[i].advancement.width;
}
GLYPH_STEP_FORWARD(r, i, gpos, cpos)
}
@@ -968,7 +957,7 @@
if (!r->glyphs[i].isNotShown && r->glyphs[i].g &&
r->glyphs[i].g != NSControlGlyph)
{
- x1 += [r->font advancementForGlyph: r->glyphs[i].g].width;
+ x1 += r->glyphs[i].advancement.width;
}
}
@@ -1864,7 +1853,7 @@
if (!gbuf_len)
{
gbuf[0] = glyph->g;
- advancementbuf[0] = [f advancementForGlyph: glyph->g];
+ advancementbuf[0] = glyph->advancement;
gbuf_point = p;
gbuf_len = 1;
}
@@ -1879,11 +1868,11 @@
gbuf_point = p;
}
gbuf[gbuf_len] = glyph->g;
- advancementbuf[gbuf_len] = [f advancementForGlyph: glyph->g];
+ advancementbuf[gbuf_len] = glyph->advancement;
gbuf_len++;
}
}
- p.x += [f advancementForGlyph: glyph->g].width;
+ p.x += glyph->advancement.width;
}
}
if (gbuf_len)
@@ -2184,7 +2173,7 @@
start.y += [largestFont pointSize] * 0.07;
end.y += [largestFont pointSize] * 0.07;
- end.x += [largestFont advancementForGlyph: [self glyphAtIndex:
(NSMaxRange(glyphRangeToDraw) - 1)]].width;
+ end.x += [self advancementForGlyphAtIndex:
(NSMaxRange(glyphRangeToDraw) - 1)].width;
start = NSMakePoint(start.x + containerOrigin.x +
fragmentRect.origin.x, start.y + containerOrigin.y + fragmentRect.origin.y);
end = NSMakePoint(end.x + containerOrigin.x + fragmentRect.origin.x,
end.y + containerOrigin.y + fragmentRect.origin.y);
@@ -2234,7 +2223,7 @@
start.y += [largestFont pointSize] * 0.07;
end.y += [largestFont pointSize] * 0.07;
- end.x += [largestFont advancementForGlyph: [self glyphAtIndex:
(NSMaxRange(range) - 1)]].width;
+ end.x += [self advancementForGlyphAtIndex: (NSMaxRange(range) - 1)].width;
start = NSMakePoint(start.x + containerOrigin.x + fragmentRect.origin.x,
start.y + containerOrigin.y + fragmentRect.origin.y);
end = NSMakePoint(end.x + containerOrigin.x + fragmentRect.origin.x, end.y +
containerOrigin.y + fragmentRect.origin.y);
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs