< prev index next >

src/java.desktop/share/classes/sun/font/GlyphLayout.java

Print this page
rev 60042 : 8248802: Add log helper methods to FontUtilities.java
   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 461                 }
 462                 catch (IndexOutOfBoundsException e) {
 463                     if (_gvdata._count >=0) {
 464                         _gvdata.grow();
 465                     }
 466                 }
 467             }
 468             // Break out of the outer for loop if layout fails.
 469             if (_gvdata._count < 0) {
 470                 break;
 471             }
 472         }
 473 
 474         // If layout fails (negative glyph count) create an un-laid out GV instead.
 475         // ie default positions. This will be a lot better than the alternative of
 476         // a complete blank layout.
 477         StandardGlyphVector gv;
 478         if (_gvdata._count < 0) {
 479             gv = new StandardGlyphVector(font, text, offset, count, frc);
 480             if (FontUtilities.debugFonts()) {
 481                FontUtilities.getLogger().warning("OpenType layout failed on font: " +
 482                                                  font);
 483             }
 484         } else {
 485             gv = _gvdata.createGlyphVector(font, frc, result);
 486         }
 487         //        System.err.println("Layout returns: " + gv);
 488         return gv;
 489     }
 490 
 491     //
 492     // private methods
 493     //
 494 
 495     private GlyphLayout() {
 496         this._gvdata = new GVData();
 497         this._textRecord = new TextRecord();
 498         this._scriptRuns = new ScriptRun();
 499         this._fontRuns = new FontRunIterator();
 500         this._erecords = new ArrayList<>(10);
 501         this._pt = new Point2D.Float();
 502         this._sd = new FontStrikeDesc();


   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 461                 }
 462                 catch (IndexOutOfBoundsException e) {
 463                     if (_gvdata._count >=0) {
 464                         _gvdata.grow();
 465                     }
 466                 }
 467             }
 468             // Break out of the outer for loop if layout fails.
 469             if (_gvdata._count < 0) {
 470                 break;
 471             }
 472         }
 473 
 474         // If layout fails (negative glyph count) create an un-laid out GV instead.
 475         // ie default positions. This will be a lot better than the alternative of
 476         // a complete blank layout.
 477         StandardGlyphVector gv;
 478         if (_gvdata._count < 0) {
 479             gv = new StandardGlyphVector(font, text, offset, count, frc);
 480             if (FontUtilities.debugFonts()) {
 481                FontUtilities.logWarning("OpenType layout failed on font: " + font);

 482             }
 483         } else {
 484             gv = _gvdata.createGlyphVector(font, frc, result);
 485         }
 486         //        System.err.println("Layout returns: " + gv);
 487         return gv;
 488     }
 489 
 490     //
 491     // private methods
 492     //
 493 
 494     private GlyphLayout() {
 495         this._gvdata = new GVData();
 496         this._textRecord = new TextRecord();
 497         this._scriptRuns = new ScriptRun();
 498         this._fontRuns = new FontRunIterator();
 499         this._erecords = new ArrayList<>(10);
 500         this._pt = new Point2D.Float();
 501         this._sd = new FontStrikeDesc();


< prev index next >