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) {
403
403
this .peer = peer ;
404
404
}
405
405
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
+
406
415
synchronized Buffer readTable (int tag ) {
407
416
Buffer buffer = null ;
408
417
boolean openedFile = false ;
@@ -569,6 +578,15 @@ private void init(String name, int fIndex) throws Exception {
569
578
// font. For some fonts advanceWidthMax is much larger then "M"
570
579
// advanceWidthMax = (float)hhea.getChar(10);
571
580
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
+ }
572
590
}
573
591
574
592
// maxp table is before the OS/2 table. Read it now
You can’t perform that action at this time.
0 commit comments