Created
June 22, 2018 22:25
-
-
Save srl295/a81ec3a8495d53b85f368a7872138e86 to your computer and use it in GitHub Desktop.
8187100 webrev comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/jdk/src/java.desktop/share/classes/sun/font/CMap.java b/jdk/src/java.desktop/share/classes/sun/font/CMap.java | |
index c52ee430..1049250c 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/CMap.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/CMap.java | |
@@ -1095,10 +1095,6 @@ abstract class CMap { | |
int numSelectors; | |
int[] selector; | |
- //for Default UVS Table | |
- int[] numUnicodeValueRanges; | |
- int[][] startUnicodeValue; | |
- short[][] additionalCount; | |
//for Non-Default UVS Table | |
int[] numUVSMapping; | |
int[][] unicodeValue; | |
@@ -1107,9 +1103,6 @@ abstract class CMap { | |
UVS(ByteBuffer buffer, int offset) { | |
numSelectors = buffer.getInt(offset+6); | |
selector = new int[numSelectors]; | |
- numUnicodeValueRanges = new int[numSelectors]; | |
- startUnicodeValue = new int[numSelectors][]; | |
- additionalCount = new short[numSelectors][]; | |
numUVSMapping = new int[numSelectors]; | |
unicodeValue = new int[numSelectors][]; | |
glyphID = new char[numSelectors][]; | |
@@ -1120,28 +1113,10 @@ abstract class CMap { | |
selector[i] += (buffer.get() & 0xff) << 8; | |
selector[i] += buffer.get() & 0xff; | |
- //for Default UVS Table | |
- int tableOffset = buffer.getInt(offset + 10 + i * 11 + 3); | |
- if (tableOffset == 0) { | |
- numUnicodeValueRanges[i] = 0; | |
- } else if (tableOffset > 0) { | |
- buffer.position(offset+tableOffset); | |
- numUnicodeValueRanges[i] = buffer.getInt() & INTMASK; | |
- | |
- startUnicodeValue[i] = new int[numUnicodeValueRanges[i]]; | |
- additionalCount[i] = new short[numUnicodeValueRanges[i]]; | |
- | |
- for (int j = 0; j < numUnicodeValueRanges[i]; j++) { | |
- int temp = (buffer.get() & 0xff) << 16; //UINT24 | |
- temp += (buffer.get() & 0xff) << 8; | |
- temp += buffer.get() & 0xff; | |
- startUnicodeValue[i][j] = temp; | |
- additionalCount[i][j] = (short)(buffer.get() & 0xff); | |
- } | |
- } | |
+ //skip Default UVS Table | |
//for Non-Default UVS Table | |
- tableOffset = buffer.getInt(offset + 10 + i * 11 + 7); | |
+ int tableOffset = buffer.getInt(offset + 10 + i * 11 + 7); | |
if (tableOffset == 0) { | |
numUVSMapping[i] = 0; | |
} else if (tableOffset > 0) { | |
@@ -1161,14 +1136,7 @@ abstract class CMap { | |
} | |
} | |
- /* getGlyph for Variation selector | |
- return value: | |
- 0: A special glyph for the variation selector is Not found | |
- -1: Default glyph should be used | |
- 0>: A special glyph is found | |
- */ | |
static final int VS_NOGLYPH = 0; | |
- static final int VS_DEFAULT_GLYPH = -1; | |
private int getGlyph(int charCode, int variationSelector) { | |
int targetSelector = -1; | |
for (int i = 0; i < numSelectors; i++) { | |
@@ -1180,21 +1148,6 @@ abstract class CMap { | |
if (targetSelector == -1) { | |
return VS_NOGLYPH; | |
} | |
- if (numUnicodeValueRanges[targetSelector] > 0) { | |
- int index = java.util.Arrays.binarySearch( | |
- startUnicodeValue[targetSelector], charCode); | |
- if (index >= 0) { | |
- return VS_DEFAULT_GLYPH; | |
- } else { | |
- index = -index - 2; | |
- if (index >= 0 && | |
- charCode >= startUnicodeValue[targetSelector][index] && | |
- charCode <= startUnicodeValue[targetSelector][index] | |
- +additionalCount[targetSelector][index]) { | |
- return VS_DEFAULT_GLYPH; | |
- } | |
- } | |
- } | |
if (numUVSMapping[targetSelector] > 0) { | |
int index = java.util.Arrays.binarySearch( | |
unicodeValue[targetSelector], charCode); | |
@@ -1206,18 +1159,15 @@ abstract class CMap { | |
} | |
} | |
- char getGlyph(int charCode, int variationSelector, boolean allowFallback) { | |
+ char getVariationGlyph(int charCode, int variationSelector) { | |
char glyph = 0; | |
if (uvs == null) { | |
- if (allowFallback) { | |
- glyph = getGlyph(charCode); | |
- } | |
+ glyph = getGlyph(charCode); | |
} else { | |
int result = uvs.getGlyph(charCode, variationSelector); | |
if (result > 0) { | |
glyph = (char)(result & 0xFFFF); | |
- } else if (result == UVS.VS_DEFAULT_GLYPH || | |
- allowFallback) { | |
+ } else { | |
glyph = getGlyph(charCode); | |
} | |
} | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java | |
index 59a49de5..1a1d48d7 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/CharToGlyphMapper.java | |
@@ -79,6 +79,11 @@ public abstract class CharToGlyphMapper { | |
chars[0] = unicode; | |
charsToGlyphs(1, chars, glyphs); | |
return glyphs[0]; | |
+ } | |
+ | |
+ public int charToVariationGlyph(int unicode, int variationSelector) { | |
+ // Override this if variation selector is supported. | |
+ return charToGlyph(unicode); | |
} | |
public abstract int getNumGlyphs(); | |
@@ -92,34 +97,9 @@ public abstract class CharToGlyphMapper { | |
public abstract void charsToGlyphs(int count, | |
int[] unicodes, int[] glyphs); | |
- // Based on Unicode 10.0.0 chapter 23.4 | |
- public static boolean isVSBaseChar(int charCode) { | |
- int type = Character.getType(charCode); | |
- if (type == Character.UNASSIGNED || | |
- type == Character.CONTROL || | |
- type == Character.FORMAT || | |
- type == Character.NON_SPACING_MARK) { | |
- return false; | |
- } | |
- return java.text.Normalizer.isNormalized( | |
- java.nio.CharBuffer.wrap(Character.toChars(charCode)), | |
- java.text.Normalizer.Form.NFD); | |
- } | |
- | |
public static boolean isVariationSelector(int charCode) { | |
return ((charCode >= VSS_START && charCode <= VSS_END) || | |
(charCode >= VS_START && charCode <= VS_END)); | |
} | |
- public static boolean isVariationSelectorBMP(char charCode) { | |
- return (charCode >= VS_START && charCode <= VS_END); | |
- } | |
- | |
- public static boolean isVariationSelectorExt(char charCode1, | |
- char charCode2) { | |
- return (charCode1 == 0xDB40 && | |
- (charCode2 >= 0xDD00 && charCode2 <= 0xDDEF)); | |
- // VSS_START - VSS_END | |
- } | |
- | |
} | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java | |
index 70400631..379c3db4 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java | |
@@ -133,26 +133,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
return missingGlyph; | |
} | |
- private int convertToGlyph(int unicode, int variationSelector) { | |
- if (variationSelector == 0) { | |
- return convertToGlyph(unicode); | |
- } | |
- for (int slot = 0; slot < font.numSlots; slot++) { | |
- if (!hasExcludes || !font.isExcludedChar(slot, unicode)) { | |
- CharToGlyphMapper mapper = getSlotMapper(slot); | |
- if (mapper instanceof TrueTypeGlyphMapper) { | |
- int glyphCode = ((TrueTypeGlyphMapper)mapper). | |
- getGlyphOfVS(unicode, variationSelector); | |
- if (glyphCode != mapper.getMissingGlyphCode()) { | |
- glyphCode = compositeGlyphCode(slot, glyphCode); | |
- return glyphCode; | |
- } | |
- } | |
- } | |
- } | |
- return convertToGlyph(unicode); //retry without Variation Selector | |
- } | |
- | |
public int getNumGlyphs() { | |
int numGlyphs = 0; | |
/* The number of glyphs in a composite is affected by | |
@@ -225,9 +205,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
glyphs[i + 1] = INVISIBLE_GLYPH_ID; | |
} | |
} | |
- if (isVariationSelector(code)) { | |
- return charsToGlyphsNSVS(count, unicodes, glyphs); | |
- } | |
int gc = glyphs[i] = getCachedGlyphCode(code); | |
if (gc == UNINITIALIZED_GLYPH) { | |
@@ -237,70 +214,8 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
if (code < FontUtilities.MIN_LAYOUT_CHARCODE) { | |
continue; | |
} | |
- else if (FontUtilities.isComplexCharCode(code)) { | |
- return true; | |
- } | |
- else if (code >= 0x10000) { | |
- i += 1; // Empty glyph slot after surrogate | |
- continue; | |
- } | |
- } | |
- | |
- return false; | |
- } | |
- | |
- private boolean charsToGlyphsNSVS(int count, char[] unicodes, | |
- int[] glyphs) { | |
- | |
- for (int i = 0; i < count; i++) { | |
- int code = unicodes[i]; // char is unsigned. | |
- int step = 1; | |
- int variationSelector = 0; | |
- | |
- if (code >= HI_SURROGATE_START && | |
- code <= HI_SURROGATE_END && i < count - 1) { | |
- char low = unicodes[i + 1]; | |
- | |
- if (low >= LO_SURROGATE_START && | |
- low <= LO_SURROGATE_END) { | |
- code = (code - HI_SURROGATE_START) * | |
- 0x400 + low - LO_SURROGATE_START + 0x10000; | |
- glyphs[i + 1] = INVISIBLE_GLYPH_ID; | |
- step = 2; | |
- } | |
- } | |
- | |
- if (i < count - step && | |
- isVariationSelectorBMP(unicodes[i+step]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = unicodes[i+step]; | |
- glyphs[i] = convertToGlyph(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- i += 1; | |
- } else if (i < count - step -1 && | |
- isVariationSelectorExt(unicodes[i+step], | |
- unicodes[i+step+1]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = (unicodes[i+step] | |
- - HI_SURROGATE_START) * 0x400 | |
- + unicodes[i+step+1] - LO_SURROGATE_START | |
- + 0x10000; | |
- glyphs[i] = convertToGlyph(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- glyphs[i+step+1] = INVISIBLE_GLYPH_ID; | |
- i += 2; | |
- } | |
- if (variationSelector == 0) { | |
- int gc = glyphs[i] = getCachedGlyphCode(code); | |
- if (gc == UNINITIALIZED_GLYPH) { | |
- glyphs[i] = convertToGlyph(code); | |
- } | |
- } | |
- | |
- if (code < FontUtilities.MIN_LAYOUT_CHARCODE) { | |
- continue; | |
- } | |
- else if (FontUtilities.isComplexCharCode(code)) { | |
+ else if (FontUtilities.isComplexCharCode(code) || | |
+ CharToGlyphMapper.isVariationSelector(code)) { | |
return true; | |
} | |
else if (code >= 0x10000) { | |
@@ -327,10 +242,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
low <= LO_SURROGATE_END) { | |
code = (code - HI_SURROGATE_START) * | |
0x400 + low - LO_SURROGATE_START + 0x10000; | |
- if (isVariationSelector(code)) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
- } | |
int gc = glyphs[i] = getCachedGlyphCode(code); | |
if (gc == UNINITIALIZED_GLYPH) { | |
@@ -340,9 +251,6 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
glyphs[i] = INVISIBLE_GLYPH_ID; | |
continue; | |
} | |
- } else if (isVariationSelectorBMP(unicodes[i])) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
} | |
int gc = glyphs[i] = getCachedGlyphCode(code); | |
@@ -352,65 +260,9 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
} | |
} | |
- private void charsToGlyphsVS(int count, char[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- int code = unicodes[i]; // char is unsigned. | |
- int variationSelector = 0; | |
- int step = 1; | |
- | |
- if (code >= HI_SURROGATE_START && | |
- code <= HI_SURROGATE_END && i < count - 1) { | |
- char low = unicodes[i + 1]; | |
- | |
- if (low >= LO_SURROGATE_START && | |
- low <= LO_SURROGATE_END) { | |
- code = (code - HI_SURROGATE_START) * | |
- 0x400 + low - LO_SURROGATE_START + 0x10000; | |
- | |
- glyphs[i+1] = INVISIBLE_GLYPH_ID; | |
- step = 2; | |
- } | |
- } | |
- | |
- if (i < count - step && | |
- isVariationSelectorBMP(unicodes[i+step]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = unicodes[i+step]; | |
- glyphs[i] = convertToGlyph(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- i += 1; | |
- } else if (i < count - step -1 && | |
- isVariationSelectorExt(unicodes[i+step], | |
- unicodes[i+step+1]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = (unicodes[i+step] | |
- - HI_SURROGATE_START) * 0x400 | |
- + unicodes[i+step+1] - LO_SURROGATE_START | |
- + 0x10000; | |
- glyphs[i] = convertToGlyph(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- glyphs[i+step+1] = INVISIBLE_GLYPH_ID; | |
- i += 2; | |
- } | |
- if (variationSelector == 0) { | |
- int gc = glyphs[i] = getCachedGlyphCode(code); | |
- if (gc == UNINITIALIZED_GLYPH) { | |
- glyphs[i] = convertToGlyph(code); | |
- } | |
- } | |
- if (code >= 0x10000) { | |
- i++; | |
- } | |
- } | |
- } | |
- | |
public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) { | |
for (int i=0; i<count; i++) { | |
int code = unicodes[i]; | |
- if (isVariationSelector(code)) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
- } | |
glyphs[i] = getCachedGlyphCode(code); | |
if (glyphs[i] == UNINITIALIZED_GLYPH) { | |
@@ -419,23 +271,4 @@ public class CompositeGlyphMapper extends CharToGlyphMapper { | |
} | |
} | |
- private void charsToGlyphsVS(int count, int[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- int code = unicodes[i]; | |
- | |
- if (i < count-1 && | |
- isVariationSelector(unicodes[i+1]) && | |
- isVSBaseChar(code) ) { | |
- glyphs[i] = convertToGlyph(code, unicodes[i+1]); | |
- glyphs[i+1] = INVISIBLE_GLYPH_ID; | |
- i++; | |
- } else { | |
- glyphs[i] = getCachedGlyphCode(code); | |
- if (glyphs[i] == UNINITIALIZED_GLYPH) { | |
- glyphs[i] = convertToGlyph(code); | |
- } | |
- } | |
- } | |
- } | |
- | |
} | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/Font2D.java b/jdk/src/java.desktop/share/classes/sun/font/Font2D.java | |
index 1b560aef..e4cdc216 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/Font2D.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/Font2D.java | |
@@ -524,8 +524,8 @@ public abstract class Font2D { | |
return getMapper().charToGlyph(wchar); | |
} | |
- public void charsToGlyphs(int count, int[] wchars, int[] glyphs) { | |
- getMapper().charsToGlyphs(count, wchars, glyphs); | |
+ public int charToVariationGlyph(int wchar, int variationSelector) { | |
+ return getMapper().charToVariationGlyph(wchar, variationSelector); | |
} | |
public int getMissingGlyphCode() { | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java b/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java | |
index 1303fd5d..d20b1006 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/FontRunIterator.java | |
@@ -119,40 +119,8 @@ public final class FontRunIterator { | |
int ch = nextCodePoint(lim); | |
int sl = mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK; | |
- int secondPosition = pos; | |
- int preChar = ch; | |
- boolean consumed = false; | |
slot = sl >>> 24; | |
- while ((ch = nextCodePoint(lim)) != DONE ) { | |
- if (CharToGlyphMapper.isVariationSelector(ch) && | |
- CharToGlyphMapper.isVSBaseChar(preChar) && | |
- consumed == false) { | |
- consumed = true; | |
- int[] chars = {preChar, ch}; | |
- int[] glyphs = {0, 0}; | |
- mapper.charsToGlyphs(2, chars, glyphs); | |
- int vsSize = 1; | |
- if (ch >= 0x10000) { | |
- vsSize = 2; | |
- } | |
- if (secondPosition + vsSize == pos) { // Real slot | |
- sl = glyphs[0] & CompositeGlyphMapper.SLOTMASK; | |
- slot = sl >>> 24; | |
- } | |
- if ((glyphs[0] & CompositeGlyphMapper.SLOTMASK) != sl) { | |
- pushback(ch); | |
- pushback(preChar); | |
- return true; | |
- } | |
- } else { | |
- consumed = false; | |
- if ((mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) | |
- != sl) { | |
- break; | |
- } | |
- } | |
- preChar = ch; | |
- } | |
+ while ((ch = nextCodePoint(lim)) != DONE && (mapper.charToGlyph(ch) & CompositeGlyphMapper.SLOTMASK) == sl); | |
pushback(ch); | |
return true; | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java | |
index ae9942a7..f3d86c07 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java | |
@@ -236,9 +236,7 @@ public final class FontUtilities { | |
return | |
isComplexCharCode(ch) || | |
(ch >= CharToGlyphMapper.HI_SURROGATE_START && | |
- ch <= CharToGlyphMapper.LO_SURROGATE_END) || | |
- (ch >= CharToGlyphMapper.VS_START && | |
- ch <= CharToGlyphMapper.VS_END); | |
+ ch <= CharToGlyphMapper.LO_SURROGATE_END); | |
} | |
/* If the character code falls into any of a number of unicode ranges | |
diff --git a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java | |
index 8c612e87..7c628300 100644 | |
--- a/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java | |
+++ b/jdk/src/java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java | |
@@ -87,18 +87,19 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
} | |
return (char)missingGlyph; | |
} | |
- } catch (Exception e) { | |
+ } catch(Exception e) { | |
handleBadCMAP(); | |
return (char) missingGlyph; | |
} | |
} | |
- private char getGlyphFromCMAPVS(int charCode, int variationSelector) { | |
+ private char getGlyphFromCMAP(int charCode, int variationSelector) { | |
if (variationSelector == 0) { | |
return getGlyphFromCMAP(charCode); | |
} | |
try { | |
- char glyphCode = cmap.getGlyph(charCode, variationSelector, true); | |
+ char glyphCode = cmap.getVariationGlyph(charCode, | |
+ variationSelector); | |
if (glyphCode < numGlyphs || | |
glyphCode >= FileFontStrike.INVISIBLE_GLYPHS) { | |
return glyphCode; | |
@@ -113,8 +114,8 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
return (char)missingGlyph; | |
} | |
} catch (Exception e) { | |
- handleBadCMAP(); | |
- return (char) missingGlyph; | |
+ handleBadCMAP(); | |
+ return (char) missingGlyph; | |
} | |
} | |
@@ -161,12 +162,20 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
return glyph; | |
} | |
+ @Override | |
+ public int charToVariationGlyph(int unicode, int variationSelector) { | |
+ if (needsJAremapping) { | |
+ unicode = remapJAIntChar(unicode); | |
+ } | |
+ int glyph = getGlyphFromCMAP(unicode, variationSelector); | |
+ if (font.checkUseNatives() && glyph < font.glyphToCharMap.length) { | |
+ font.glyphToCharMap[glyph] = (char)unicode; | |
+ } | |
+ return glyph; | |
+ } | |
+ | |
public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- if (isVariationSelector(unicodes[i])) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
- } | |
+ for (int i=0;i<count;i++) { | |
if (needsJAremapping) { | |
glyphs[i] = getGlyphFromCMAP(remapJAIntChar(unicodes[i])); | |
} else { | |
@@ -179,37 +188,9 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
} | |
} | |
- private void charsToGlyphsVS(int count, int[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- if (i < count - 1 && | |
- isVariationSelector(unicodes[i + 1]) && | |
- isVSBaseChar(unicodes[i])) { | |
- if (needsJAremapping) { | |
- glyphs[i] = getGlyphFromCMAPVS(remapJAIntChar(unicodes[i]), | |
- unicodes[i + 1]); | |
- } else { | |
- glyphs[i] = getGlyphFromCMAPVS(unicodes[i], | |
- unicodes[i + 1]); | |
- } | |
- i++; | |
- glyphs[i] = INVISIBLE_GLYPH_ID; | |
- } else { | |
- if (needsJAremapping) { | |
- glyphs[i] = getGlyphFromCMAP(remapJAIntChar(unicodes[i])); | |
- } else { | |
- glyphs[i] = getGlyphFromCMAP(unicodes[i]); | |
- } | |
- if (font.checkUseNatives() && | |
- glyphs[i] < font.glyphToCharMap.length) { | |
- font.glyphToCharMap[glyphs[i]] = (char)unicodes[i]; | |
- } | |
- } | |
- } | |
- } | |
- | |
public void charsToGlyphs(int count, char[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
+ for (int i=0; i<count; i++) { | |
int code; | |
if (needsJAremapping) { | |
code = remapJAChar(unicodes[i]); | |
@@ -226,18 +207,11 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
code = (code - HI_SURROGATE_START) * | |
0x400 + low - LO_SURROGATE_START + 0x10000; | |
- if (isVariationSelector(code)) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
- } | |
glyphs[i] = getGlyphFromCMAP(code); | |
i += 1; // Empty glyph slot after surrogate | |
glyphs[i] = INVISIBLE_GLYPH_ID; | |
continue; | |
} | |
- } else if (isVariationSelectorBMP(unicodes[i])) { | |
- charsToGlyphsVS(count, unicodes, glyphs); | |
- return; | |
} | |
glyphs[i] = getGlyphFromCMAP(code); | |
@@ -249,64 +223,6 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
} | |
} | |
- private void charsToGlyphsVS(int count, char[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- int code; | |
- int variationSelector = 0; | |
- int step = 1; | |
- if (needsJAremapping) { | |
- code = remapJAChar(unicodes[i]); | |
- } else { | |
- code = unicodes[i]; // char is unsigned. | |
- } | |
- | |
- if (code >= HI_SURROGATE_START && | |
- code <= HI_SURROGATE_END && i < count - 1) { | |
- char low = unicodes[i + 1]; | |
- | |
- if (low >= LO_SURROGATE_START && | |
- low <= LO_SURROGATE_END) { | |
- code = (code - HI_SURROGATE_START) * | |
- 0x400 + low - LO_SURROGATE_START + 0x10000; | |
- | |
- glyphs[i + 1] = INVISIBLE_GLYPH_ID; | |
- step = 2; | |
- } | |
- } | |
- if (i < count - step && | |
- isVariationSelectorBMP(unicodes[i + step]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = unicodes[i + step]; | |
- glyphs[i] = getGlyphFromCMAPVS(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- i += 1; | |
- } else if (i < count - step -1 && | |
- isVariationSelectorExt(unicodes[i + step], | |
- unicodes[i + step + 1]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = (unicodes[i + step] - HI_SURROGATE_START) | |
- * 0x400 + unicodes[i + step + 1] | |
- - LO_SURROGATE_START + 0x10000; | |
- glyphs[i] = getGlyphFromCMAPVS(code, variationSelector); | |
- glyphs[i + step] = INVISIBLE_GLYPH_ID; | |
- glyphs[i + step + 1] = INVISIBLE_GLYPH_ID; | |
- i += 2; | |
- } | |
- if (variationSelector == 0) { | |
- glyphs[i] = getGlyphFromCMAP(code); | |
- | |
- if (font.checkUseNatives() && | |
- glyphs[i] < font.glyphToCharMap.length) { | |
- font.glyphToCharMap[glyphs[i]] = (char)code; | |
- } | |
- } | |
- if (code >= 0x10000) { | |
- i++; | |
- } | |
- | |
- } | |
- } | |
- | |
/* This variant checks if shaping is needed and immediately | |
* returns true if it does. A caller of this method should be expecting | |
* to check the return type because it needs to know how to handle | |
@@ -314,7 +230,7 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
*/ | |
public boolean charsToGlyphsNS(int count, char[] unicodes, int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
+ for (int i=0; i<count; i++) { | |
int code; | |
if (needsJAremapping) { | |
code = remapJAChar(unicodes[i]); | |
@@ -333,9 +249,6 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
glyphs[i + 1] = INVISIBLE_GLYPH_ID; | |
} | |
} | |
- if (isVariationSelector(code)) { | |
- return charsToGlyphsNSVS(count, unicodes, glyphs); | |
- } | |
glyphs[i] = getGlyphFromCMAP(code); | |
if (font.checkUseNatives() && | |
@@ -346,74 +259,8 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
if (code < FontUtilities.MIN_LAYOUT_CHARCODE) { | |
continue; | |
} | |
- else if (FontUtilities.isComplexCharCode(code)) { | |
- return true; | |
- } | |
- else if (code >= 0x10000) { | |
- i += 1; // Empty glyph slot after surrogate | |
- continue; | |
- } | |
- } | |
- | |
- return false; | |
- } | |
- | |
- private boolean charsToGlyphsNSVS(int count, char[] unicodes, | |
- int[] glyphs) { | |
- for (int i = 0; i < count; i++) { | |
- int code; | |
- int step = 1; | |
- int variationSelector = 0; | |
- if (needsJAremapping) { | |
- code = remapJAChar(unicodes[i]); | |
- } else { | |
- code = unicodes[i]; // char is unsigned. | |
- } | |
- | |
- if (code >= HI_SURROGATE_START && | |
- code <= HI_SURROGATE_END && i < count - 1) { | |
- char low = unicodes[i + 1]; | |
- | |
- if (low >= LO_SURROGATE_START && | |
- low <= LO_SURROGATE_END) { | |
- code = (code - HI_SURROGATE_START) * | |
- 0x400 + low - LO_SURROGATE_START + 0x10000; | |
- glyphs[i + 1] = INVISIBLE_GLYPH_ID; | |
- step = 2; | |
- } | |
- } | |
- | |
- if (i < count - step && | |
- isVariationSelectorBMP(unicodes[i + step]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = unicodes[i + step]; | |
- glyphs[i] = getGlyphFromCMAPVS(code, variationSelector); | |
- glyphs[i+step] = INVISIBLE_GLYPH_ID; | |
- i += 1; | |
- } else if (i < count - step - 1 && | |
- isVariationSelectorExt(unicodes[i + step], | |
- unicodes[i + step + 1]) && | |
- isVSBaseChar(code)) { | |
- variationSelector = (unicodes[i + step] - HI_SURROGATE_START) | |
- * 0x400 + unicodes[i + step + 1] | |
- - LO_SURROGATE_START + 0x10000; | |
- glyphs[i] = getGlyphFromCMAPVS(code, variationSelector); | |
- glyphs[i + step] = INVISIBLE_GLYPH_ID; | |
- glyphs[i + step + 1] = INVISIBLE_GLYPH_ID; | |
- i += 2; | |
- } | |
- if (variationSelector == 0) { | |
- glyphs[i] = getGlyphFromCMAP(code); | |
- if (font.checkUseNatives() && | |
- glyphs[i] < font.glyphToCharMap.length) { | |
- font.glyphToCharMap[glyphs[i]] = (char)code; | |
- } | |
- } | |
- | |
- if (code < FontUtilities.MIN_LAYOUT_CHARCODE) { | |
- continue; | |
- } | |
- else if (FontUtilities.isComplexCharCode(code)) { | |
+ else if (FontUtilities.isComplexCharCode(code) || | |
+ CharToGlyphMapper.isVariationSelector(code)) { | |
return true; | |
} | |
else if (code >= 0x10000) { | |
@@ -434,8 +281,4 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper { | |
cmap instanceof CMap.CMapFormat10 || | |
cmap instanceof CMap.CMapFormat12; | |
} | |
- | |
- int getGlyphOfVS(int charCode, int variationSelector) { | |
- return cmap.getGlyph(charCode, variationSelector, false); | |
- } | |
} | |
diff --git a/jdk/src/java.desktop/share/native/common/font/sunfontids.h b/jdk/src/java.desktop/share/native/common/font/sunfontids.h | |
index c1bb4198..2301f80b 100644 | |
--- a/jdk/src/java.desktop/share/native/common/font/sunfontids.h | |
+++ b/jdk/src/java.desktop/share/native/common/font/sunfontids.h | |
@@ -39,7 +39,7 @@ typedef struct FontManagerNativeIDs { | |
jmethodID getTableBytesMID; | |
jmethodID canDisplayMID; | |
jmethodID f2dCharToGlyphMID; | |
- jmethodID f2dCharsToGlyphsMID; | |
+ jmethodID f2dCharToVariationGlyphMID; | |
/* sun/font/CharToGlyphMapper methods */ | |
jmethodID charToGlyphMID; | |
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 | |
index f1eceae0..19d070a8 100644 | |
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc | |
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc | |
@@ -51,46 +51,14 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, | |
if (variation_selector == 0) { | |
*glyph = (hb_codepoint_t)env->CallIntMethod( | |
font2D, sunFontIDs.f2dCharToGlyphMID, unicode); | |
- if (env->ExceptionOccurred()) | |
- { | |
- env->ExceptionClear(); | |
- } | |
} else { | |
- jintArray unicodes = NULL; | |
- jintArray results = NULL; | |
- jint vsPair[] = {(jint)unicode, | |
- (jint)variation_selector}; | |
- | |
- *glyph = 0; | |
- unicodes = env->NewIntArray(2); | |
- if (unicodes == NULL) { | |
- goto cleanup; | |
- } | |
- results = env->NewIntArray(2); | |
- if (results == NULL) { | |
- goto cleanup; | |
- } | |
- | |
- env->SetIntArrayRegion(unicodes, 0, 2, vsPair); | |
- env->CallVoidMethod(font2D, sunFontIDs.f2dCharsToGlyphsMID, 2, | |
- unicodes, results); | |
- if (env->ExceptionOccurred()) | |
- { | |
- goto cleanup; | |
- } | |
- env->GetIntArrayRegion(results, 0, 2, vsPair); | |
- *glyph = vsPair[0]; | |
-cleanup: | |
- if (env->ExceptionOccurred()) | |
- { | |
- env->ExceptionClear(); | |
- } | |
- if (unicodes != NULL) { | |
- env->DeleteLocalRef(unicodes); | |
- } | |
- if (results != NULL) { | |
- env->DeleteLocalRef(results); | |
- } | |
+ *glyph = (hb_codepoint_t)env->CallIntMethod( | |
+ font2D, sunFontIDs.f2dCharToVariationGlyphMID, | |
+ unicode, variation_selector); | |
+ } | |
+ if (env->ExceptionOccurred()) | |
+ { | |
+ env->ExceptionClear(); | |
} | |
if ((int)*glyph < 0) { | |
*glyph = 0; | |
diff --git a/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c b/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c | |
index 70138a90..f53291e9 100644 | |
--- a/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c | |
+++ b/jdk/src/java.desktop/share/native/libfontmanager/sunFont.c | |
@@ -144,8 +144,8 @@ static void initFontIDs(JNIEnv *env) { | |
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Font2D")); | |
CHECK_NULL(sunFontIDs.f2dCharToGlyphMID = | |
(*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I")); | |
- CHECK_NULL(sunFontIDs.f2dCharsToGlyphsMID = | |
- (*env)->GetMethodID(env, tmpClass, "charsToGlyphs", "(I[I[I)V")); | |
+ CHECK_NULL(sunFontIDs.f2dCharToVariationGlyphMID = | |
+ (*env)->GetMethodID(env, tmpClass, "charToVariationGlyph", "(II)I")); | |
CHECK_NULL(sunFontIDs.getMapperMID = | |
(*env)->GetMethodID(env, tmpClass, "getMapper", | |
"()Lsun/font/CharToGlyphMapper;")); | |
diff --git a/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java b/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java | |
index ddbe64aa..d6c10e4f 100644 | |
--- a/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java | |
+++ b/jdk/test/jdk/java/awt/font/TextLayout/VariationSelectorTest.java | |
@@ -15,6 +15,7 @@ import java.awt.font.GlyphVector; | |
public class VariationSelectorTest { | |
// A font supporting Unicode variation selectors is required | |
+ // At least DejaVu 2.20 from 2007 | |
private static final Font FONT = new Font("DejaVu Sans", Font.PLAIN, 12); | |
public static void main(String[] args) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment