author | erikj |
Mon, 01 Oct 2018 11:02:33 -0700 | |
branch | JEP-230-microbenchmarks-branch |
changeset 56912 | d434fc4d10aa |
parent 50840 | 1db5917dfe1c |
child 54232 | 7c11a7cc7c1d |
permissions | -rw-r--r-- |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
1 |
/* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
4 |
* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
10 |
* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
15 |
* accompanied this code). |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
16 |
* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
20 |
* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
23 |
* questions. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
24 |
*/ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
25 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
26 |
#include "hb.h" |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
27 |
#include "hb-jdk.h" |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
28 |
#ifdef MACOSX |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
29 |
#include "hb-coretext.h" |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
30 |
#endif |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
31 |
#include <stdlib.h> |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
32 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
33 |
#if defined(__GNUC__) && __GNUC__ >= 4 |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
34 |
#define HB_UNUSED __attribute__((unused)) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
35 |
#else |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
36 |
#define HB_UNUSED |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
37 |
#endif |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
38 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
39 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
40 |
hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
41 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
42 |
hb_codepoint_t unicode, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
43 |
hb_codepoint_t variation_selector, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
44 |
hb_codepoint_t *glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
45 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
46 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
47 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
48 |
JDKFontInfo *jdkFontInfo = (JDKFontInfo*)font_data; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
49 |
JNIEnv* env = jdkFontInfo->env; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
50 |
jobject font2D = jdkFontInfo->font2D; |
50840 | 51 |
if (variation_selector == 0) { |
52 |
*glyph = (hb_codepoint_t)env->CallIntMethod( |
|
53 |
font2D, sunFontIDs.f2dCharToGlyphMID, unicode); |
|
54 |
} else { |
|
55 |
*glyph = (hb_codepoint_t)env->CallIntMethod( |
|
56 |
font2D, sunFontIDs.f2dCharToVariationGlyphMID, |
|
57 |
unicode, variation_selector); |
|
58 |
} |
|
59 |
if (env->ExceptionOccurred()) |
|
60 |
{ |
|
61 |
env->ExceptionClear(); |
|
62 |
} |
|
43826
ff4d8d468f68
8172967: [macosx] Exception while working with layout for text containing unmappable character
prr
parents:
43232
diff
changeset
|
63 |
if ((int)*glyph < 0) { |
ff4d8d468f68
8172967: [macosx] Exception while working with layout for text containing unmappable character
prr
parents:
43232
diff
changeset
|
64 |
*glyph = 0; |
ff4d8d468f68
8172967: [macosx] Exception while working with layout for text containing unmappable character
prr
parents:
43232
diff
changeset
|
65 |
} |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
66 |
return (*glyph != 0); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
67 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
68 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
69 |
static hb_position_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
70 |
hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
71 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
72 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
73 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
74 |
{ |
43232 | 75 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
76 |
float fadv = 0.0f; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
77 |
if ((glyph & 0xfffe) == 0xfffe) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
78 |
return 0; // JDK uses this glyph code. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
79 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
80 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
81 |
JDKFontInfo *jdkFontInfo = (JDKFontInfo*)font_data; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
82 |
JNIEnv* env = jdkFontInfo->env; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
83 |
jobject fontStrike = jdkFontInfo->fontStrike; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
84 |
jobject pt = env->CallObjectMethod(fontStrike, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
85 |
sunFontIDs.getGlyphMetricsMID, glyph); |
43232 | 86 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
87 |
if (pt == NULL) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
88 |
return 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
89 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
90 |
fadv = env->GetFloatField(pt, sunFontIDs.xFID); |
40712 | 91 |
fadv *= jdkFontInfo->devScale; |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
92 |
env->DeleteLocalRef(pt); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
93 |
|
41003
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
94 |
return HBFloatToFixed(fadv); |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
95 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
96 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
97 |
static hb_position_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
98 |
hb_jdk_get_glyph_v_advance (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
99 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
100 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
101 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
102 |
{ |
43232 | 103 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
104 |
float fadv = 0.0f; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
105 |
if ((glyph & 0xfffe) == 0xfffe) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
106 |
return 0; // JDK uses this glyph code. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
107 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
108 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
109 |
JDKFontInfo *jdkFontInfo = (JDKFontInfo*)font_data; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
110 |
JNIEnv* env = jdkFontInfo->env; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
111 |
jobject fontStrike = jdkFontInfo->fontStrike; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
112 |
jobject pt = env->CallObjectMethod(fontStrike, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
113 |
sunFontIDs.getGlyphMetricsMID, glyph); |
43232 | 114 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
115 |
if (pt == NULL) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
116 |
return 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
117 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
118 |
fadv = env->GetFloatField(pt, sunFontIDs.yFID); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
119 |
env->DeleteLocalRef(pt); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
120 |
|
41003
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
121 |
return HBFloatToFixed(fadv); |
43232 | 122 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
123 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
124 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
125 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
126 |
hb_jdk_get_glyph_h_origin (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
127 |
void *font_data HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
128 |
hb_codepoint_t glyph HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
129 |
hb_position_t *x HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
130 |
hb_position_t *y HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
131 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
132 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
133 |
/* We always work in the horizontal coordinates. */ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
134 |
return true; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
135 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
136 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
137 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
138 |
hb_jdk_get_glyph_v_origin (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
139 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
140 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
141 |
hb_position_t *x, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
142 |
hb_position_t *y, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
143 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
144 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
145 |
return false; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
146 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
147 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
148 |
static hb_position_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
149 |
hb_jdk_get_glyph_h_kerning (hb_font_t *font, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
150 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
151 |
hb_codepoint_t lejdk_glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
152 |
hb_codepoint_t right_glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
153 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
154 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
155 |
/* Not implemented. This seems to be in the HB API |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
156 |
* as a way to fall back to Freetype's kerning support |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
157 |
* which could be based on some on-the fly glyph analysis. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
158 |
* But more likely it reads the kern table. That is easy |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
159 |
* enough code to add if we find a need to fall back |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
160 |
* to that instead of using gpos. It seems like if |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
161 |
* there is a gpos table at all, the practice is to |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
162 |
* use that and ignore kern, no matter that gpos does |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
163 |
* not implement the kern feature. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
164 |
*/ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
165 |
return 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
166 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
167 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
168 |
static hb_position_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
169 |
hb_jdk_get_glyph_v_kerning (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
170 |
void *font_data HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
171 |
hb_codepoint_t top_glyph HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
172 |
hb_codepoint_t bottom_glyph HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
173 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
174 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
175 |
/* OpenType doesn't have vertical-kerning other than GPOS. */ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
176 |
return 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
177 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
178 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
179 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
180 |
hb_jdk_get_glyph_extents (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
181 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
182 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
183 |
hb_glyph_extents_t *extents, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
184 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
185 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
186 |
/* TODO */ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
187 |
return false; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
188 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
189 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
190 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
191 |
hb_jdk_get_glyph_contour_point (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
192 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
193 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
194 |
unsigned int point_index, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
195 |
hb_position_t *x, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
196 |
hb_position_t *y, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
197 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
198 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
199 |
if ((glyph & 0xfffe) == 0xfffe) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
200 |
*x = 0; *y = 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
201 |
return true; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
202 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
203 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
204 |
JDKFontInfo *jdkFontInfo = (JDKFontInfo*)font_data; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
205 |
JNIEnv* env = jdkFontInfo->env; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
206 |
jobject fontStrike = jdkFontInfo->fontStrike; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
207 |
jobject pt = env->CallObjectMethod(fontStrike, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
208 |
sunFontIDs.getGlyphPointMID, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
209 |
glyph, point_index); |
43232 | 210 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
211 |
if (pt == NULL) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
212 |
*x = 0; *y = 0; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
213 |
return true; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
214 |
} |
41003
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
215 |
*x = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID)); |
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
216 |
*y = HBFloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID)); |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
217 |
env->DeleteLocalRef(pt); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
218 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
219 |
return true; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
220 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
221 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
222 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
223 |
hb_jdk_get_glyph_name (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
224 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
225 |
hb_codepoint_t glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
226 |
char *name, unsigned int size, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
227 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
228 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
229 |
return false; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
230 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
231 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
232 |
static hb_bool_t |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
233 |
hb_jdk_get_glyph_from_name (hb_font_t *font HB_UNUSED, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
234 |
void *font_data, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
235 |
const char *name, int len, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
236 |
hb_codepoint_t *glyph, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
237 |
void *user_data HB_UNUSED) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
238 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
239 |
return false; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
240 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
241 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
242 |
// remind : can we initialise this from the code we call |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
243 |
// from the class static method in Java to make it |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
244 |
// completely thread safe. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
245 |
static hb_font_funcs_t * |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
246 |
_hb_jdk_get_font_funcs (void) |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
247 |
{ |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
248 |
static hb_font_funcs_t *jdk_ffuncs = NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
249 |
hb_font_funcs_t *ff; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
250 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
251 |
if (!jdk_ffuncs) { |
43232 | 252 |
ff = hb_font_funcs_create(); |
253 |
||
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
254 |
hb_font_funcs_set_glyph_func(ff, hb_jdk_get_glyph, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
255 |
hb_font_funcs_set_glyph_h_advance_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
256 |
hb_jdk_get_glyph_h_advance, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
257 |
hb_font_funcs_set_glyph_v_advance_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
258 |
hb_jdk_get_glyph_v_advance, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
259 |
hb_font_funcs_set_glyph_h_origin_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
260 |
hb_jdk_get_glyph_h_origin, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
261 |
hb_font_funcs_set_glyph_v_origin_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
262 |
hb_jdk_get_glyph_v_origin, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
263 |
hb_font_funcs_set_glyph_h_kerning_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
264 |
hb_jdk_get_glyph_h_kerning, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
265 |
hb_font_funcs_set_glyph_v_kerning_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
266 |
hb_jdk_get_glyph_v_kerning, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
267 |
hb_font_funcs_set_glyph_extents_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
268 |
hb_jdk_get_glyph_extents, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
269 |
hb_font_funcs_set_glyph_contour_point_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
270 |
hb_jdk_get_glyph_contour_point, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
271 |
hb_font_funcs_set_glyph_name_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
272 |
hb_jdk_get_glyph_name, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
273 |
hb_font_funcs_set_glyph_from_name_func(ff, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
274 |
hb_jdk_get_glyph_from_name, NULL, NULL); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
275 |
hb_font_funcs_make_immutable(ff); // done setting functions. |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
276 |
jdk_ffuncs = ff; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
277 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
278 |
return jdk_ffuncs; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
279 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
280 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
281 |
static void _do_nothing(void) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
282 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
283 |
|
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
284 |
static void _free_nothing(void*) { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
285 |
} |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
286 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
287 |
static hb_blob_t * |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
288 |
reference_table(hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
289 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
290 |
JDKFontInfo *jdkFontInfo = (JDKFontInfo*)user_data; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
291 |
JNIEnv* env = jdkFontInfo->env; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
292 |
jobject font2D = jdkFontInfo->font2D; |
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
293 |
jsize length = 0; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
294 |
void* buffer = NULL; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
295 |
int cacheIdx = 0; |
43232 | 296 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
297 |
// HB_TAG_NONE is 0 and is used to get the whole font file. |
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
298 |
// It is not expected to be needed for JDK. |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
299 |
if (tag == 0 || jdkFontInfo->layoutTables == NULL) { |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
300 |
return NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
301 |
} |
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
302 |
|
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
303 |
for (cacheIdx=0; cacheIdx<LAYOUTCACHE_ENTRIES; cacheIdx++) { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
304 |
if (tag == jdkFontInfo->layoutTables->entries[cacheIdx].tag) break; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
305 |
} |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
306 |
|
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
307 |
if (cacheIdx < LAYOUTCACHE_ENTRIES) { // if found |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
308 |
if (jdkFontInfo->layoutTables->entries[cacheIdx].len != -1) { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
309 |
length = jdkFontInfo->layoutTables->entries[cacheIdx].len; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
310 |
buffer = (void*)jdkFontInfo->layoutTables->entries[cacheIdx].ptr; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
311 |
} |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
312 |
} |
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
313 |
|
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
314 |
if (buffer == NULL) { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
315 |
jbyteArray tableBytes = (jbyteArray) |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
316 |
env->CallObjectMethod(font2D, sunFontIDs.getTableBytesMID, tag); |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
317 |
if (tableBytes == NULL) { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
318 |
return NULL; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
319 |
} |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
320 |
length = env->GetArrayLength(tableBytes); |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
321 |
buffer = calloc(length, sizeof(jbyte)); |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
322 |
env->GetByteArrayRegion(tableBytes, 0, length, (jbyte*)buffer); |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
323 |
|
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
324 |
if (cacheIdx >= LAYOUTCACHE_ENTRIES) { // not a cacheable table |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
325 |
return hb_blob_create((const char *)buffer, length, |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
326 |
HB_MEMORY_MODE_WRITABLE, |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
327 |
buffer, free); |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
328 |
} else { |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
329 |
jdkFontInfo->layoutTables->entries[cacheIdx].len = length; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
330 |
jdkFontInfo->layoutTables->entries[cacheIdx].ptr = buffer; |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
331 |
} |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
332 |
} |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
333 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
334 |
return hb_blob_create((const char *)buffer, length, |
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
335 |
HB_MEMORY_MODE_READONLY, |
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
336 |
NULL, _free_nothing); |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
337 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
338 |
|
47188
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
339 |
|
0048f025c993
8186317: Cache font layout tables for use by harfbuzz
prr
parents:
43826
diff
changeset
|
340 |
|
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
341 |
hb_face_t* |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
342 |
hb_jdk_face_create(JDKFontInfo *jdkFontInfo, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
343 |
hb_destroy_func_t destroy) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
344 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
345 |
hb_face_t *face = |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
346 |
hb_face_create_for_tables(reference_table, jdkFontInfo, destroy); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
347 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
348 |
return face; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
349 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
350 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
351 |
static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
352 |
hb_destroy_func_t destroy) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
353 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
354 |
hb_font_t *font; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
355 |
hb_face_t *face; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
356 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
357 |
face = hb_jdk_face_create(jdkFontInfo, destroy); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
358 |
font = hb_font_create(face); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
359 |
hb_face_destroy (face); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
360 |
hb_font_set_funcs (font, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
361 |
_hb_jdk_get_font_funcs (), |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
362 |
jdkFontInfo, (hb_destroy_func_t) _do_nothing); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
363 |
hb_font_set_scale (font, |
41003
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
364 |
HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale), |
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
365 |
HBFloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale)); |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
366 |
return font; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
367 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
368 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
369 |
#ifdef MACOSX |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
370 |
static hb_font_t* _hb_jdk_ct_font_create(JDKFontInfo *jdkFontInfo) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
371 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
372 |
hb_font_t *font = NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
373 |
hb_face_t *face = NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
374 |
if (jdkFontInfo->nativeFont == 0) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
375 |
return NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
376 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
377 |
face = hb_coretext_face_create((CGFontRef)(jdkFontInfo->nativeFont)); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
378 |
font = hb_font_create(face); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
379 |
hb_face_destroy(face); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
380 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
381 |
hb_font_set_scale(font, |
41003
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
382 |
HBFloatToFixed(jdkFontInfo->ptSize), |
054df19db18c
8165345: JDK macro definition re-defined by MacOS core framework
prr
parents:
40988
diff
changeset
|
383 |
HBFloatToFixed(jdkFontInfo->ptSize)); |
34414
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
384 |
return font; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
385 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
386 |
#endif |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
387 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
388 |
hb_font_t* hb_jdk_font_create(JDKFontInfo *jdkFontInfo, |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
389 |
hb_destroy_func_t destroy) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
390 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
391 |
hb_font_t* font = NULL; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
392 |
|
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
393 |
#ifdef MACOSX |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
394 |
if (jdkFontInfo->aat) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
395 |
font = _hb_jdk_ct_font_create(jdkFontInfo); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
396 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
397 |
#endif |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
398 |
if (font == NULL) { |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
399 |
font = _hb_jdk_font_create(jdkFontInfo, destroy); |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
400 |
} |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
401 |
return font; |
e496a8d8fc8a
8143177: Integrate harfbuzz opentype layout engine per JEP 258
prr
parents:
diff
changeset
|
402 |
} |