1 /*
2 * Copyright (c) 1996, 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
1589 } else {
1590 return table_scriptFontsMotif[-fid + fontIndex * NUM_STYLES + styleIndex];
1591 }
1592 }
1593
1594 private static int[] getExclusionRanges(short scriptID) {
1595 short exID = table_exclusions[scriptID];
1596 if (exID == 0) {
1597 return EMPTY_INT_ARRAY;
1598 } else {
1599 char[] exChar = getString(exID).toCharArray();
1600 int[] exInt = new int[exChar.length / 2];
1601 int i = 0;
1602 for (int j = 0; j < exInt.length; j++) {
1603 exInt[j] = (exChar[i++] << 16) + (exChar[i++] & 0xffff);
1604 }
1605 return exInt;
1606 }
1607 }
1608
1609 private static boolean contains(short IDs[], short id, int limit) {
1610 for (int i = 0; i < limit; i++) {
1611 if (IDs[i] == id) {
1612 return true;
1613 }
1614 }
1615 return false;
1616 }
1617
1618 /* Return the PlatformFontName from its fontID*/
1619 protected static String getComponentFontName(short id) {
1620 if (id < 0) {
1621 return null;
1622 }
1623 return getString(table_componentFontNameIDs[id]);
1624 }
1625
1626 private static String getComponentFileName(short id) {
1627 if (id < 0) {
1628 return null;
1629 }
1741
1742 private static short getStringID(String s) {
1743 if (s == null) {
1744 return (short)0;
1745 }
1746 short pos0 = (short)stringTable.length();
1747 stringTable.append(s);
1748 short pos1 = (short)stringTable.length();
1749
1750 stringIDs[stringIDNum] = pos0;
1751 stringIDs[stringIDNum + 1] = pos1;
1752 stringIDNum++;
1753 if (stringIDNum + 1 >= stringIDs.length) {
1754 short[] tmp = new short[stringIDNum + 1000];
1755 System.arraycopy(stringIDs, 0, tmp, 0, stringIDNum);
1756 stringIDs = tmp;
1757 }
1758 return (short)(stringIDNum - 1);
1759 }
1760
1761 private static short getShortArrayID(short sa[]) {
1762 char[] cc = new char[sa.length];
1763 for (int i = 0; i < sa.length; i ++) {
1764 cc[i] = (char)sa[i];
1765 }
1766 String s = new String(cc);
1767 return getStringID(s);
1768 }
1769
1770 //utility "empty" objects
1771 private static final int[] EMPTY_INT_ARRAY = new int[0];
1772 private static final String[] EMPTY_STRING_ARRAY = new String[0];
1773 private static final short[] EMPTY_SHORT_ARRAY = new short[0];
1774 private static final String UNDEFINED_COMPONENT_FONT = "unknown";
1775
1776 //////////////////////////////////////////////////////////////////////////
1777 //Convert the FontConfig data in Properties file to binary data tables //
1778 //////////////////////////////////////////////////////////////////////////
1779 static class PropertiesHandler {
1780 public void load(InputStream in) throws IOException {
1781 initLogicalNameStyle();
|
1 /*
2 * Copyright (c) 1996, 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
1589 } else {
1590 return table_scriptFontsMotif[-fid + fontIndex * NUM_STYLES + styleIndex];
1591 }
1592 }
1593
1594 private static int[] getExclusionRanges(short scriptID) {
1595 short exID = table_exclusions[scriptID];
1596 if (exID == 0) {
1597 return EMPTY_INT_ARRAY;
1598 } else {
1599 char[] exChar = getString(exID).toCharArray();
1600 int[] exInt = new int[exChar.length / 2];
1601 int i = 0;
1602 for (int j = 0; j < exInt.length; j++) {
1603 exInt[j] = (exChar[i++] << 16) + (exChar[i++] & 0xffff);
1604 }
1605 return exInt;
1606 }
1607 }
1608
1609 private static boolean contains(short[] IDs, short id, int limit) {
1610 for (int i = 0; i < limit; i++) {
1611 if (IDs[i] == id) {
1612 return true;
1613 }
1614 }
1615 return false;
1616 }
1617
1618 /* Return the PlatformFontName from its fontID*/
1619 protected static String getComponentFontName(short id) {
1620 if (id < 0) {
1621 return null;
1622 }
1623 return getString(table_componentFontNameIDs[id]);
1624 }
1625
1626 private static String getComponentFileName(short id) {
1627 if (id < 0) {
1628 return null;
1629 }
1741
1742 private static short getStringID(String s) {
1743 if (s == null) {
1744 return (short)0;
1745 }
1746 short pos0 = (short)stringTable.length();
1747 stringTable.append(s);
1748 short pos1 = (short)stringTable.length();
1749
1750 stringIDs[stringIDNum] = pos0;
1751 stringIDs[stringIDNum + 1] = pos1;
1752 stringIDNum++;
1753 if (stringIDNum + 1 >= stringIDs.length) {
1754 short[] tmp = new short[stringIDNum + 1000];
1755 System.arraycopy(stringIDs, 0, tmp, 0, stringIDNum);
1756 stringIDs = tmp;
1757 }
1758 return (short)(stringIDNum - 1);
1759 }
1760
1761 private static short getShortArrayID(short[] sa) {
1762 char[] cc = new char[sa.length];
1763 for (int i = 0; i < sa.length; i ++) {
1764 cc[i] = (char)sa[i];
1765 }
1766 String s = new String(cc);
1767 return getStringID(s);
1768 }
1769
1770 //utility "empty" objects
1771 private static final int[] EMPTY_INT_ARRAY = new int[0];
1772 private static final String[] EMPTY_STRING_ARRAY = new String[0];
1773 private static final short[] EMPTY_SHORT_ARRAY = new short[0];
1774 private static final String UNDEFINED_COMPONENT_FONT = "unknown";
1775
1776 //////////////////////////////////////////////////////////////////////////
1777 //Convert the FontConfig data in Properties file to binary data tables //
1778 //////////////////////////////////////////////////////////////////////////
1779 static class PropertiesHandler {
1780 public void load(InputStream in) throws IOException {
1781 initLogicalNameStyle();
|