3909N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A /* I/O and file operations are always synchronized on the font 0N/A * object. Two threads can be accessing the font and retrieving 0N/A * information, and synchronized only to the extent that filesystem 0N/A * operations require. 0N/A * A limited number of files can be open at a time, to limit the 0N/A * absorption of file descriptors. If a file needs to be opened 0N/A * when there are none free, then the synchronization of all I/O 0N/A * ensures that any in progress operation will complete before some 0N/A * other thread closes the descriptor in order to allocate another one. 0N/A // NB consider using a RAF. FIS has finalize method so may take a 0N/A // little longer to be GC'd. We don't use this stream at all anyway. 0N/A // In fact why increase the size of a FileFont object if the stream 0N/A //protected FileInputStream stream; 0N/A //protected FileChannel channel; 0N/A /* The following variables are used, (and in the case of the arrays, 0N/A * only initialised) for select fonts where a native scaler may be 0N/A * used to get glyph images and metrics. 0N/A * glyphToCharMap is filled in on the fly and used to do a reverse 0N/A * lookup when a FileFont needs to get the charcode back from a glyph 0N/A * code so it can re-map via a NativeGlyphMapper to get a native glyph. 0N/A * This isn't a big hit in time, since a boolean test is sufficient 0N/A * to choose the usual default path, nor in memory for fonts which take 0N/A * the native path, since fonts have contiguous zero-based glyph indexes, 0N/A * and these obviously do all exist in the font. 0N/A * @throws FontFormatException - if the font can't be opened 0N/A /* This method needs to be accessible to FontManager if there is 0N/A * file pool management. It may be a no-op. 0N/A * This is the public interface. The subclasses need to implement 0N/A * this. The returned block may be longer than the requested length. 4632N/A // MACOSX begin -- Make this static so that we can pass in CFont 0N/A /* This is called when a font scaler is determined to 0N/A * be unusable (ie bad). 0N/A * We want to replace current scaler with NullFontScaler, so 0N/A * we never try to use same font scaler again. 0N/A * Scaler native resources could have already been disposed 0N/A * or they will be eventually by Java2D disposer. 0N/A * However, it should be safe to call dispose() explicitly here. 0N/A * For safety we also invalidate all strike's scaler context. 0N/A * So, in case they cache pointer to native scaler 0N/A * it will not ever be used. 0N/A * It also appears desirable to remove all the entries from the 0N/A * cache so no other code will pick them up. But we can't just 0N/A * 'delete' them as code may be using them. And simply dropping 0N/A * the reference to the cache will make the reference objects 0N/A * unreachable and so they will not get disposed. 0N/A * Since a strike may hold (via java arrays) native pointers to many 0N/A * rasterised glyphs, this would be a memory leak. 0N/A * - to move all the entries to another map where they 0N/A * are no longer locatable 0N/A * - update FontStrikeDisposer to be able to distinguish which 0N/A * map they are held in via a boolean flag 0N/A * Since this isn't expected to be anything other than an extremely 0N/A * rare maybe it is not worth doing this last part. 0N/A /* NB we know these are all FileFontStrike instances 0N/A * because the cache is on this FileFont 0N/A /* T1 & TT implementation differ so this method is abstract. 0N/A NB: null should not be returned here! */ 0N/A /* REMIND: is it possible that the file is 0N/A * still open? It will be closed when the 0N/A * font2D is disposed but could this code 0N/A * execute first? If so the file would not 0N/A * be deleted on MS-windows. 0N/A /* remove from delete on exit hook list : */ 1686N/A // FIXME: still need to be refactored 3784N/A // unable to verify whether value of java.io.tempdir will be 3784N/A // exposed, so return only a name of the font file.