1 /*
2 * Copyright (c) 2003, 2006, 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
314 return numGlyphs;
315 }
316
317 PhysicalFont getDelegateFont() {
318 if (delegateFont == null) {
319 SunFontManager fm = SunFontManager.getInstance();
320 delegateFont = fm.getDefaultPhysicalFont();
321 }
322 return delegateFont;
323 }
324
325 /* Specify that the dpi is 72x72, as this corresponds to JDK's
326 * default user space. These are the 10th and 11th fields in the XLFD.
327 * ptSize in XLFD is in 10th's of a point so multiply by 10,
328 * Replace the 9th field in the XLFD (ie after the 8th hyphen)
329 * with this pt size (this corresponds to the field that's "%d" in the
330 * font configuration files). Wild card the other numeric fields.
331 * ie to request 12 pt Times New Roman italic font, use an XLFD like :
332 * -monotype-times new roman-regular-i---*-120-72-72-p-*-iso8859-1
333 */
334 byte[] getPlatformNameBytes(int ptSize) {
335 int[] hPos = new int[14];
336 int hyphenCnt = 1;
337 int pos = 1;
338
339 while (pos != -1 && hyphenCnt < 14) {
340 pos = platName.indexOf('-', pos);
341 if (pos != -1) {
342 hPos[hyphenCnt++] = pos;
343 pos++;
344 }
345 }
346 String sizeStr = Integer.toString((int)Math.abs(ptSize)*10);
347 StringBuilder sb = new StringBuilder(platName);
348 /* work backwards so as to not invalidate the positions. */
349 sb.replace(hPos[11]+1, hPos[12], "*");
350
351 sb.replace(hPos[9]+1, hPos[10], "72");
352
353 sb.replace(hPos[8]+1, hPos[9], "72");
|
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
314 return numGlyphs;
315 }
316
317 PhysicalFont getDelegateFont() {
318 if (delegateFont == null) {
319 SunFontManager fm = SunFontManager.getInstance();
320 delegateFont = fm.getDefaultPhysicalFont();
321 }
322 return delegateFont;
323 }
324
325 /* Specify that the dpi is 72x72, as this corresponds to JDK's
326 * default user space. These are the 10th and 11th fields in the XLFD.
327 * ptSize in XLFD is in 10th's of a point so multiply by 10,
328 * Replace the 9th field in the XLFD (ie after the 8th hyphen)
329 * with this pt size (this corresponds to the field that's "%d" in the
330 * font configuration files). Wild card the other numeric fields.
331 * ie to request 12 pt Times New Roman italic font, use an XLFD like :
332 * -monotype-times new roman-regular-i---*-120-72-72-p-*-iso8859-1
333 */
334 @SuppressWarnings("cast")
335 byte[] getPlatformNameBytes(int ptSize) {
336 int[] hPos = new int[14];
337 int hyphenCnt = 1;
338 int pos = 1;
339
340 while (pos != -1 && hyphenCnt < 14) {
341 pos = platName.indexOf('-', pos);
342 if (pos != -1) {
343 hPos[hyphenCnt++] = pos;
344 pos++;
345 }
346 }
347 String sizeStr = Integer.toString((int)Math.abs(ptSize)*10);
348 StringBuilder sb = new StringBuilder(platName);
349 /* work backwards so as to not invalidate the positions. */
350 sb.replace(hPos[11]+1, hPos[12], "*");
351
352 sb.replace(hPos[9]+1, hPos[10], "72");
353
354 sb.replace(hPos[8]+1, hPos[9], "72");
|