Re: [OpenJDK 2D-Dev] JDK-8187100 [PATCH][SWING] To make display Variation Selector(IVS/SVS/FVS)
Hi That's very encourage us that the similar requirement exist. As the starting point of discussion, I'd like to share the results of analysis. (This is also Steven's request.) 1) Heap usage Akira-san's code had smaller foot print. (Mesured by Font2Demo, IPAmj font, and RHEL7) Akira-san's (w/o VS) 7454464 bytes, (w/ VS) 7773472 bytes Ours (w/o VS) 7593096 bytes, (w/ VS) 7631088 bytes 2) Mongolian support This works for not only FVS, but also other Mongolian glyphs. This is separated by our patch. 3) Swing key operations I agreed that this is another layer's issue, and dropped from my patch, too. 4) Our code's advantages - Composite (logical) fonts support - Obeyed Unicode standard more strictly - Base character definition - Behavior when no VS glyph is available I sent my latest update to Steven, which was revised based on Phil's greate comments. Best regards, Toshio Nakamura, IBM Japan From: Nakajima Akira To: Phil Race , <2d-dev@openjdk.java.net>, Toshio 5 Nakamura , "Steven R. Loomis" Date: 2018/06/14 08:41 Subject: Re: [OpenJDK 2D-Dev] JDK-8187100 [PATCH][SWING] To make display Variation Selector(IVS/SVS/FVS) Hello Phil. Thanks for your reply and suggestion. > http://www.oracle.com/technetwork/community/oca-486395.html Signed OCA is listed as NTT Comware Corporation - OpenJDK -- Company: NTT Comware Corporation Name: Akira Nakajima E-Mail: nakajima.ak...@nttcom.co.jp -- On 2018/06/14 3:14, Phil Race wrote: > Hi Akira, > > It seems that maybe we should be looking at what you propose and > comparing it > to see if one or the other approach is better and if one missed > something the other spotted. > I'd like to ask Steven and Toshio to take the lead on that. > > However for any of your patch to be included it is imperative that you > FIRST > have a signed OCA accepted. Please see > http://www.oracle.com/technetwork/community/oca-486395.html > where your name is not present ... > > -phil. > > On 06/13/2018 12:53 AM, Nakajima Akira wrote: >> I happened to create similar patch(for SWING and JavaFX) without >> knowing the report below. >> https://bugs.openjdk.java.net/browse/JDK-8187100 >> >> I do not know much about circumstances, because this is my first post >> about Java forum. >> Please discard this if unnecessary. >> >> >> == >> Difference with following patch. >> http://cr.openjdk.java.net/~srl/8187100/webrev.00/ >> >> 1. For Acceleration and Memory saving, load only partial format14 >> glyphs table. >> java.desktop/share/classes/sun/font/CMap.java >> >> +if (numMappings[i] > 0 && (uniStart[i] == null || >> glyphID[i] == null)) { >> +try { >> +initNonDef(i); >> >> >> >> 2. Support Mongolian and FVS (I checked on Linux and Windows) >> java.desktop/share/classes/sun/font/FontUtilities.java >> >> +else if (code <= 0x18af) { // 1800 - 18AF Mongolian >> (including FVS) >> +return true; >> +} >> >> >> 3. Not implementing following >> >> >> 3) Swing text component's DEL and BS key operations change >> >> >> >> >> == >> This SWING patch fixes following 2 bugs. >> >> 1. To make display IVS/SVS (JDK-8187100) >> Sample is kami.java and kami2.java. >> >> java.desktop/share/classes/sun/font/CMap.java >> java.desktop/share/classes/sun/font/CharToGlyphMapper.java >> java.desktop/share/classes/sun/font/Font2D.java >> java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java >> java.desktop/share/native/libfontmanager/sunFont.c >> java.desktop/share/native/libfontmanager/hb-jdk-font.cc >> >> >> 2. To make dislpay Mongolian and FVS >> Sample is mongol.java. >> >> java.desktop/share/classes/sun/font/FontUtilities.java >> >> >> >> == >> I checked this patch on CentOS 7.5 and Windows7 x64. >> >> >> I created same patch for JavaFX >> and posted to openjfx-...@openjdk.java.net. >> >> >> >> PATCH >> >> diff -r e1b3def12624 src/java.desktop/share/classes/sun/font/CMap.java >> --- a/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 >> 06:35:04 2018 +0200 >> +++ b/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 &
Re: [OpenJDK 2D-Dev] JDK-8187100 [PATCH][SWING] To make display Variation Selector(IVS/SVS/FVS)
Hello Phil. Thanks for your reply and suggestion. > http://www.oracle.com/technetwork/community/oca-486395.html Signed OCA is listed as NTT Comware Corporation - OpenJDK -- Company: NTT Comware Corporation Name: Akira Nakajima E-Mail: nakajima.ak...@nttcom.co.jp -- On 2018/06/14 3:14, Phil Race wrote: Hi Akira, It seems that maybe we should be looking at what you propose and comparing it to see if one or the other approach is better and if one missed something the other spotted. I'd like to ask Steven and Toshio to take the lead on that. However for any of your patch to be included it is imperative that you FIRST have a signed OCA accepted. Please see http://www.oracle.com/technetwork/community/oca-486395.html where your name is not present ... -phil. On 06/13/2018 12:53 AM, Nakajima Akira wrote: I happened to create similar patch(for SWING and JavaFX) without knowing the report below. https://bugs.openjdk.java.net/browse/JDK-8187100 I do not know much about circumstances, because this is my first post about Java forum. Please discard this if unnecessary. == Difference with following patch. http://cr.openjdk.java.net/~srl/8187100/webrev.00/ 1. For Acceleration and Memory saving, load only partial format14 glyphs table. java.desktop/share/classes/sun/font/CMap.java +if (numMappings[i] > 0 && (uniStart[i] == null || glyphID[i] == null)) { +try { +initNonDef(i); 2. Support Mongolian and FVS (I checked on Linux and Windows) java.desktop/share/classes/sun/font/FontUtilities.java +else if (code <= 0x18af) { // 1800 - 18AF Mongolian (including FVS) +return true; +} 3. Not implementing following >> 3) Swing text component's DEL and BS key operations change == This SWING patch fixes following 2 bugs. 1. To make display IVS/SVS (JDK-8187100) Sample is kami.java and kami2.java. java.desktop/share/classes/sun/font/CMap.java java.desktop/share/classes/sun/font/CharToGlyphMapper.java java.desktop/share/classes/sun/font/Font2D.java java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java java.desktop/share/native/libfontmanager/sunFont.c java.desktop/share/native/libfontmanager/hb-jdk-font.cc 2. To make dislpay Mongolian and FVS Sample is mongol.java. java.desktop/share/classes/sun/font/FontUtilities.java == I checked this patch on CentOS 7.5 and Windows7 x64. I created same patch for JavaFX and posted to openjfx-...@openjdk.java.net. PATCH diff -r e1b3def12624 src/java.desktop/share/classes/sun/font/CMap.java --- a/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 06:35:04 2018 +0200 +++ b/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 14:14:08 2018 +0900 @@ -129,6 +129,7 @@ static final short MSUnicodeSurrogateEncoding = 10; static final char noSuchChar = (char)0xfffd; +static final int BYTEMASK = 0x00ff; static final int SHORTMASK = 0x; static final int INTMASK = 0x; @@ -141,7 +142,7 @@ */ char[] xlat; -static CMap initialize(TrueTypeFont font) { +static CMap initialize(TrueTypeFont font, int[] offset_format, int create_cmap) { CMap cmap = null; @@ -150,8 +151,15 @@ int three0=0, three1=0, three2=0, three3=0, three4=0, three5=0, three6=0, three10=0; boolean threeStar = false; +boolean zeroStar = false; ByteBuffer cmapBuffer = font.getTableBuffer(TrueTypeFont.cmapTag); + +/* create CMap14 */ +if (create_cmap == 14 && offset_format[0] != 0) { +return createCMap(cmapBuffer, offset_format[0], null); +} + int cmapTableOffset = font.getTableSize(TrueTypeFont.cmapTag); short numberSubTables = cmapBuffer.getShort(2); @@ -159,7 +167,7 @@ for (int i=0; i 0) { +int min = 0, max, mid; +max = numMappings[i]; +while (min < max) { +mid = (min+max) >> 1; +if (charCode < uniStart[i][mid]) { +max = mid; +} else if (charCode > uniStart[i][mid]) { +min = mid + 1; +} else { +return mid; +} +} +} +return -1; +} + +final int findRangeNumber_Def(int charCode, int i) { +if (numRanges[i] > 0) { +int min = 0, max, mid; +max = numRanges[i]; +while (min < max) { +mid = (min+max) >> 1; +if (charCode < defUniStart[i][mid]) { +max =
Re: [OpenJDK 2D-Dev] JDK-8187100 [PATCH][SWING] To make display Variation Selector(IVS/SVS/FVS)
Hi Akira, It seems that maybe we should be looking at what you propose and comparing it to see if one or the other approach is better and if one missed something the other spotted. I'd like to ask Steven and Toshio to take the lead on that. However for any of your patch to be included it is imperative that you FIRST have a signed OCA accepted. Please see http://www.oracle.com/technetwork/community/oca-486395.html where your name is not present ... -phil. On 06/13/2018 12:53 AM, Nakajima Akira wrote: I happened to create similar patch(for SWING and JavaFX) without knowing the report below. https://bugs.openjdk.java.net/browse/JDK-8187100 I do not know much about circumstances, because this is my first post about Java forum. Please discard this if unnecessary. == Difference with following patch. http://cr.openjdk.java.net/~srl/8187100/webrev.00/ 1. For Acceleration and Memory saving, load only partial format14 glyphs table. java.desktop/share/classes/sun/font/CMap.java +if (numMappings[i] > 0 && (uniStart[i] == null || glyphID[i] == null)) { +try { +initNonDef(i); 2. Support Mongolian and FVS (I checked on Linux and Windows) java.desktop/share/classes/sun/font/FontUtilities.java +else if (code <= 0x18af) { // 1800 - 18AF Mongolian (including FVS) +return true; +} 3. Not implementing following >> 3) Swing text component's DEL and BS key operations change == This SWING patch fixes following 2 bugs. 1. To make display IVS/SVS (JDK-8187100) Sample is kami.java and kami2.java. java.desktop/share/classes/sun/font/CMap.java java.desktop/share/classes/sun/font/CharToGlyphMapper.java java.desktop/share/classes/sun/font/Font2D.java java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java java.desktop/share/native/libfontmanager/sunFont.c java.desktop/share/native/libfontmanager/hb-jdk-font.cc 2. To make dislpay Mongolian and FVS Sample is mongol.java. java.desktop/share/classes/sun/font/FontUtilities.java == I checked this patch on CentOS 7.5 and Windows7 x64. I created same patch for JavaFX and posted to openjfx-...@openjdk.java.net. PATCH diff -r e1b3def12624 src/java.desktop/share/classes/sun/font/CMap.java --- a/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 06:35:04 2018 +0200 +++ b/src/java.desktop/share/classes/sun/font/CMap.javaWed Jun 13 14:14:08 2018 +0900 @@ -129,6 +129,7 @@ static final short MSUnicodeSurrogateEncoding = 10; static final char noSuchChar = (char)0xfffd; +static final int BYTEMASK = 0x00ff; static final int SHORTMASK = 0x; static final int INTMASK = 0x; @@ -141,7 +142,7 @@ */ char[] xlat; -static CMap initialize(TrueTypeFont font) { +static CMap initialize(TrueTypeFont font, int[] offset_format, int create_cmap) { CMap cmap = null; @@ -150,8 +151,15 @@ int three0=0, three1=0, three2=0, three3=0, three4=0, three5=0, three6=0, three10=0; boolean threeStar = false; +boolean zeroStar = false; ByteBuffer cmapBuffer = font.getTableBuffer(TrueTypeFont.cmapTag); + +/* create CMap14 */ +if (create_cmap == 14 && offset_format[0] != 0) { +return createCMap(cmapBuffer, offset_format[0], null); +} + int cmapTableOffset = font.getTableSize(TrueTypeFont.cmapTag); short numberSubTables = cmapBuffer.getShort(2); @@ -159,7 +167,7 @@ for (int i=0; i case 10: three10 = offset; break; // MS Unicode surrogates } +} else if (platformID == 0) { // APPLE_UNICODE +zeroStar = true; +encodingID = cmapBuffer.getShort(); +offset = cmapBuffer.getInt(); +if (encodingID == 5) { +offset_format[0] = offset; +} } } @@ -419,6 +434,7 @@ case 8: return new CMapFormat8(buffer, offset, xlat); case 10: return new CMapFormat10(buffer, offset, xlat); case 12: return new CMapFormat12(buffer, offset, xlat); +case 14: return new CMapFormat14(buffer, offset); default: throw new RuntimeException("Cmap format unimplemented: " + (int)buffer.getChar(offset)); } @@ -435,6 +451,13 @@ */ abstract char getGlyph(int charCode); +char getGlyph(int charCode, int vs) { +return getGlyph(charCode); +} + +void setDefCMap(CMap defCmap) { +}; + /* Format 4 Header is * ushort format (off=0) * ushort length (off=2) @@ -1031,6 +1054,191 @@ } +// Format 14: (Table for variation selector) +static class CMapFormat14
[OpenJDK 2D-Dev] JDK-8187100 [PATCH][SWING] To make display Variation Selector(IVS/SVS/FVS)
I happened to create similar patch(for SWING and JavaFX) without knowing the report below. https://bugs.openjdk.java.net/browse/JDK-8187100 I do not know much about circumstances, because this is my first post about Java forum. Please discard this if unnecessary. == Difference with following patch. http://cr.openjdk.java.net/~srl/8187100/webrev.00/ 1. For Acceleration and Memory saving, load only partial format14 glyphs table. java.desktop/share/classes/sun/font/CMap.java +if (numMappings[i] > 0 && (uniStart[i] == null || glyphID[i] == null)) { +try { +initNonDef(i); 2. Support Mongolian and FVS (I checked on Linux and Windows) java.desktop/share/classes/sun/font/FontUtilities.java +else if (code <= 0x18af) { // 1800 - 18AF Mongolian (including FVS) +return true; +} 3. Not implementing following >> 3) Swing text component's DEL and BS key operations change == This SWING patch fixes following 2 bugs. 1. To make display IVS/SVS (JDK-8187100) Sample is kami.java and kami2.java. java.desktop/share/classes/sun/font/CMap.java java.desktop/share/classes/sun/font/CharToGlyphMapper.java java.desktop/share/classes/sun/font/Font2D.java java.desktop/share/classes/sun/font/TrueTypeGlyphMapper.java java.desktop/share/native/libfontmanager/sunFont.c java.desktop/share/native/libfontmanager/hb-jdk-font.cc 2. To make dislpay Mongolian and FVS Sample is mongol.java. java.desktop/share/classes/sun/font/FontUtilities.java == I checked this patch on CentOS 7.5 and Windows7 x64. I created same patch for JavaFX and posted to openjfx-...@openjdk.java.net. PATCH diff -r e1b3def12624 src/java.desktop/share/classes/sun/font/CMap.java --- a/src/java.desktop/share/classes/sun/font/CMap.java Wed Jun 13 06:35:04 2018 +0200 +++ b/src/java.desktop/share/classes/sun/font/CMap.java Wed Jun 13 14:14:08 2018 +0900 @@ -129,6 +129,7 @@ static final short MSUnicodeSurrogateEncoding = 10; static final char noSuchChar = (char)0xfffd; +static final int BYTEMASK = 0x00ff; static final int SHORTMASK = 0x; static final int INTMASK = 0x; @@ -141,7 +142,7 @@ */ char[] xlat; -static CMap initialize(TrueTypeFont font) { +static CMap initialize(TrueTypeFont font, int[] offset_format, int create_cmap) { CMap cmap = null; @@ -150,8 +151,15 @@ int three0=0, three1=0, three2=0, three3=0, three4=0, three5=0, three6=0, three10=0; boolean threeStar = false; +boolean zeroStar = false; ByteBuffer cmapBuffer = font.getTableBuffer(TrueTypeFont.cmapTag); + +/* create CMap14 */ +if (create_cmap == 14 && offset_format[0] != 0) { +return createCMap(cmapBuffer, offset_format[0], null); +} + int cmapTableOffset = font.getTableSize(TrueTypeFont.cmapTag); short numberSubTables = cmapBuffer.getShort(2); @@ -159,7 +167,7 @@ for (int i=0; i default: throw new RuntimeException("Cmap format unimplemented: " + (int)buffer.getChar(offset)); } @@ -435,6 +451,13 @@ */ abstract char getGlyph(int charCode); +char getGlyph(int charCode, int vs) { +return getGlyph(charCode); +} + +void setDefCMap(CMap defCmap) { +}; + /* Format 4 Header is * ushort format (off=0) * ushort length (off=2) @@ -1031,6 +1054,191 @@ } +// Format 14: (Table for variation selector) +static class CMapFormat14 extends CMap { + +ByteBuffer buffer; +int offset; +int numSelector; +int[] varSelector; + +/* default glyphs */ +int[] defaultOff, numRanges; +int[][] defUniStart; +short[][] additionalCnt; + +/* non default glyphs */ +int[] nonDefOff, numMappings; +int[][] uniStart, glyphID; +/* e.g. + * uniStart[numSelector-1] = U+e0100 + * uniStart[numSelector-1][numMappings-1] = U+795e + * glyphID[numSelector-1][numMappings-1] = 12345 + */ + +CMap defCmap; +void setDefCMap(CMap cmap) { +this.defCmap = cmap; +} + +CMapFormat14(ByteBuffer buffer, int offset) { +this.buffer = buffer; +this.offset = offset; + +buffer.position(offset+6); +/* get count of Variation Selector */ +numSelector = buffer.getInt(); + +varSelector = new int[numSelector]; // e.g. {0xfe00, 0xe0100, 0xe0101} +defaultOff = new int[numSelector]; +nonDefOff = new int[numSelector]; + +/* get Variation Selector and Table offset */ +