1 /*
2 * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
442 FontStrike fontStrike,
443 float ptSize,
444 float[] mat,
445 MemorySegment hbface,
446 char[] text,
447 GVData gvData,
448 int script,
449 int offset,
450 int limit,
451 int baseIndex,
452 Point2D.Float startPt,
453 int flags,
454 int slot) {
455
456 /*
457 * ScopedValue is needed so that call backs into Java during
458 * shaping can locate the correct instances of these to query or update.
459 * The alternative of creating bound method handles is far too slow.
460 */
461 ScopedVars vars = new ScopedVars(font2D, fontStrike, gvData, startPt);
462 ScopedValue.where(scopedVars, vars)
463 .run(() -> {
464
465 try (Arena arena = Arena.ofConfined()) {
466
467 float startX = (float)startPt.getX();
468 float startY = (float)startPt.getY();
469
470 MemorySegment matrix = arena.allocateFrom(JAVA_FLOAT, mat);
471 MemorySegment chars = arena.allocateFrom(JAVA_CHAR, text);
472
473 /*int ret =*/ jdk_hb_shape_handle.invokeExact(
474 ptSize, matrix, hbface, chars, text.length,
475 script, offset, limit,
476 baseIndex, startX, startY, flags, slot,
477 hb_jdk_font_funcs_struct,
478 store_layout_results_stub);
479 } catch (Throwable t) {
480 }
481 });
482 }
483
484 private static int getFontTableData(Font2D font2D,
|
1 /*
2 * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
442 FontStrike fontStrike,
443 float ptSize,
444 float[] mat,
445 MemorySegment hbface,
446 char[] text,
447 GVData gvData,
448 int script,
449 int offset,
450 int limit,
451 int baseIndex,
452 Point2D.Float startPt,
453 int flags,
454 int slot) {
455
456 /*
457 * ScopedValue is needed so that call backs into Java during
458 * shaping can locate the correct instances of these to query or update.
459 * The alternative of creating bound method handles is far too slow.
460 */
461 ScopedVars vars = new ScopedVars(font2D, fontStrike, gvData, startPt);
462 ScopedValue.runWhere(scopedVars, vars, () -> {
463 try (Arena arena = Arena.ofConfined()) {
464
465 float startX = (float)startPt.getX();
466 float startY = (float)startPt.getY();
467
468 MemorySegment matrix = arena.allocateFrom(JAVA_FLOAT, mat);
469 MemorySegment chars = arena.allocateFrom(JAVA_CHAR, text);
470
471 /*int ret =*/ jdk_hb_shape_handle.invokeExact(
472 ptSize, matrix, hbface, chars, text.length,
473 script, offset, limit,
474 baseIndex, startX, startY, flags, slot,
475 hb_jdk_font_funcs_struct,
476 store_layout_results_stub);
477 } catch (Throwable t) {
478 }
479 });
480 }
481
482 private static int getFontTableData(Font2D font2D,
|