On Mon, 27 Apr 2026 20:07:41 GMT, Daniel Gredler <[email protected]> wrote:

> When rendering Thai text, scaling fonts via `deriveFont(float)` seems to 
> always work correctly. However, when the font is scaled via 
> `deriveFont(AffineTransform)`, the vowels above the main line of text are 
> misplaced, mangling the meaning of the text.
> 
> This appears to be caused by GPOS adjustments performed by HarfBuzz which are 
> calculated at the wrong scale if the full (point size + AffineTransform) 
> scale is not provided to HarfBuzz upon font creation.
> 
> The fix must change both the FFM and JNI HarfBuzz integration code, so it 
> looks a bit longer than it actually is. The FFM and JNI changes were made in 
> separate commits, so it might be helpful to review only the FFM changes in a 
> first pass, and then have a look at the corresponding JNI changes (which are 
> in a separate commit).
> 
> Some observations:
> 
> - jdk_font_create_hbp() needs to incorporate font transform scaling, not just 
> the font point size scaling
> - jdk_font_create_hbp() needs two independent font scales / point sizes (x 
> and y)
> - jdk_font_create_hbp() applies devTx, only for it to be removed in 
> store_layout_results(); we might as well leave devTx out from the start
> 
> Sequence of changes made to the FFM code:
> 
> - Replace SDCache.gtx (glyph transform = font transform without translation, 
> plus point size scaling, plus device transform) with SDCache.ftx (font 
> transform including translation, plus point size scaling)
> - Remove SDCache.delta (just keep translation components in new ftx field 
> instead)
> - Remove SDCache.dtx (never used)
> - Remove devScale from store_layout_results() parameters (dev scale no longer 
> included during layout, so doesn't need to be undone here)
> - Remove destroy function param from jdk_font_create_hbp() (never used, 
> always NULL)
> - Calculate x and y font point sizes in jdk_hb_shape (based on full font 
> transform, including font pt size), instead of using only font pt size
> - Pass these x and y point sizes into jdk_font_create_hbp()
> - Remove now-unused ptSize parameter from jdk_font_create_hbp()
> - Remove now-unused devScale parameter from jdk_font_create_hbp()
> - Remove now-unused ptSize parameter from jdk_hb_shape()
> - Remove now-unused ptSize parameter from HBShaper.shape()
> 
> Sequence of changes made to the JNI code:
> 
> - Remove destroy function from _hb_jdk_font_create(), not used just like in 
> FFM code
> - Use xPtSize and yPtSize in _hb_jdk_font_create(), instead of ptSize and 
> devScale
> - Remove devScale from storeGVData (not used during layout, so doesn't need 
> to be undone at the end)
> - Remove now...

Could you merge master into this PR branch ? A couple of the files were changed 
by 8378603.

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

PR Comment: https://git.openjdk.org/jdk/pull/30953#issuecomment-4338681647

Reply via email to