Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Commit 0b50683

Browse files
author
arajkumar
committed
8209191: [macOS] Distorted complex text rendering
Reviewed-by: kcr, prr
1 parent 19876b9 commit 0b50683

File tree

1 file changed

+20
-1
lines changed
  • modules/javafx.graphics/src/main/native-font

1 file changed

+20
-1
lines changed

modules/javafx.graphics/src/main/native-font/coretext.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,26 @@ JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetPositions)
673673
{
674674
CTRunRef run = (CTRunRef)runRef;
675675
const CGPoint* positions = CTRunGetPositionsPtr(run);
676+
CFIndex count = CTRunGetGlyphCount(run);
677+
if (count == 0) {
678+
return 0;
679+
}
680+
681+
CGPoint* tempPositions = NULL;
682+
if (!positions) {
683+
tempPositions = (CGPoint*) malloc(count * sizeof(CGPoint));
684+
if (!tempPositions) {
685+
return 0;
686+
}
687+
688+
CTRunGetPositions(run, CFRangeMake(0, 0), tempPositions);
689+
positions = tempPositions;
690+
}
691+
676692
int j = 0;
677693
if (positions) {
678694
jfloat* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
679695
if (buffer) {
680-
CFIndex count = CTRunGetGlyphCount(run);
681696
int i = 0;
682697
while (i < count) {
683698
CGPoint pos = positions[i++];
@@ -687,6 +702,10 @@ JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetPositions)
687702
(*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
688703
}
689704
}
705+
706+
if (tempPositions) {
707+
free(tempPositions);
708+
}
690709
return j;
691710
}
692711

0 commit comments

Comments
 (0)