11/*
2- * Copyright (C) 2016-2018 Muhammad Tayyab Akram
2+ * Copyright (C) 2016-2019 Muhammad Tayyab Akram
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -142,6 +142,31 @@ static jlong getClusterMapPtr(JNIEnv *env, jobject obj, jlong resultHandle)
142142 return reinterpret_cast <jlong>(charToGlyphMapPtr);
143143}
144144
145+ static void getCaretEdges (JNIEnv *env, jobject obj, jlong resultHandle,
146+ jbooleanArray caretStops, jfloatArray caretEdges)
147+ {
148+ ShapingResult *shapingResult = reinterpret_cast <ShapingResult *>(resultHandle);
149+ SFAlbumRef baseAlbum = shapingResult->sfAlbum ();
150+
151+ void *caretEdgesBuffer = env->GetPrimitiveArrayCritical (caretEdges, nullptr );
152+ void *caretStopsBuffer = nullptr ;
153+
154+ if (caretStops) {
155+ caretStopsBuffer = env->GetPrimitiveArrayCritical (caretStops, nullptr );
156+ }
157+
158+ SFBoolean *caretStopValues = static_cast <SFBoolean *>(caretStopsBuffer);
159+ SFFloat *caretEdgeValues = static_cast <SFFloat *>(caretEdgesBuffer);
160+
161+ SFFloat advanceScale = shapingResult->sizeByEm ();
162+ SFAlbumGetCaretEdges (baseAlbum, caretStopValues, advanceScale, caretEdgeValues);
163+
164+ if (caretStops) {
165+ env->ReleasePrimitiveArrayCritical (caretStops, caretStopsBuffer, 0 );
166+ }
167+ env->ReleasePrimitiveArrayCritical (caretEdges, caretEdgesBuffer, 0 );
168+ }
169+
145170static JNINativeMethod JNI_METHODS[] = {
146171 { " nCreate" , " ()J" , (void *)create },
147172 { " nDispose" , " (J)V" , (void *)dispose },
@@ -155,6 +180,7 @@ static JNINativeMethod JNI_METHODS[] = {
155180 { " nGetGlyphOffsetsPtr" , " (J)J" , (void *)getGlyphOffsetsPtr },
156181 { " nGetGlyphAdvancesPtr" , " (J)J" , (void *)getGlyphAdvancesPtr },
157182 { " nGetClusterMapPtr" , " (J)J" , (void *)getClusterMapPtr },
183+ { " nGetCaretEdges" , " (J[Z[F)V" , (void *)getCaretEdges },
158184};
159185
160186jint register_com_mta_tehreer_sfnt_ShapingResult (JNIEnv *env)
0 commit comments