617
618
619 JNIEXPORT jlong JNICALL OS_NATIVE(CFStringCreateWithCharacters__J_3CJJ)
620 (JNIEnv *env, jclass that, jlong arg0, jcharArray arg1, jlong arg2, jlong arg3)
621 {
622 jchar *lparg1=NULL;
623 jlong rc = 0;
624 if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
625 UniChar* str = lparg1 + arg2;
626 rc = (jlong)CFStringCreateWithCharacters((CFAllocatorRef)arg0, str, (CFIndex)arg3);
627 fail:
628 if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
629 return rc;
630 }
631
632 JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetGlyphs)
633 (JNIEnv *env, jclass that, jlong runRef, jint slotMask, jint start, jintArray bufferRef)
634 {
635 CTRunRef run = (CTRunRef)runRef;
636 const CGGlyph * glyphs = CTRunGetGlyphsPtr(run);
637 int i = 0;
638 if (glyphs) {
639 jint* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
640 if (buffer) {
641 CFIndex count = CTRunGetGlyphCount(run);
642 while(i < count) {
643 buffer[start + i] = slotMask | (glyphs[i] & 0xFFFF);
644 i++;
645 }
646 (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
647 }
648 }
649 return i;
650 }
651
652 JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetPositions)
653 (JNIEnv *env, jclass that, jlong runRef, jint start, jfloatArray bufferRef)
654 {
655 CTRunRef run = (CTRunRef)runRef;
656 const CGPoint* positions = CTRunGetPositionsPtr(run);
657 int j = 0;
658 if (positions) {
659 jfloat* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
660 if (buffer) {
661 CFIndex count = CTRunGetGlyphCount(run);
662 int i = 0;
663 while (i < count) {
664 CGPoint pos = positions[i++];
665 buffer[start + j++] = pos.x;
666 buffer[start + j++] = pos.y;
667 }
668 (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
|
617
618
619 JNIEXPORT jlong JNICALL OS_NATIVE(CFStringCreateWithCharacters__J_3CJJ)
620 (JNIEnv *env, jclass that, jlong arg0, jcharArray arg1, jlong arg2, jlong arg3)
621 {
622 jchar *lparg1=NULL;
623 jlong rc = 0;
624 if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
625 UniChar* str = lparg1 + arg2;
626 rc = (jlong)CFStringCreateWithCharacters((CFAllocatorRef)arg0, str, (CFIndex)arg3);
627 fail:
628 if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
629 return rc;
630 }
631
632 JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetGlyphs)
633 (JNIEnv *env, jclass that, jlong runRef, jint slotMask, jint start, jintArray bufferRef)
634 {
635 CTRunRef run = (CTRunRef)runRef;
636 const CGGlyph * glyphs = CTRunGetGlyphsPtr(run);
637 CFIndex count = CTRunGetGlyphCount(run);
638 if(count == 0) {
639 return 0;
640 }
641
642 CGGlyph* tempGlyphs = NULL;
643 if(!glyphs)
644 {
645 tempGlyphs = (CGGlyph*) malloc(count * sizeof(CGGlyph));
646 if(!tempGlyphs) {
647 return 0;
648 }
649
650 CTRunGetGlyphs(run, CFRangeMake(0 ,0), tempGlyphs);
651 glyphs = tempGlyphs;
652 }
653
654 int i = 0;
655 if (glyphs) {
656 jint* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
657 if (buffer) {
658 while(i < count) {
659 buffer[start + i] = slotMask | (glyphs[i] & 0xFFFF);
660 i++;
661 }
662 (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
663 }
664 }
665
666 if(tempGlyphs) {
667 free(tempGlyphs);
668 }
669 return i;
670 }
671
672 JNIEXPORT jint JNICALL OS_NATIVE(CTRunGetPositions)
673 (JNIEnv *env, jclass that, jlong runRef, jint start, jfloatArray bufferRef)
674 {
675 CTRunRef run = (CTRunRef)runRef;
676 const CGPoint* positions = CTRunGetPositionsPtr(run);
677 int j = 0;
678 if (positions) {
679 jfloat* buffer = (*env)->GetPrimitiveArrayCritical(env, bufferRef, NULL);
680 if (buffer) {
681 CFIndex count = CTRunGetGlyphCount(run);
682 int i = 0;
683 while (i < count) {
684 CGPoint pos = positions[i++];
685 buffer[start + j++] = pos.x;
686 buffer[start + j++] = pos.y;
687 }
688 (*env)->ReleasePrimitiveArrayCritical(env, bufferRef, buffer, 0);
|