Source Code Cross Referenced for TrueTypeTable.java in  » PDF » PDF-Renderer » com » sun » pdfview » font » ttf » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » PDF » PDF Renderer » com.sun.pdfview.font.ttf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: TrueTypeTable.java,v 1.2 2007/12/20 18:33:30 rbair Exp $
003:         *
004:         * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005:         * Santa Clara, California 95054, U.S.A. All rights reserved.
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         * 
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020:         */
021:
022:        package com.sun.pdfview.font.ttf;
023:
024:        import java.nio.ByteBuffer;
025:
026:        /**
027:         * The base class for TrueType tables.  Specific tables can extend this
028:         * to add more functionality
029:         */
030:        public class TrueTypeTable {
031:            /**
032:             * Well known tables
033:             */
034:            public static final int CMAP_TABLE = 0x636d6170;
035:            public static final int GLYF_TABLE = 0x676c7966;
036:            public static final int HEAD_TABLE = 0x68656164;
037:            public static final int HHEA_TABLE = 0x68686561;
038:            public static final int HMTX_TABLE = 0x686d7478;
039:            public static final int MAXP_TABLE = 0x6d617870;
040:            public static final int NAME_TABLE = 0x6e616d65;
041:            public static final int POST_TABLE = 0x706f7374;
042:            public static final int LOCA_TABLE = 0x6c6f6361;
043:
044:            /**
045:             * This table's tag
046:             */
047:            private int tag;
048:
049:            /**
050:             * The data in this table, in ByteBuffer form
051:             */
052:            private ByteBuffer data;
053:
054:            /** 
055:             * Creates a new instance of TrueTypeTable.
056:             *
057:             * This method is protected.  Use the <code>getTable()</code> methods
058:             * to get new instances.
059:             *
060:             * @param tag the tag for this table
061:             */
062:            protected TrueTypeTable(int tag) {
063:                this .tag = tag;
064:            }
065:
066:            /**
067:             * Get a new instance of an empty table by tag string
068:             *
069:             * @param ttf the font that contains this table
070:             * @param tagString the tag for this table, as a 4 character string
071:             *        (e.g. head or cmap)
072:             */
073:            public static TrueTypeTable createTable(TrueTypeFont ttf,
074:                    String tagString) {
075:                return createTable(ttf, tagString, null);
076:            }
077:
078:            /**
079:             * Get a new instance of a table with provided data
080:             *
081:             * @param ttf the font that contains this table
082:             * @param tagString the tag for this table, as a 4 character string
083:             *        (e.g. head or cmap)
084:             * @param data the table data
085:             */
086:            public static TrueTypeTable createTable(TrueTypeFont ttf,
087:                    String tagString, ByteBuffer data) {
088:                TrueTypeTable outTable = null;
089:
090:                int tag = stringToTag(tagString);
091:
092:                switch (tag) {
093:                case CMAP_TABLE: // cmap table
094:                    outTable = new CmapTable();
095:                    break;
096:                case GLYF_TABLE:
097:                    outTable = new GlyfTable(ttf);
098:                    break;
099:                case HEAD_TABLE: // head table
100:                    outTable = new HeadTable();
101:                    break;
102:                case HHEA_TABLE: // hhea table
103:                    outTable = new HheaTable();
104:                    break;
105:                case HMTX_TABLE:
106:                    outTable = new HmtxTable(ttf);
107:                    break;
108:                case LOCA_TABLE:
109:                    outTable = new LocaTable(ttf);
110:                    break;
111:                case MAXP_TABLE: // maxp table
112:                    outTable = new MaxpTable();
113:                    break;
114:                case NAME_TABLE: // name table
115:                    outTable = new NameTable();
116:                    break;
117:                case POST_TABLE: // post table
118:                    outTable = new PostTable();
119:                    break;
120:                default:
121:                    outTable = new TrueTypeTable(tag);
122:                    break;
123:                }
124:
125:                if (data != null) {
126:                    outTable.setData(data);
127:                }
128:
129:                return outTable;
130:            }
131:
132:            /**
133:             * Get the table's tag
134:             */
135:            public int getTag() {
136:                return tag;
137:            }
138:
139:            /**
140:             * Get the data in the table
141:             */
142:            public ByteBuffer getData() {
143:                return data;
144:            }
145:
146:            /**
147:             * Set the data in the table
148:             */
149:            public void setData(ByteBuffer data) {
150:                this .data = data;
151:            }
152:
153:            /**
154:             * Get the size of the table, in bytes
155:             */
156:            public int getLength() {
157:                return getData().remaining();
158:            }
159:
160:            /**
161:             * Get the tag as a string
162:             */
163:            public static String tagToString(int tag) {
164:                char[] c = new char[4];
165:                c[0] = (char) (0xff & (tag >> 24));
166:                c[1] = (char) (0xff & (tag >> 16));
167:                c[2] = (char) (0xff & (tag >> 8));
168:                c[3] = (char) (0xff & (tag));
169:
170:                return new String(c);
171:            }
172:
173:            /**
174:             * Turn a string into a tag
175:             */
176:            public static int stringToTag(String tag) {
177:                char[] c = tag.toCharArray();
178:
179:                if (c.length != 4) {
180:                    throw new IllegalArgumentException("Bad tag length: " + tag);
181:                }
182:
183:                return c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3];
184:            }
185:
186:            /**
187:             * Put into a nice string
188:             */
189:            public String toString() {
190:                String out = "    " + tagToString(getTag())
191:                        + " Table.  Data is: ";
192:                if (getData() == null) {
193:                    out += "not set";
194:                } else {
195:                    out += "set";
196:                }
197:                return out;
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.