< prev index next >

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

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2003, 2018, 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


 151      * @param platname - Platform identifier of the font. Typically file name.
 152      * @param nativeNames - Native names - typically XLFDs on Unix.
 153      */
 154     public Type1Font(String platname, Object nativeNames)
 155         throws FontFormatException {
 156 
 157         this(platname, nativeNames, false);
 158     }
 159 
 160     /**
 161      * - does basic verification of the file
 162      * - reads the names (full, family).
 163      * - determines the style of the font.
 164      * @throws FontFormatException if the font can't be opened
 165      * or fails verification,  or there's no usable cmap
 166      */
 167     public Type1Font(String platname, Object nativeNames, boolean createdCopy)
 168         throws FontFormatException {
 169         super(platname, nativeNames);
 170         fontRank = Font2D.TYPE1_RANK;
 171         checkedNatives = true;
 172         try {
 173             verify();
 174         } catch (Throwable t) {
 175             if (createdCopy) {
 176                 T1DisposerRecord ref = new T1DisposerRecord(platname);
 177                 Disposer.addObjectRecord(bufferRef, ref);
 178                 bufferRef = null;
 179             }
 180             if (t instanceof FontFormatException) {
 181                 throw (FontFormatException)t;
 182             } else {
 183                 throw new FontFormatException("Unexpected runtime exception.");
 184             }
 185         }
 186     }
 187 
 188     private synchronized ByteBuffer getBuffer() throws FontFormatException {
 189         MappedByteBuffer mapBuf = (MappedByteBuffer)bufferRef.get();
 190         if (mapBuf == null) {
 191           //System.out.println("open T1 " + platName);


   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


 151      * @param platname - Platform identifier of the font. Typically file name.
 152      * @param nativeNames - Native names - typically XLFDs on Unix.
 153      */
 154     public Type1Font(String platname, Object nativeNames)
 155         throws FontFormatException {
 156 
 157         this(platname, nativeNames, false);
 158     }
 159 
 160     /**
 161      * - does basic verification of the file
 162      * - reads the names (full, family).
 163      * - determines the style of the font.
 164      * @throws FontFormatException if the font can't be opened
 165      * or fails verification,  or there's no usable cmap
 166      */
 167     public Type1Font(String platname, Object nativeNames, boolean createdCopy)
 168         throws FontFormatException {
 169         super(platname, nativeNames);
 170         fontRank = Font2D.TYPE1_RANK;

 171         try {
 172             verify();
 173         } catch (Throwable t) {
 174             if (createdCopy) {
 175                 T1DisposerRecord ref = new T1DisposerRecord(platname);
 176                 Disposer.addObjectRecord(bufferRef, ref);
 177                 bufferRef = null;
 178             }
 179             if (t instanceof FontFormatException) {
 180                 throw (FontFormatException)t;
 181             } else {
 182                 throw new FontFormatException("Unexpected runtime exception.");
 183             }
 184         }
 185     }
 186 
 187     private synchronized ByteBuffer getBuffer() throws FontFormatException {
 188         MappedByteBuffer mapBuf = (MappedByteBuffer)bufferRef.get();
 189         if (mapBuf == null) {
 190           //System.out.println("open T1 " + platName);


< prev index next >