Guest User

Untitled

a guest
Jun 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.10 KB | None | 0 0
  1. diff --git a/jdk/src/java.desktop/share/classes/sun/font/CMap.java b/jdk/src/java.desktop/share/classes/sun/font/CMap.java
  2. index c52ee430..1049250c 100644
  3. --- a/jdk/src/java.desktop/share/classes/sun/font/CMap.java
  4. +++ b/jdk/src/java.desktop/share/classes/sun/font/CMap.java
  5. @@ -1095,10 +1095,6 @@ abstract class CMap {
  6. int numSelectors;
  7. int[] selector;
  8.  
  9. - //for Default UVS Table
  10. - int[] numUnicodeValueRanges;
  11. - int[][] startUnicodeValue;
  12. - short[][] additionalCount;
  13. //for Non-Default UVS Table
  14. int[] numUVSMapping;
  15. int[][] unicodeValue;
  16. @@ -1107,9 +1103,6 @@ abstract class CMap {
  17. UVS(ByteBuffer buffer, int offset) {
  18. numSelectors = buffer.getInt(offset+6);
  19. selector = new int[numSelectors];
  20. - numUnicodeValueRanges = new int[numSelectors];
  21. - startUnicodeValue = new int[numSelectors][];
  22. - additionalCount = new short[numSelectors][];
  23. numUVSMapping = new int[numSelectors];
  24. unicodeValue = new int[numSelectors][];
  25. glyphID = new char[numSelectors][];
  26. @@ -1120,28 +1113,10 @@ abstract class CMap {
  27. selector[i] += (buffer.get() & 0xff) << 8;
  28. selector[i] += buffer.get() & 0xff;
  29.  
  30. - //for Default UVS Table
  31. - int tableOffset = buffer.getInt(offset + 10 + i * 11 + 3);
  32. - if (tableOffset == 0) {
  33. - numUnicodeValueRanges[i] = 0;
  34. - } else if (tableOffset > 0) {
  35. - buffer.position(offset+tableOffset);
  36. - numUnicodeValueRanges[i] = buffer.getInt() & INTMASK;
  37. -
  38. - startUnicodeValue[i] = new int[numUnicodeValueRanges[i]];
  39. - additionalCount[i] = new short[numUnicodeValueRanges[i]];
  40. -
  41. - for (int j = 0; j < numUnicodeValueRanges[i]; j++) {
  42. - int temp = (buffer.get() & 0xff) << 16; //UINT24
  43. - temp += (buffer.get() & 0xff) << 8;
  44. - temp += buffer.get() & 0xff;
  45. - startUnicodeValue[i][j] = temp;
  46. - additionalCount[i][j] = (short)(buffer.get() & 0xff);
  47. - }
  48. - }
  49. + //skip Default UVS Table
  50.  
  51. //for Non-Default UVS Table
  52. - tableOffset = buffer.getInt(offset + 10 + i * 11 + 7);
  53. + int tableOffset = buffer.getInt(offset + 10 + i * 11 + 7);
  54. if (tableOffset == 0) {
  55. numUVSMapping[i] = 0;
  56. } else if (tableOffset > 0) {
  57. @@ -1161,14 +1136,7 @@ abstract class CMap {
  58. }
  59. }
  60.  
  61. - /* getGlyph for Variation selector
  62. - return value:
  63. - 0: A special glyph for the variation selector is Not found
  64. - -1: Default glyph should be used
  65. - 0>: A special glyph is found
  66. - */
  67. static final int VS_NOGLYPH = 0;
  68. - static final int VS_DEFAULT_GLYPH = -1;
  69. private int getGlyph(int charCode, int variationSelector) {
  70. int targetSelector = -1;
  71. for (int i = 0; i < numSelectors; i++) {
  72. @@ -1180,21 +1148,6 @@ abstract class CMap {
  73. if (targetSelector == -1) {
  74. return VS_NOGLYPH;
  75. }
  76. - if (numUnicodeValueRanges[targetSelector] > 0) {
  77. - int index = java.util.Arrays.binarySearch(
  78. - startUnicodeValue[targetSelector], charCode);
  79. - if (index >= 0) {
  80. - return VS_DEFAULT_GLYPH;
  81. - } else {
  82. - index = -index - 2;
  83. - if (index >= 0 &&
  84. - charCode >= startUnicodeValue[targetSelector][index] &&
  85. - charCode <= startUnicodeValue[targetSelector][index]
  86. - +additionalCount[targetSelector][index]) {
  87. - return VS_DEFAULT_GLYPH;
  88. - }
  89. - }
  90. - }
  91. if (numUVSMapping[targetSelector] > 0) {
  92. int index = java.util.Arrays.binarySearch(
  93. unicodeValue[targetSelector], charCode);
  94. @@ -1206,18 +1159,15 @@ abstract class CMap {
  95. }
  96. }
  97.  
  98. - char getGlyph(int charCode, int variationSelector, boolean allowFallback) {
  99. + char getVariationGlyph(int charCode, int variationSelector) {
  100. char glyph = 0;
  101. if (uvs == null) {
  102. - if (allowFallback) {
  103. - glyph = getGlyph(charCode);
  104. - }
  105. + glyph = getGlyph(charCode);
  106. } else {
  107. int result = uvs.getGlyph(charCode, variationSelector);
  108. if (result > 0) {
  109. glyph = (char)(result & 0xFFFF);
  110. - } else if (result == UVS.VS_DEFAULT_GLYPH ||
  111. - allowFallback) {
  112. + } else {
  113. glyph = getGlyph(charCode);
  114. }
  115. }
  116. diff --git a/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java
  117. index 59a49de5..1a1d48d7 100644
  118. --- a/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java
  119. +++ b/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java
  120. @@ -79,6 +79,11 @@ public abstract class CharToGlyphMapper {
  121. chars[0] = unicode;
  122. charsToGlyphs(1, chars, glyphs);
  123. return glyphs[0];
  124. + }
  125. +
  126. + public int charToVariationGlyph(int unicode, int variationSelector) {
  127. + // Override this if variation selector is supported.
  128. + return charToGlyph(unicode);
  129. }
  130.  
  131. public abstract int getNumGlyphs();
  132. @@ -92,34 +97,9 @@ public abstract class CharToGlyphMapper {
  133. public abstract void charsToGlyphs(int count,
  134. int[] unicodes, int[] glyphs);
  135.  
  136. - // Based on Unicode 10.0.0 chapter 23.4
  137. - public static boolean isVSBaseChar(int charCode) {
  138. - int type = Character.getType(charCode);
  139. - if (type == Character.UNASSIGNED ||
  140. - type == Character.CONTROL ||
  141. - type == Character.FORMAT ||
  142. - type == Character.NON_SPACING_MARK) {
  143. - return false;
  144. - }
  145. - return java.text.Normalizer.isNormalized(
  146. - java.nio.CharBuffer.wrap(Character.toChars(charCode)),
  147. - java.text.Normalizer.Form.NFD);
  148. - }
  149. -
  150. public static boolean isVariationSelector(int charCode) {
  151. return ((charCode >= VSS_START && charCode <= VSS_END) ||
  152. (charCode >= VS_START && charCode <= VS_END));
  153. }
  154.  
  155. - public static boolean isVariationSelectorBMP(char charCode) {
  156. - return (charCode >= VS_START && charCode <= VS_END);
  157. - }
  158. -
  159. - public static boolean isVariationSelectorExt(char charCode1,
  160. - char charCode2) {
  161. - return (charCode1 == 0xDB40 &&
  162. - (charCode2 >= 0xDD00 && charCode2 <= 0xDDEF));
  163. - // VSS_START - VSS_END
  164. - }
  165. -
  166. }
  167. diff --git a/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java
  168. index 70400631..379c3db4 100644
  169. --- a/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java
  170. +++ b/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java
  171. @@ -133,26 +133,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  172. return missingGlyph;
  173. }
  174.  
  175. - private int convertToGlyph(int unicode, int variationSelector) {
  176. - if (variationSelector == 0) {
  177. - return convertToGlyph(unicode);
  178. - }
  179. - for (int slot = 0; slot < font.numSlots; slot++) {
  180. - if (!hasExcludes || !font.isExcludedChar(slot, unicode)) {
  181. - CharToGlyphMapper mapper = getSlotMapper(slot);
  182. - if (mapper instanceof TrueTypeGlyphMapper) {
  183. - int glyphCode = ((TrueTypeGlyphMapper)mapper).
  184. - getGlyphOfVS(unicode, variationSelector);
  185. - if (glyphCode != mapper.getMissingGlyphCode()) {
  186. - glyphCode = compositeGlyphCode(slot, glyphCode);
  187. - return glyphCode;
  188. - }
  189. - }
  190. - }
  191. - }
  192. - return convertToGlyph(unicode); //retry without Variation Selector
  193. - }
  194. -
  195. public int getNumGlyphs() {
  196. int numGlyphs = 0;
  197. /* The number of glyphs in a composite is affected by
  198. @@ -225,9 +205,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  199. glyphs[i + 1] = INVISIBLE_GLYPH_ID;
  200. }
  201. }
  202. - if (isVariationSelector(code)) {
  203. - return charsToGlyphsNSVS(count, unicodes, glyphs);
  204. - }
  205.  
  206. int gc = glyphs[i] = getCachedGlyphCode(code);
  207. if (gc == UNINITIALIZED_GLYPH) {
  208. @@ -237,70 +214,8 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  209. if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
  210. continue;
  211. }
  212. - else if (FontUtilities.isComplexCharCode(code)) {
  213. - return true;
  214. - }
  215. - else if (code >= 0x10000) {
  216. - i += 1; // Empty glyph slot after surrogate
  217. - continue;
  218. - }
  219. - }
  220. -
  221. - return false;
  222. - }
  223. -
  224. - private boolean charsToGlyphsNSVS(int count, char[] unicodes,
  225. - int[] glyphs) {
  226. -
  227. - for (int i = 0; i < count; i++) {
  228. - int code = unicodes[i]; // char is unsigned.
  229. - int step = 1;
  230. - int variationSelector = 0;
  231. -
  232. - if (code >= HI_SURROGATE_START &&
  233. - code <= HI_SURROGATE_END && i < count - 1) {
  234. - char low = unicodes[i + 1];
  235. -
  236. - if (low >= LO_SURROGATE_START &&
  237. - low <= LO_SURROGATE_END) {
  238. - code = (code - HI_SURROGATE_START) *
  239. - 0x400 + low - LO_SURROGATE_START + 0x10000;
  240. - glyphs[i + 1] = INVISIBLE_GLYPH_ID;
  241. - step = 2;
  242. - }
  243. - }
  244. -
  245. - if (i < count - step &&
  246. - isVariationSelectorBMP(unicodes[i+step]) &&
  247. - isVSBaseChar(code)) {
  248. - variationSelector = unicodes[i+step];
  249. - glyphs[i] = convertToGlyph(code, variationSelector);
  250. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  251. - i += 1;
  252. - } else if (i < count - step -1 &&
  253. - isVariationSelectorExt(unicodes[i+step],
  254. - unicodes[i+step+1]) &&
  255. - isVSBaseChar(code)) {
  256. - variationSelector = (unicodes[i+step]
  257. - - HI_SURROGATE_START) * 0x400
  258. - + unicodes[i+step+1] - LO_SURROGATE_START
  259. - + 0x10000;
  260. - glyphs[i] = convertToGlyph(code, variationSelector);
  261. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  262. - glyphs[i+step+1] = INVISIBLE_GLYPH_ID;
  263. - i += 2;
  264. - }
  265. - if (variationSelector == 0) {
  266. - int gc = glyphs[i] = getCachedGlyphCode(code);
  267. - if (gc == UNINITIALIZED_GLYPH) {
  268. - glyphs[i] = convertToGlyph(code);
  269. - }
  270. - }
  271. -
  272. - if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
  273. - continue;
  274. - }
  275. - else if (FontUtilities.isComplexCharCode(code)) {
  276. + else if (FontUtilities.isComplexCharCode(code) ||
  277. + CharToGlyphMapper.isVariationSelector(code)) {
  278. return true;
  279. }
  280. else if (code >= 0x10000) {
  281. @@ -327,10 +242,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  282. low <= LO_SURROGATE_END) {
  283. code = (code - HI_SURROGATE_START) *
  284. 0x400 + low - LO_SURROGATE_START + 0x10000;
  285. - if (isVariationSelector(code)) {
  286. - charsToGlyphsVS(count, unicodes, glyphs);
  287. - return;
  288. - }
  289.  
  290. int gc = glyphs[i] = getCachedGlyphCode(code);
  291. if (gc == UNINITIALIZED_GLYPH) {
  292. @@ -340,9 +251,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  293. glyphs[i] = INVISIBLE_GLYPH_ID;
  294. continue;
  295. }
  296. - } else if (isVariationSelectorBMP(unicodes[i])) {
  297. - charsToGlyphsVS(count, unicodes, glyphs);
  298. - return;
  299. }
  300.  
  301. int gc = glyphs[i] = getCachedGlyphCode(code);
  302. @@ -352,65 +260,9 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  303. }
  304. }
  305.  
  306. - private void charsToGlyphsVS(int count, char[] unicodes, int[] glyphs) {
  307. - for (int i = 0; i < count; i++) {
  308. - int code = unicodes[i]; // char is unsigned.
  309. - int variationSelector = 0;
  310. - int step = 1;
  311. -
  312. - if (code >= HI_SURROGATE_START &&
  313. - code <= HI_SURROGATE_END && i < count - 1) {
  314. - char low = unicodes[i + 1];
  315. -
  316. - if (low >= LO_SURROGATE_START &&
  317. - low <= LO_SURROGATE_END) {
  318. - code = (code - HI_SURROGATE_START) *
  319. - 0x400 + low - LO_SURROGATE_START + 0x10000;
  320. -
  321. - glyphs[i+1] = INVISIBLE_GLYPH_ID;
  322. - step = 2;
  323. - }
  324. - }
  325. -
  326. - if (i < count - step &&
  327. - isVariationSelectorBMP(unicodes[i+step]) &&
  328. - isVSBaseChar(code)) {
  329. - variationSelector = unicodes[i+step];
  330. - glyphs[i] = convertToGlyph(code, variationSelector);
  331. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  332. - i += 1;
  333. - } else if (i < count - step -1 &&
  334. - isVariationSelectorExt(unicodes[i+step],
  335. - unicodes[i+step+1]) &&
  336. - isVSBaseChar(code)) {
  337. - variationSelector = (unicodes[i+step]
  338. - - HI_SURROGATE_START) * 0x400
  339. - + unicodes[i+step+1] - LO_SURROGATE_START
  340. - + 0x10000;
  341. - glyphs[i] = convertToGlyph(code, variationSelector);
  342. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  343. - glyphs[i+step+1] = INVISIBLE_GLYPH_ID;
  344. - i += 2;
  345. - }
  346. - if (variationSelector == 0) {
  347. - int gc = glyphs[i] = getCachedGlyphCode(code);
  348. - if (gc == UNINITIALIZED_GLYPH) {
  349. - glyphs[i] = convertToGlyph(code);
  350. - }
  351. - }
  352. - if (code >= 0x10000) {
  353. - i++;
  354. - }
  355. - }
  356. - }
  357. -
  358. public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) {
  359. for (int i=0; i<count; i++) {
  360. int code = unicodes[i];
  361. - if (isVariationSelector(code)) {
  362. - charsToGlyphsVS(count, unicodes, glyphs);
  363. - return;
  364. - }
  365.  
  366. glyphs[i] = getCachedGlyphCode(code);
  367. if (glyphs[i] == UNINITIALIZED_GLYPH) {
  368. @@ -419,23 +271,4 @@ public class CompositeGlyphMapper extends CharToGlyphMapper {
  369. }
  370. }
  371.  
  372. - private void charsToGlyphsVS(int count, int[] unicodes, int[] glyphs) {
  373. - for (int i = 0; i < count; i++) {
  374. - int code = unicodes[i];
  375. -
  376. - if (i < count-1 &&
  377. - isVariationSelector(unicodes[i+1]) &&
  378. - isVSBaseChar(code) ) {
  379. - glyphs[i] = convertToGlyph(code, unicodes[i+1]);
  380. - glyphs[i+1] = INVISIBLE_GLYPH_ID;
  381. - i++;
  382. - } else {
  383. - glyphs[i] = getCachedGlyphCode(code);
  384. - if (glyphs[i] == UNINITIALIZED_GLYPH) {
  385. - glyphs[i] = convertToGlyph(code);
  386. - }
  387. - }
  388. - }
  389. - }
  390. -
  391. }
  392. diff --git a/jdk/src/java.desktop/share/classes/sun/font/Font2D.java b/jdk/src/java.desktop/share/classes/sun/font/Font2D.java
  393. index 1b560aef..e4cdc216 100644
  394. --- a/jdk/src/java.desktop/share/classes/sun/font/Font2D.java
  395. +++ b/jdk/src/java.desktop/share/classes/sun/font/Font2D.java
  396. @@ -524,8 +524,8 @@ public abstract class Font2D {
  397. return getMapper().charToGlyph(wchar);
  398. }
  399.  
  400. - public void charsToGlyphs(int count, int[] wchars, int[] glyphs) {
  401. - getMapper().charsToGlyphs(count, wchars, glyphs);
  402. + public int charToVariationGlyph(int wchar, int variationSelector) {
  403. + return getMapper().charToVariationGlyph(wchar, variationSelector);
  404. }
  405.  
  406. public int getMissingGlyphCode() {
  407. diff --git a/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java b/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java
  408. index 1303fd5d..d20b1006 100644
  409. --- a/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java
  410. +++ b/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java
  411. @@ -119,40 +119,8 @@ public final class FontRunIterator {
  412.  
  413. int ch = nextCodePoint(lim);
  414. int sl = mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK;
  415. - int secondPosition = pos;
  416. - int preChar = ch;
  417. - boolean consumed = false;
  418. slot = sl >>> 24;
  419. - while ((ch = nextCodePoint(lim)) != DONE ) {
  420. - if (CharToGlyphMapper.isVariationSelector(ch) &&
  421. - CharToGlyphMapper.isVSBaseChar(preChar) &&
  422. - consumed == false) {
  423. - consumed = true;
  424. - int[] chars = {preChar, ch};
  425. - int[] glyphs = {0, 0};
  426. - mapper.charsToGlyphs(2, chars, glyphs);
  427. - int vsSize = 1;
  428. - if (ch >= 0x10000) {
  429. - vsSize = 2;
  430. - }
  431. - if (secondPosition + vsSize == pos) { // Real slot
  432. - sl = glyphs[0] & CompositeGlyphMapper.SLOTMASK;
  433. - slot = sl >>> 24;
  434. - }
  435. - if ((glyphs[0] & CompositeGlyphMapper.SLOTMASK) != sl) {
  436. - pushback(ch);
  437. - pushback(preChar);
  438. - return true;
  439. - }
  440. - } else {
  441. - consumed = false;
  442. - if ((mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK)
  443. - != sl) {
  444. - break;
  445. - }
  446. - }
  447. - preChar = ch;
  448. - }
  449. + while ((ch = nextCodePoint(lim)) != DONE && (mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) == sl);
  450. pushback(ch);
  451.  
  452. return true;
  453. diff --git a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java
  454. index ae9942a7..f3d86c07 100644
  455. --- a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java
  456. +++ b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java
  457. @@ -236,9 +236,7 @@ public final class FontUtilities {
  458. return
  459. isComplexCharCode(ch) ||
  460. (ch >= CharToGlyphMapper.HI_SURROGATE_START &&
  461. - ch <= CharToGlyphMapper.LO_SURROGATE_END) ||
  462. - (ch >= CharToGlyphMapper.VS_START &&
  463. - ch <= CharToGlyphMapper.VS_END);
  464. + ch <= CharToGlyphMapper.LO_SURROGATE_END);
  465. }
  466.  
  467. /* If the character code falls into any of a number of unicode ranges
  468. diff --git a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java
  469. index 8c612e87..7c628300 100644
  470. --- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java
  471. +++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java
  472. @@ -87,18 +87,19 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  473. }
  474. return (char)missingGlyph;
  475. }
  476. - } catch (Exception e) {
  477. + } catch(Exception e) {
  478. handleBadCMAP();
  479. return (char) missingGlyph;
  480. }
  481. }
  482.  
  483. - private char getGlyphFromCMAPVS(int charCode, int variationSelector) {
  484. + private char getGlyphFromCMAP(int charCode, int variationSelector) {
  485. if (variationSelector == 0) {
  486. return getGlyphFromCMAP(charCode);
  487. }
  488. try {
  489. - char glyphCode = cmap.getGlyph(charCode, variationSelector, true);
  490. + char glyphCode = cmap.getVariationGlyph(charCode,
  491. + variationSelector);
  492. if (glyphCode < numGlyphs ||
  493. glyphCode >= FileFontStrike.INVISIBLE_GLYPHS) {
  494. return glyphCode;
  495. @@ -113,8 +114,8 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  496. return (char)missingGlyph;
  497. }
  498. } catch (Exception e) {
  499. - handleBadCMAP();
  500. - return (char) missingGlyph;
  501. + handleBadCMAP();
  502. + return (char) missingGlyph;
  503. }
  504. }
  505.  
  506. @@ -161,12 +162,20 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  507. return glyph;
  508. }
  509.  
  510. + @Override
  511. + public int charToVariationGlyph(int unicode, int variationSelector) {
  512. + if (needsJAremapping) {
  513. + unicode = remapJAIntChar(unicode);
  514. + }
  515. + int glyph = getGlyphFromCMAP(unicode, variationSelector);
  516. + if (font.checkUseNatives() && glyph < font.glyphToCharMap.length) {
  517. + font.glyphToCharMap[glyph] = (char)unicode;
  518. + }
  519. + return glyph;
  520. + }
  521. +
  522. public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) {
  523. - for (int i = 0; i < count; i++) {
  524. - if (isVariationSelector(unicodes[i])) {
  525. - charsToGlyphsVS(count, unicodes, glyphs);
  526. - return;
  527. - }
  528. + for (int i=0;i<count;i++) {
  529. if (needsJAremapping) {
  530. glyphs[i] = getGlyphFromCMAP(remapJAIntChar(unicodes[i]));
  531. } else {
  532. @@ -179,37 +188,9 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  533. }
  534. }
  535.  
  536. - private void charsToGlyphsVS(int count, int[] unicodes, int[] glyphs) {
  537. - for (int i = 0; i < count; i++) {
  538. - if (i < count - 1 &&
  539. - isVariationSelector(unicodes[i + 1]) &&
  540. - isVSBaseChar(unicodes[i])) {
  541. - if (needsJAremapping) {
  542. - glyphs[i] = getGlyphFromCMAPVS(remapJAIntChar(unicodes[i]),
  543. - unicodes[i + 1]);
  544. - } else {
  545. - glyphs[i] = getGlyphFromCMAPVS(unicodes[i],
  546. - unicodes[i + 1]);
  547. - }
  548. - i++;
  549. - glyphs[i] = INVISIBLE_GLYPH_ID;
  550. - } else {
  551. - if (needsJAremapping) {
  552. - glyphs[i] = getGlyphFromCMAP(remapJAIntChar(unicodes[i]));
  553. - } else {
  554. - glyphs[i] = getGlyphFromCMAP(unicodes[i]);
  555. - }
  556. - if (font.checkUseNatives() &&
  557. - glyphs[i] < font.glyphToCharMap.length) {
  558. - font.glyphToCharMap[glyphs[i]] = (char)unicodes[i];
  559. - }
  560. - }
  561. - }
  562. - }
  563. -
  564. public void charsToGlyphs(int count, char[] unicodes, int[] glyphs) {
  565.  
  566. - for (int i = 0; i < count; i++) {
  567. + for (int i=0; i<count; i++) {
  568. int code;
  569. if (needsJAremapping) {
  570. code = remapJAChar(unicodes[i]);
  571. @@ -226,18 +207,11 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  572. code = (code - HI_SURROGATE_START) *
  573. 0x400 + low - LO_SURROGATE_START + 0x10000;
  574.  
  575. - if (isVariationSelector(code)) {
  576. - charsToGlyphsVS(count, unicodes, glyphs);
  577. - return;
  578. - }
  579. glyphs[i] = getGlyphFromCMAP(code);
  580. i += 1; // Empty glyph slot after surrogate
  581. glyphs[i] = INVISIBLE_GLYPH_ID;
  582. continue;
  583. }
  584. - } else if (isVariationSelectorBMP(unicodes[i])) {
  585. - charsToGlyphsVS(count, unicodes, glyphs);
  586. - return;
  587. }
  588. glyphs[i] = getGlyphFromCMAP(code);
  589.  
  590. @@ -249,64 +223,6 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  591. }
  592. }
  593.  
  594. - private void charsToGlyphsVS(int count, char[] unicodes, int[] glyphs) {
  595. - for (int i = 0; i < count; i++) {
  596. - int code;
  597. - int variationSelector = 0;
  598. - int step = 1;
  599. - if (needsJAremapping) {
  600. - code = remapJAChar(unicodes[i]);
  601. - } else {
  602. - code = unicodes[i]; // char is unsigned.
  603. - }
  604. -
  605. - if (code >= HI_SURROGATE_START &&
  606. - code <= HI_SURROGATE_END && i < count - 1) {
  607. - char low = unicodes[i + 1];
  608. -
  609. - if (low >= LO_SURROGATE_START &&
  610. - low <= LO_SURROGATE_END) {
  611. - code = (code - HI_SURROGATE_START) *
  612. - 0x400 + low - LO_SURROGATE_START + 0x10000;
  613. -
  614. - glyphs[i + 1] = INVISIBLE_GLYPH_ID;
  615. - step = 2;
  616. - }
  617. - }
  618. - if (i < count - step &&
  619. - isVariationSelectorBMP(unicodes[i + step]) &&
  620. - isVSBaseChar(code)) {
  621. - variationSelector = unicodes[i + step];
  622. - glyphs[i] = getGlyphFromCMAPVS(code, variationSelector);
  623. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  624. - i += 1;
  625. - } else if (i < count - step -1 &&
  626. - isVariationSelectorExt(unicodes[i + step],
  627. - unicodes[i + step + 1]) &&
  628. - isVSBaseChar(code)) {
  629. - variationSelector = (unicodes[i + step] - HI_SURROGATE_START)
  630. - * 0x400 + unicodes[i + step + 1]
  631. - - LO_SURROGATE_START + 0x10000;
  632. - glyphs[i] = getGlyphFromCMAPVS(code, variationSelector);
  633. - glyphs[i + step] = INVISIBLE_GLYPH_ID;
  634. - glyphs[i + step + 1] = INVISIBLE_GLYPH_ID;
  635. - i += 2;
  636. - }
  637. - if (variationSelector == 0) {
  638. - glyphs[i] = getGlyphFromCMAP(code);
  639. -
  640. - if (font.checkUseNatives() &&
  641. - glyphs[i] < font.glyphToCharMap.length) {
  642. - font.glyphToCharMap[glyphs[i]] = (char)code;
  643. - }
  644. - }
  645. - if (code >= 0x10000) {
  646. - i++;
  647. - }
  648. -
  649. - }
  650. - }
  651. -
  652. /* This variant checks if shaping is needed and immediately
  653. * returns true if it does. A caller of this method should be expecting
  654. * to check the return type because it needs to know how to handle
  655. @@ -314,7 +230,7 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  656. */
  657. public boolean charsToGlyphsNS(int count, char[] unicodes, int[] glyphs) {
  658.  
  659. - for (int i = 0; i < count; i++) {
  660. + for (int i=0; i<count; i++) {
  661. int code;
  662. if (needsJAremapping) {
  663. code = remapJAChar(unicodes[i]);
  664. @@ -333,9 +249,6 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  665. glyphs[i + 1] = INVISIBLE_GLYPH_ID;
  666. }
  667. }
  668. - if (isVariationSelector(code)) {
  669. - return charsToGlyphsNSVS(count, unicodes, glyphs);
  670. - }
  671.  
  672. glyphs[i] = getGlyphFromCMAP(code);
  673. if (font.checkUseNatives() &&
  674. @@ -346,74 +259,8 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  675. if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
  676. continue;
  677. }
  678. - else if (FontUtilities.isComplexCharCode(code)) {
  679. - return true;
  680. - }
  681. - else if (code >= 0x10000) {
  682. - i += 1; // Empty glyph slot after surrogate
  683. - continue;
  684. - }
  685. - }
  686. -
  687. - return false;
  688. - }
  689. -
  690. - private boolean charsToGlyphsNSVS(int count, char[] unicodes,
  691. - int[] glyphs) {
  692. - for (int i = 0; i < count; i++) {
  693. - int code;
  694. - int step = 1;
  695. - int variationSelector = 0;
  696. - if (needsJAremapping) {
  697. - code = remapJAChar(unicodes[i]);
  698. - } else {
  699. - code = unicodes[i]; // char is unsigned.
  700. - }
  701. -
  702. - if (code >= HI_SURROGATE_START &&
  703. - code <= HI_SURROGATE_END && i < count - 1) {
  704. - char low = unicodes[i + 1];
  705. -
  706. - if (low >= LO_SURROGATE_START &&
  707. - low <= LO_SURROGATE_END) {
  708. - code = (code - HI_SURROGATE_START) *
  709. - 0x400 + low - LO_SURROGATE_START + 0x10000;
  710. - glyphs[i + 1] = INVISIBLE_GLYPH_ID;
  711. - step = 2;
  712. - }
  713. - }
  714. -
  715. - if (i < count - step &&
  716. - isVariationSelectorBMP(unicodes[i + step]) &&
  717. - isVSBaseChar(code)) {
  718. - variationSelector = unicodes[i + step];
  719. - glyphs[i] = getGlyphFromCMAPVS(code, variationSelector);
  720. - glyphs[i+step] = INVISIBLE_GLYPH_ID;
  721. - i += 1;
  722. - } else if (i < count - step - 1 &&
  723. - isVariationSelectorExt(unicodes[i + step],
  724. - unicodes[i + step + 1]) &&
  725. - isVSBaseChar(code)) {
  726. - variationSelector = (unicodes[i + step] - HI_SURROGATE_START)
  727. - * 0x400 + unicodes[i + step + 1]
  728. - - LO_SURROGATE_START + 0x10000;
  729. - glyphs[i] = getGlyphFromCMAPVS(code, variationSelector);
  730. - glyphs[i + step] = INVISIBLE_GLYPH_ID;
  731. - glyphs[i + step + 1] = INVISIBLE_GLYPH_ID;
  732. - i += 2;
  733. - }
  734. - if (variationSelector == 0) {
  735. - glyphs[i] = getGlyphFromCMAP(code);
  736. - if (font.checkUseNatives() &&
  737. - glyphs[i] < font.glyphToCharMap.length) {
  738. - font.glyphToCharMap[glyphs[i]] = (char)code;
  739. - }
  740. - }
  741. -
  742. - if (code < FontUtilities.MIN_LAYOUT_CHARCODE) {
  743. - continue;
  744. - }
  745. - else if (FontUtilities.isComplexCharCode(code)) {
  746. + else if (FontUtilities.isComplexCharCode(code) ||
  747. + CharToGlyphMapper.isVariationSelector(code)) {
  748. return true;
  749. }
  750. else if (code >= 0x10000) {
  751. @@ -434,8 +281,4 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
  752. cmap instanceof CMap.CMapFormat10 ||
  753. cmap instanceof CMap.CMapFormat12;
  754. }
  755. -
  756. - int getGlyphOfVS(int charCode, int variationSelector) {
  757. - return cmap.getGlyph(charCode, variationSelector, false);
  758. - }
  759. }
  760. diff --git a/jdk/src/java.desktop/share/native/common/font/sunfontids.h b/jdk/src/java.desktop/share/native/common/font/sunfontids.h
  761. index c1bb4198..2301f80b 100644
  762. --- a/jdk/src/java.desktop/share/native/common/font/sunfontids.h
  763. +++ b/jdk/src/java.desktop/share/native/common/font/sunfontids.h
  764. @@ -39,7 +39,7 @@ typedef struct FontManagerNativeIDs {
  765. jmethodID getTableBytesMID;
  766. jmethodID canDisplayMID;
  767. jmethodID f2dCharToGlyphMID;
  768. - jmethodID f2dCharsToGlyphsMID;
  769. + jmethodID f2dCharToVariationGlyphMID;
  770.  
  771. /* sun/font/CharToGlyphMapper methods */
  772. jmethodID charToGlyphMID;
  773. diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc
  774. index f1eceae0..19d070a8 100644
  775. --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc
  776. +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc
  777. @@ -51,46 +51,14 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED,
  778. if (variation_selector == 0) {
  779. *glyph = (hb_codepoint_t)env->CallIntMethod(
  780. font2D, sunFontIDs.f2dCharToGlyphMID, unicode);
  781. - if (env->ExceptionOccurred())
  782. - {
  783. - env->ExceptionClear();
  784. - }
  785. } else {
  786. - jintArray unicodes = NULL;
  787. - jintArray results = NULL;
  788. - jint vsPair[] = {(jint)unicode,
  789. - (jint)variation_selector};
  790. -
  791. - *glyph = 0;
  792. - unicodes = env->NewIntArray(2);
  793. - if (unicodes == NULL) {
  794. - goto cleanup;
  795. - }
  796. - results = env->NewIntArray(2);
  797. - if (results == NULL) {
  798. - goto cleanup;
  799. - }
  800. -
  801. - env->SetIntArrayRegion(unicodes, 0, 2, vsPair);
  802. - env->CallVoidMethod(font2D, sunFontIDs.f2dCharsToGlyphsMID, 2,
  803. - unicodes, results);
  804. - if (env->ExceptionOccurred())
  805. - {
  806. - goto cleanup;
  807. - }
  808. - env->GetIntArrayRegion(results, 0, 2, vsPair);
  809. - *glyph = vsPair[0];
  810. -cleanup:
  811. - if (env->ExceptionOccurred())
  812. - {
  813. - env->ExceptionClear();
  814. - }
  815. - if (unicodes != NULL) {
  816. - env->DeleteLocalRef(unicodes);
  817. - }
  818. - if (results != NULL) {
  819. - env->DeleteLocalRef(results);
  820. - }
  821. + *glyph = (hb_codepoint_t)env->CallIntMethod(
  822. + font2D, sunFontIDs.f2dCharToVariationGlyphMID,
  823. + unicode, variation_selector);
  824. + }
  825. + if (env->ExceptionOccurred())
  826. + {
  827. + env->ExceptionClear();
  828. }
  829. if ((int)*glyph < 0) {
  830. *glyph = 0;
  831. diff --git a/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c b/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c
  832. index 70138a90..f53291e9 100644
  833. --- a/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c
  834. +++ b/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c
  835. @@ -144,8 +144,8 @@ static void initFontIDs(JNIEnv *env) {
  836. CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Font2D"));
  837. CHECK_NULL(sunFontIDs.f2dCharToGlyphMID =
  838. (*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I"));
  839. - CHECK_NULL(sunFontIDs.f2dCharsToGlyphsMID =
  840. - (*env)->GetMethodID(env, tmpClass, "charsToGlyphs", "(I[I[I)V"));
  841. + CHECK_NULL(sunFontIDs.f2dCharToVariationGlyphMID =
  842. + (*env)->GetMethodID(env, tmpClass, "charToVariationGlyph", "(II)I"));
  843. CHECK_NULL(sunFontIDs.getMapperMID =
  844. (*env)->GetMethodID(env, tmpClass, "getMapper",
  845. "()Lsun/font/CharToGlyphMapper;"));
  846. diff --git a/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java b/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java
  847. index ddbe64aa..d6c10e4f 100644
  848. --- a/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java
  849. +++ b/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java
  850. @@ -15,6 +15,7 @@ import java.awt.font.GlyphVector;
  851.  
  852. public class VariationSelectorTest {
  853. // A font supporting Unicode variation selectors is required
  854. + // At least DejaVu 2.20 from 2007
  855. private static final Font FONT = new Font("DejaVu Sans", Font.PLAIN, 12);
  856.  
  857. public static void main(String[] args) {
Add Comment
Please, Sign In to add comment