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
59 // little longer to be GC'd. We don't use this stream at all anyway.
60 // In fact why increase the size of a FileFont object if the stream
61 // isn't needed ..
62 //protected FileInputStream stream;
63 //protected FileChannel channel;
64 protected int fileSize;
65
66 protected FontScaler scaler;
67
68 /* The following variables are used, (and in the case of the arrays,
69 * only initialised) for select fonts where a native scaler may be
70 * used to get glyph images and metrics.
71 * glyphToCharMap is filled in on the fly and used to do a reverse
72 * lookup when a FileFont needs to get the charcode back from a glyph
73 * code so it can re-map via a NativeGlyphMapper to get a native glyph.
74 * This isn't a big hit in time, since a boolean test is sufficient
75 * to choose the usual default path, nor in memory for fonts which take
76 * the native path, since fonts have contiguous zero-based glyph indexes,
77 * and these obviously do all exist in the font.
78 */
79 protected boolean checkedNatives;
80 protected boolean useNatives;
81 protected NativeFont[] nativeFonts;
82 protected char[] glyphToCharMap;
83 /*
84 * @throws FontFormatException if the font can't be opened
85 */
86 FileFont(String platname, Object nativeNames)
87 throws FontFormatException {
88
89 super(platname, nativeNames);
90 }
91
92 FontStrike createStrike(FontStrikeDesc desc) {
93 if (!checkedNatives) {
94 checkUseNatives();
95 }
96 return new FileFontStrike(this, desc);
97 }
98
99 protected boolean checkUseNatives() {
100 checkedNatives = true;
101 return useNatives;
102 }
103
104 /* This method needs to be accessible to FontManager if there is
105 * file pool management. It may be a no-op.
106 */
107 protected abstract void close();
108
109
110 /*
111 * This is the public interface. The subclasses need to implement
112 * this. The returned block may be longer than the requested length.
113 */
114 abstract ByteBuffer readBlock(int offset, int length);
115
116 public boolean canDoStyle(int style) {
117 return true;
118 }
119
120 static void setFileToRemove(List<Font2D> fonts,
121 File file, int cnt,
|
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
59 // little longer to be GC'd. We don't use this stream at all anyway.
60 // In fact why increase the size of a FileFont object if the stream
61 // isn't needed ..
62 //protected FileInputStream stream;
63 //protected FileChannel channel;
64 protected int fileSize;
65
66 protected FontScaler scaler;
67
68 /* The following variables are used, (and in the case of the arrays,
69 * only initialised) for select fonts where a native scaler may be
70 * used to get glyph images and metrics.
71 * glyphToCharMap is filled in on the fly and used to do a reverse
72 * lookup when a FileFont needs to get the charcode back from a glyph
73 * code so it can re-map via a NativeGlyphMapper to get a native glyph.
74 * This isn't a big hit in time, since a boolean test is sufficient
75 * to choose the usual default path, nor in memory for fonts which take
76 * the native path, since fonts have contiguous zero-based glyph indexes,
77 * and these obviously do all exist in the font.
78 */
79 protected NativeFont[] nativeFonts;
80 protected char[] glyphToCharMap;
81 /*
82 * @throws FontFormatException if the font can't be opened
83 */
84 FileFont(String platname, Object nativeNames)
85 throws FontFormatException {
86
87 super(platname, nativeNames);
88 }
89
90 FontStrike createStrike(FontStrikeDesc desc) {
91 return new FileFontStrike(this, desc);
92 }
93
94 /* This method needs to be accessible to FontManager if there is
95 * file pool management. It may be a no-op.
96 */
97 protected abstract void close();
98
99
100 /*
101 * This is the public interface. The subclasses need to implement
102 * this. The returned block may be longer than the requested length.
103 */
104 abstract ByteBuffer readBlock(int offset, int length);
105
106 public boolean canDoStyle(int style) {
107 return true;
108 }
109
110 static void setFileToRemove(List<Font2D> fonts,
111 File file, int cnt,
|