File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
modules/javafx.graphics/src/main/java/com/sun/javafx/font Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,15 @@ public void setPeer(Object peer) {
403403 this .peer = peer ;
404404 }
405405
406+ int getTableLength (int tag ) {
407+ int len = 0 ;
408+ DirectoryEntry tagDE = getDirectoryEntry (tag );
409+ if (tagDE != null ) {
410+ len = tagDE .length ;
411+ }
412+ return len ;
413+ }
414+
406415 synchronized Buffer readTable (int tag ) {
407416 Buffer buffer = null ;
408417 boolean openedFile = false ;
@@ -569,6 +578,15 @@ private void init(String name, int fIndex) throws Exception {
569578 // font. For some fonts advanceWidthMax is much larger then "M"
570579 // advanceWidthMax = (float)hhea.getChar(10);
571580 numHMetrics = hhea .getChar (34 ) & 0xffff ;
581+ /* the hmtx table may have a trailing LSB array which we don't
582+ * use. But it means we must not assume these two values match.
583+ * We are only concerned here with not reading more data than
584+ * there is in the table.
585+ */
586+ int hmtxEntries = getTableLength (hmtxTag ) >> 2 ;
587+ if (numHMetrics > hmtxEntries ) {
588+ numHMetrics = hmtxEntries ;
589+ }
572590 }
573591
574592 // maxp table is before the OS/2 table. Read it now
You can’t perform that action at this time.
0 commit comments