mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
* Source/GSLayoutManager.m:
* Source/GSHorizontalTypesetter.m: * Headers/Additions/GNUstepGUI/GSLayoutManager_internal.h: * Headers/Additions/GNUstepGUI/GSLayoutManager.h: Store glyph advances in the runs in GSLayoutManager. Extend the NSGlyphStorage protocol to support a case where the glyph generator provides the glyph advances. I'm hoping to use this in the future to implement (optional) glyph generators which are wrappers around HarfBuzz or the ICU OpenType layout engine. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33684 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3ad54a9a3c
commit
5d897881e4
5 changed files with 106 additions and 17 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2011-08-02 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSLayoutManager.m:
|
||||
* Source/GSHorizontalTypesetter.m:
|
||||
* Headers/Additions/GNUstepGUI/GSLayoutManager_internal.h:
|
||||
* Headers/Additions/GNUstepGUI/GSLayoutManager.h: Store
|
||||
glyph advances in the runs in GSLayoutManager. Extend the
|
||||
NSGlyphStorage protocol to support a case where the glyph
|
||||
generator provides the glyph advances.
|
||||
|
||||
I'm hoping to use this in the future to implement (optional)
|
||||
glyph generators which are wrappers around HarfBuzz or the ICU
|
||||
OpenType layout engine.
|
||||
|
||||
2011-08-02 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Images/common_SwitchOff.tiff:
|
||||
|
|
|
@ -159,6 +159,16 @@ If characters have been edited, lengthChange has the text length delta.
|
|||
changeInLength: (int)lengthChange
|
||||
invalidatedRange: (NSRange)invalidatedRange;
|
||||
|
||||
/**
|
||||
* GNUstep extension
|
||||
*/
|
||||
- (void) insertGlyphs: (const NSGlyph*)glyph_list
|
||||
withAdvancements: (const NSSize*)advancements
|
||||
length: (NSUInteger)length
|
||||
forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||
characterIndex: (NSUInteger)index;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -217,6 +227,11 @@ invalid (extends beyond the end of glyphs). */
|
|||
(NSRangeException?) */
|
||||
- (unsigned int) characterIndexForGlyphAtIndex: (unsigned int)glyphIndex;
|
||||
|
||||
/**
|
||||
* GNUstep extension
|
||||
*/
|
||||
- (NSSize) advancementForGlyphAtIndex: (unsigned int)glyphIndex;
|
||||
|
||||
/* Returns the range of glyphs for the characters in charRange. If
|
||||
actualRange isn't NULL, the exact range of characters for the glyphs in the
|
||||
returned range is returned there. */
|
||||
|
|
|
@ -91,6 +91,8 @@ typedef struct
|
|||
unsigned int soft:1;
|
||||
unsigned int elasitc:1;
|
||||
unsigned int bidilevel:7; // Need to support 0..61
|
||||
|
||||
NSSize advancement;
|
||||
} glyph_t;
|
||||
|
||||
|
||||
|
|
|
@ -250,6 +250,9 @@ the last time or not, we wouldn't need to clear the cache every time */
|
|||
|
||||
g->dont_show = NO;
|
||||
g->outside_line_frag = NO;
|
||||
|
||||
// FIXME: This assumes the layout manager implements this GNUstep extension
|
||||
g->size = [curLayoutManager advancementForGlyphAtIndex: cache_base + cache_length];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,17 +686,6 @@ restart: ;
|
|||
|
||||
NSFont *f = cache->font;
|
||||
|
||||
/*
|
||||
TODO: This is kindof ugly, but -advancementForGlyph: is responsible for
|
||||
~10% of execution time when handling huge amounts of text (according to
|
||||
profiling, 2004-08-09). Would be cleaner to get rid of the font/fontInfo
|
||||
indirection.
|
||||
*/
|
||||
id fontInfo = [f fontInfo];
|
||||
NSSize (*advancementForGlyph)(id, SEL, NSGlyph)
|
||||
= (NSSize(*)(id, SEL, NSGlyph))[fontInfo methodForSelector:
|
||||
@selector(advancementForGlyph:)];
|
||||
|
||||
float f_ascender = [f ascender], f_descender = -[f descender];
|
||||
|
||||
NSGlyph last_glyph = NSNullGlyph;
|
||||
|
@ -771,9 +763,6 @@ restart: ;
|
|||
{
|
||||
float new_height;
|
||||
f = g->font;
|
||||
fontInfo = [f fontInfo];
|
||||
advancementForGlyph = (NSSize(*)(id, SEL, NSGlyph))
|
||||
[fontInfo methodForSelector: @selector(advancementForGlyph:)];
|
||||
f_ascender = [f ascender];
|
||||
f_descender = -[f descender];
|
||||
last_glyph = NSNullGlyph;
|
||||
|
@ -983,9 +972,6 @@ restart: ;
|
|||
|
||||
last_p = g->pos = p;
|
||||
/* Only the width is used. */
|
||||
g->size = advancementForGlyph(fontInfo,
|
||||
@selector(advancementForGlyph:),
|
||||
g->g);
|
||||
p.x += g->size.width;
|
||||
}
|
||||
|
||||
|
|
|
@ -990,6 +990,43 @@ Fills in all glyph holes up to last. only looking at levels below level
|
|||
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
|
||||
actualGlyphRange: (NSRange *)actualGlyphRange
|
||||
{
|
||||
|
@ -3130,7 +3167,11 @@ has).
|
|||
return _textStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* GNUstep extension
|
||||
*/
|
||||
- (void) insertGlyphs: (const NSGlyph*)glyph_list
|
||||
withAdvancements: (const NSSize*)advancements
|
||||
length: (NSUInteger)length
|
||||
forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||
characterIndex: (NSUInteger)index
|
||||
|
@ -3172,10 +3213,41 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
|
|||
// We expect to get a nominal glyph run
|
||||
g->char_offset = i + index - cpos;
|
||||
g->g = glyph_list[i];
|
||||
g->advancement = advancements[i];
|
||||
g++;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) insertGlyphs: (const NSGlyph*)glyph_list
|
||||
length: (NSUInteger)length
|
||||
forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||
characterIndex: (NSUInteger)index
|
||||
{
|
||||
glyph_run_t *run;
|
||||
int i;
|
||||
unsigned int gpos, cpos;
|
||||
NSSize advances[length];
|
||||
|
||||
run = run_for_character_index(index, glyphs, &gpos, &cpos);
|
||||
if (!run)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"%s glyph index out of range", __PRETTY_FUNCTION__];
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
advances[i] = [run->font advancementForGlyph: glyph_list[i]];
|
||||
}
|
||||
|
||||
[self insertGlyphs: glyph_list
|
||||
withAdvancements: advances
|
||||
length: length
|
||||
forStartingGlyphAtIndex: glyph
|
||||
characterIndex: index];
|
||||
}
|
||||
|
||||
- (NSUInteger) layoutOptions
|
||||
{
|
||||
NSUInteger options = 0;
|
||||
|
|
Loading…
Reference in a new issue