On Tue, 4 Jun 2024 05:32:23 GMT, Karthik P K <k...@openjdk.org> wrote:

>> I think if this is specific to mac, and doesn't occur on other platforms 
>> that the supplied `positions` may be incorrect by the underlying 
>> `*GlyphLayout` code.  Under Windows it will likely use the `DWGlyphLayout` 
>> to supply `positions`.  On Mac this will be `CTGlyphLayout`.
>> 
>> The more prudent course of action than seems to be to fix what is supplied 
>> by `CTGlyphLayout` instead of working around it in `TextRun`.
>> 
>> I haven't checked it that extensively yet, but I think `positions` is not 
>> supposed to contain negative `x` values at all when not in compact mode.
>
> Yes the issue is specific to Mac only. Windows uses `DWGlyphLayout` for 
> positions as you pointed out.
> Since the position obtained from the underlying platform itself is not 
> correct Mac, looked like fixing it in either `TextRun`  or in the native side 
> does not make huge difference so went with this approach. However I will 
> explore how we can fix it on the native side.
> 
> If the `positions` is not supposed to contain negative value, it is an issue 
> from Apple not in JavaFX. In this case should we actually fix the issue in 
> JavaFX, as it becomes a workaround rather than a fix regardless of where we 
> fix it.

The `*GlyphLayout` classes are adapters for a platform.  Their job is to call 
native code, and to convert it to a standard format that JavaFX expects.  The 
native code for Apple is probably perfectly fine, but it is not adapted to the 
standard format correctly for the case that you discovered.  I'm suggesting 
therefore to change the `CTGlyphLayout` class to adapt/modify the `positions` 
array before it is given to JavaFX code that expects it to be in a specific 
format.

`CTGlyphLayout` calls:

            run.shape(glyphCount, glyphs, positions, indices);

It should not be too hard to fix `positions` passed here to be in the correct 
format so `TextRun` can remain unchanged.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1468#discussion_r1625493122

Reply via email to