186 }
187
188 /* Do an initial approximation, in root */
189 root = a > b ? a + (b / 2) : b + (a / 2);
190
191 /* An unrolled Newton-Raphson iteration sequence */
192 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
193 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
194 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
195
196 return root;
197 }
198
199 JDKFontInfo*
200 createJDKFontInfo(JNIEnv *env,
201 jobject font2D,
202 jobject fontStrike,
203 jfloat ptSize,
204 jlong pScaler,
205 jlong pNativeFont,
206 jfloatArray matrix,
207 jboolean aat) {
208
209
210 JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
211 if (!fi) {
212 return NULL;
213 }
214 fi->env = env; // this is valid only for the life of this JNI call.
215 fi->font2D = font2D;
216 fi->fontStrike = fontStrike;
217 fi->nativeFont = pNativeFont;
218 fi->aat = aat;
219 (*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
220 fi->ptSize = ptSize;
221 fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
222 fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
223 if (!aat && (getenv("HB_NODEVTX") != NULL)) {
224 fi->devScale = fi->xPtSize / fi->ptSize;
225 } else {
226 fi->devScale = 1.0f;
227 }
228 return fi;
229 }
230
231
232 #define TYPO_KERN 0x00000001
233 #define TYPO_LIGA 0x00000002
234 #define TYPO_RTL 0x80000000
235
236 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
237 (JNIEnv *env, jclass cls,
238 jobject font2D,
239 jobject fontStrike,
240 jfloat ptSize,
241 jfloatArray matrix,
242 jlong pScaler,
243 jlong pNativeFont,
244 jboolean aat,
245 jcharArray text,
246 jobject gvdata,
247 jint script,
248 jint offset,
249 jint limit,
250 jint baseIndex,
251 jobject startPt,
252 jint flags,
253 jint slot) {
254
255 hb_buffer_t *buffer;
256 hb_font_t* hbfont;
257 jchar *chars;
258 jsize len;
259 int glyphCount;
260 hb_glyph_info_t *glyphInfo;
261 hb_glyph_position_t *glyphPos;
262 hb_direction_t direction = HB_DIRECTION_LTR;
263 hb_feature_t *features = NULL;
264 int featureCount = 0;
265 char* kern = (flags & TYPO_KERN) ? "kern" : "-kern";
266 char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga";
267 jboolean ret;
268 unsigned int buflen;
269
270 JDKFontInfo *jdkFontInfo =
271 createJDKFontInfo(env, font2D, fontStrike, ptSize,
272 pScaler, pNativeFont, matrix, aat);
273 if (!jdkFontInfo) {
274 return JNI_FALSE;
275 }
276 jdkFontInfo->env = env; // this is valid only for the life of this JNI call.
277 jdkFontInfo->font2D = font2D;
278 jdkFontInfo->fontStrike = fontStrike;
279
280 hbfont = hb_jdk_font_create(jdkFontInfo, NULL);
281
282 buffer = hb_buffer_create();
283 hb_buffer_set_script(buffer, getHBScriptCode(script));
284 hb_buffer_set_language(buffer,
285 hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
286 if ((flags & TYPO_RTL) != 0) {
287 direction = HB_DIRECTION_RTL;
288 }
289 hb_buffer_set_direction(buffer, direction);
290 hb_buffer_set_cluster_level(buffer,
291 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
292
|
186 }
187
188 /* Do an initial approximation, in root */
189 root = a > b ? a + (b / 2) : b + (a / 2);
190
191 /* An unrolled Newton-Raphson iteration sequence */
192 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
193 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
194 root = (root + (a * (a / root)) + (b * (b / root)) + 1) / 2;
195
196 return root;
197 }
198
199 JDKFontInfo*
200 createJDKFontInfo(JNIEnv *env,
201 jobject font2D,
202 jobject fontStrike,
203 jfloat ptSize,
204 jlong pScaler,
205 jlong pNativeFont,
206 jlong layoutTables,
207 jfloatArray matrix,
208 jboolean aat) {
209
210
211 JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
212 if (!fi) {
213 return NULL;
214 }
215 fi->env = env; // this is valid only for the life of this JNI call.
216 fi->font2D = font2D;
217 fi->fontStrike = fontStrike;
218 fi->nativeFont = pNativeFont;
219 fi->layoutTables = (TTLayoutTableCache*)layoutTables;
220 fi->aat = aat;
221 (*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
222 fi->ptSize = ptSize;
223 fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
224 fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
225 if (!aat && (getenv("HB_NODEVTX") != NULL)) {
226 fi->devScale = fi->xPtSize / fi->ptSize;
227 } else {
228 fi->devScale = 1.0f;
229 }
230 return fi;
231 }
232
233
234 #define TYPO_KERN 0x00000001
235 #define TYPO_LIGA 0x00000002
236 #define TYPO_RTL 0x80000000
237
238 JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
239 (JNIEnv *env, jclass cls,
240 jobject font2D,
241 jobject fontStrike,
242 jfloat ptSize,
243 jfloatArray matrix,
244 jlong pScaler,
245 jlong pNativeFont,
246 jlong layoutTables,
247 jboolean aat,
248 jcharArray text,
249 jobject gvdata,
250 jint script,
251 jint offset,
252 jint limit,
253 jint baseIndex,
254 jobject startPt,
255 jint flags,
256 jint slot) {
257
258 hb_buffer_t *buffer;
259 hb_font_t* hbfont;
260 jchar *chars;
261 jsize len;
262 int glyphCount;
263 hb_glyph_info_t *glyphInfo;
264 hb_glyph_position_t *glyphPos;
265 hb_direction_t direction = HB_DIRECTION_LTR;
266 hb_feature_t *features = NULL;
267 int featureCount = 0;
268 char* kern = (flags & TYPO_KERN) ? "kern" : "-kern";
269 char* liga = (flags & TYPO_LIGA) ? "liga" : "-liga";
270 jboolean ret;
271 unsigned int buflen;
272
273 JDKFontInfo *jdkFontInfo =
274 createJDKFontInfo(env, font2D, fontStrike, ptSize,
275 pScaler, pNativeFont, layoutTables, matrix, aat);
276 if (!jdkFontInfo) {
277 return JNI_FALSE;
278 }
279 jdkFontInfo->env = env; // this is valid only for the life of this JNI call.
280 jdkFontInfo->font2D = font2D;
281 jdkFontInfo->fontStrike = fontStrike;
282
283 hbfont = hb_jdk_font_create(jdkFontInfo, NULL);
284
285 buffer = hb_buffer_create();
286 hb_buffer_set_script(buffer, getHBScriptCode(script));
287 hb_buffer_set_language(buffer,
288 hb_ot_tag_to_language(HB_OT_TAG_DEFAULT_LANGUAGE));
289 if ((flags & TYPO_RTL) != 0) {
290 direction = HB_DIRECTION_RTL;
291 }
292 hb_buffer_set_direction(buffer, direction);
293 hb_buffer_set_cluster_level(buffer,
294 HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
295
|