mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 01:40:38 +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
|
@ -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…
Add table
Add a link
Reference in a new issue