Re: Generating ligature glyphs
Re: Generating ligature glyphs
- Subject: Re: Generating ligature glyphs
- From: Rolland Bryan <email@hidden>
- Date: Mon, 31 Oct 2005 12:03:46 +0200
- Thread-topic: Generating ligature glyphs
Aki,
Thank you for your response. Please excuse the long post ;-)
It seems to me that what you propose has many difficulties. Consider the
following scenario. The geometry of my text container is a circular hole,
with text being laid out to either side. For the line of text "This is line
layout using the ATS typesetter to perform the ..." positioned halfway down
the the circle (breaking after "layout using" and "typesetter to"),
NSATSTypesetter performs the following calls:
[NSATSTypesetter layoutParagraphAtPoint]
[NSATSTypesetter beginParagraph]
[NSATSTypesetter beginLineWithGlyphAtIndex:]
[NSATSTypesetter
getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:...]
[NSATSTypesetter
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:]
[NSATSTypesetter setLocation:withAdvancements:forStartOfGlyphRange:]
[NSATSTypesetter endLineWithGlyphRange: ] ==> (This is line layout using )
[NSATSTypesetter beginLineWithGlyphAtIndex:]
[NSATSTypesetter
getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:...]
[NSATSTypesetter
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:]
[NSATSTypesetter setLocation:withAdvancements:forStartOfGlyphRange:]
[NSATSTypesetter endLineWithGlyphRange: ] ==> (the ATS typesetter to )
[NSATSTypesetter beginLineWithGlyphAtIndex:]
[NSATSTypesetter
getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:...]
[NSATSTypesetter
setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:]
[NSATSTypesetter setLocation:withAdvancements:forStartOfGlyphRange:]
[NSATSTypesetter endLineWithGlyphRange: ] ==> (perform the ...)
[NSATSTypesetter endParagraph]
NSATSTypesetter, insists on treating each fragment as a new line. By the
time you detect a change in baseline, it's too late. Not calling
endLineWithGlyphRange along the way does not provide a means to restart the
line, which it would have to because of the non-rectangular nature of the
geometry.
By the way, this default behaviour of NSATSTypesetter is not useful, because
the approach results in glyphs on one line being laid out on top of glyphs
of other lines -- This happens if (in the example above) the left hand
fragment has sufficiently bigger glyphs than the right hand fragment.
Given that neither NSLayoutManager nor NSATSTypesetter provide a way to get
the glyph information I need, perhaps you could suggest where I should begin
to get to understand how to work with the font tables.
Rolland
On 10/28/05 8:32 PM, "Aki Inoue" <email@hidden> wrote:
> Rolland,
>
> In Tiger, we added -endLineWithGlyphRange: to NSTypesetter. The
> invocation of this method at the end of a line layout session
> "commits" the result.
>
> In other words, you could decide not commit by overriding this method
> if you found a conflict between the last line fragment and previous
> ones, and retrace.
>
>> My typesetter is working nicely, but I just need to know how to get
>> the
>> ligatures and their glyphs.
> Since the ligature mapping is context dependent, we don't offer
> simple ligature glyph query. If you really want to go this approach,
> you need to parse font tables by yourself unfortunately.
>
> Aki
>
>> Aki,
>>
>> I am subclassing NSATSTypesetter, and that is what I hoped to do.
>> However,
>> when one has an NSTextContainer with a geometry that creates a
>> (non-rectangular) hole across which lines must be laid out,
>> NSATSTypesetter
>> does not maintain a common baseline across the entire line. Rather
>> it treats
>> each fragment on each side of the hole as completely independent
>> lines. This
>> also ends up jumbling up lines and laying fragments on top of one
>> another.
>>
>> I also thought I could override (void)
>> willSetLineFragmentRect:(NSRectPointer)lineRect forGlyphRange:
>> (NSRange)glyphRange usedRect:(NSRectPointer)usedRect baselineOffset:
>> (float *)baselineOffset;
>>
>> However, if a later fragment in the line needed a lower baseline, I
>> would
>> have to somehow retrace my steps, in sync with NSATSTypesetter.
>>
>> My typesetter is working nicely, but I just need to know how to get
>> the
>> ligatures and their glyphs.
>>
>> Rolland
>>
>>
>> On 10/27/05 10:34 PM, "Aki Inoue" <email@hidden> wrote:
>>
>>> Rolland,
>>>
>>> It would be much much easier just to subclass NSATSTypesetter than to
>>> write your own engine.
>>>
>>> The starting point for you would be to override - (void)
>>> willSetLineFragmentRect:(NSRectPointer)lineRect forGlyphRange:
>>> (NSRange)glyphRange usedRect:(NSRectPointer)usedRect baselineOffset:
>>> (float *)baselineOffset;
>>>
>>> Aki
>>>
>>>> Thank you for your response.
>>>>
>>>> I am writing a typesetter.
>>>>
>>>> I use getGlyphsInRange:... to obtain the necessary information to
>>>> calculate
>>>> line breaks etc. So my precise question is, how do I use the font
>>>> information to (a) determine which glyph sequence should be
>>>> replaced with
>>>> ligature glyph(s) and (b) to obtain the actual NSGlyph representing
>>>> the
>>>> ligature?
>>>>
>>>> What determines that f¹ followed by i¹ should be a ligature,
>>>> and, how does
>>>> one get the fi¹ ligature glyph to do the replacement?
>>>>
>>>> This would probably also answer the question as to how to get the
>>>> right
>>>> hyphen glyph. I see that NSATSTypesetter uses the undocumented call
>>>> hyphenGlyphForLocale: on NSFont.
>>>>
>>>> One of the reasons I need to write my own typesetter (in addition
>>>> to it
>>>> being really interesting) is that I need different behaviour to the
>>>> way
>>>> NSATSTypesetter lays out text on a line interrupted by a shape:
>>>> NSATSTypesetter treats the left and right sides as independent
>>>> lines; I want
>>>> a common baseline and height.
>>>>
>>>> Rolland Bryan
>>>>
>>>>
>>>> On 10/26/05 8:00 PM, "Douglas Davidson" <email@hidden> wrote:
>>>>
>>>>>
>>>>> On Oct 26, 2005, at 4:40 AM, Rolland Bryan wrote:
>>>>>
>>>>>>
>>>>>> How does one force NSLayoutManager to generate ligature glyphs?
>>>>>>
>>>>>
>>>>> There are many sorts of ligatures, but for e.g an "fi" ligature,
>>>>> what will
>>>>> happen is that during glyph generation, the glyph generator will
>>>>> generate the
>>>>> standard "f" and "i" glyphs. During layout, the typesetter will
>>>>> determine
>>>>> from font information that an "fi" ligature is available, and then
>>>>> replace the
>>>>> "f" glyph with the "fi" ligature glyph and the "i" glyph with a
>>>>> padding null
>>>>> glyph. Generation of the ligature happens during layout because
>>>>> it depends on
>>>>> the "f" and the "i" actually appearing adjacent to each other on
>>>>> the same line
>>>>> of text. The process is controlled to some extent by text
>>>>> attributes; for
>>>>> example, NSLigatureAttributeName can be set to 0 to suppress
>>>>> ligatures of this
>>>>> sort.
>>>>>
>>>>> If you would explain what it is that you are trying to do, and
>>>>> what you are
>>>>> seeing, perhaps it would be possible to give more detailed
>>>>> guidance.
>>>>>
>>>>> Douglas Davidson
>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Cocoa-dev mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden