On Thu, 11 Jun 2020 00:12:39 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> This addresses https://bugs.openjdk.java.net/browse/JDK-8246348
>
> modules/javafx.graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java
>  line 87:
> 
>> 86:
>> 87:     private Map<TextRun, Long> runUtf8 = new HashMap<>();
>> 88:     public void layout(TextRun run, PGFont font, FontStrike strike, 
>> char[] text) {
> 
> In order for this to work, each TextRun would need to be immutable (at least 
> during the life of this PangoGlyphLayout)
> and there would need to be a 1-1 mapping between the TextRun and the string 
> pointer, independent of anything else. Is
> this the case? I'm seeing some crashes in OSPango.g_utf8_offset_to_pointer 
> when testing. I don't know if they are
> related to this or not.

I would assume that once the layout method is called, the TextRun won't change 
anymore. If it would change, the current
code might break as well, as the string pointer is currently cached. I agree 
though that this is a brittle approach.
What I'm basically doing here is store additional information (the number of 
unicode codepoints rather than the number
of UTF 16 chars, which can then be mapped to the string pointer pointing to the 
relevant substring) on the TextRun, but
since I didn't want to modify TextRun, that additional info is stored in this 
Map. I'd prefer modifying TextRun though.

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

PR: https://git.openjdk.java.net/jfx/pull/249

Reply via email to