feat(core): render local CJK glyphs at 2x texture resolution (#4304)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
Taku Fukada
2026-07-01 20:52:01 +09:00
committed by GitHub
parent 60f15190c3
commit 887e6021e6
22 changed files with 357 additions and 84 deletions

View File

@@ -267,11 +267,15 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
builtInOffset = {0.0f, 0.0f};
}
// rectBuffer is in 1x logical units; only rect.w/h carry the texture
// scale. GL JS keeps 2x glyphs centered by storing fractional
// left/top metrics, so native local glyphs do the same.
const float textureScale = positionedGlyph.metrics.isDoubleResolution ? 2.0f : 1.0f;
const float x1 = (positionedGlyph.metrics.left - rectBuffer) * positionedGlyph.scale - halfAdvance +
builtInOffset.x;
const float y1 = (-positionedGlyph.metrics.top - rectBuffer) * positionedGlyph.scale + builtInOffset.y;
const float x2 = x1 + rect.w * positionedGlyph.scale / pixelRatio;
const float y2 = y1 + rect.h * positionedGlyph.scale / pixelRatio;
const float x2 = x1 + rect.w / textureScale * positionedGlyph.scale / pixelRatio;
const float y2 = y1 + rect.h / textureScale * positionedGlyph.scale / pixelRatio;
Point<float> tl{x1, y1};
Point<float> tr{x2, y1};