Source Code Cross Referenced for AFM.java in  » PDF » jPod » de » intarsys » font » afm » 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 » jPod » de.intarsys.font.afm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.font.afm;
031:
032:        import de.intarsys.font.FontStyle;
033:        import de.intarsys.font.IFont;
034:        import java.util.HashMap;
035:        import java.util.Map;
036:
037:        /**
038:         * A simple implementation for an adobe font metric object.
039:         * 
040:         * <p>
041:         * This implementation will hold all afm attributes in a generic collection. The
042:         * char metrics are read explicitly and held in a list of AFMChar's. No other
043:         * information (like kerning) is extracted.
044:         * </p>
045:         * 
046:         * <p>
047:         * See the "Adobe Font Metrics File Format Specification"
048:         * </p>
049:         */
050:        public class AFM implements  IFont {
051:            /*
052:             * todo create exceptions when font unavailable todo under construction
053:             */
054:            public static final String FN_TIMES = "Times-Roman"; //$NON-NLS-1$
055:
056:            public static final String FN_TIMES_BOLD = "Times-Bold"; //$NON-NLS-1$
057:
058:            public static final String FN_TIMES_ITALIC = "Times-Italic"; //$NON-NLS-1$
059:
060:            public static final String FN_TIMES_BOLDITALIC = "Times-BoldItalic"; //$NON-NLS-1$
061:
062:            public static final String FN_HELVETICA = "Helvetica"; //$NON-NLS-1$
063:
064:            public static final String FN_HELVETICA_BOLD = "Helvetica-Bold"; //$NON-NLS-1$
065:
066:            public static final String FN_HELVETICA_OBLIQUE = "Helvetica-Oblique"; //$NON-NLS-1$
067:
068:            public static final String FN_HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique"; //$NON-NLS-1$
069:
070:            public static final String FN_COURIER = "Courier"; //$NON-NLS-1$
071:
072:            public static final String FN_COURIER_BOLD = "Courier-Bold"; //$NON-NLS-1$
073:
074:            public static final String FN_COURIER_OBLIQUE = "Courier-Oblique"; //$NON-NLS-1$
075:
076:            public static final String FN_COURIER_BOLDOBLIQUE = "Courier-BoldOblique"; //$NON-NLS-1$
077:
078:            public static final String FN_SYMBOL = "Symbol"; //$NON-NLS-1$
079:
080:            public static final String FN_ZAPFDINGBATS = "ZapfDingbats"; //$NON-NLS-1$
081:
082:            // the chars described in the font metric file
083:            // ... organized by codePoint
084:            private HashMap charsByCode = new HashMap();
085:
086:            // ... organized by name
087:            private HashMap charsByName = new HashMap();
088:
089:            // attribute name/value pairs parsed form the font metric file
090:            private Map attributes = new HashMap();
091:
092:            /**
093:             * BuiltInAFM constructor comment.
094:             */
095:            public AFM() {
096:                super ();
097:            }
098:
099:            /**
100:             * The string value for a generic attribute designated by <code>name</code>.
101:             * 
102:             * @param name
103:             *            The name of the attribute to lookup.
104:             * 
105:             * @return The string value for a generic attribute designated by
106:             *         <code>name</code>.
107:             */
108:            public String getAttribute(String name) {
109:                return (String) attributes.get(name);
110:            }
111:
112:            /**
113:             * The character representation for a byte code point given in
114:             * <code>codePoint</code>.
115:             * 
116:             * @param codePoint
117:             *            The byte code point.
118:             * 
119:             * @return The character representation for a byte code point given in
120:             *         <code>codePoint</code>.
121:             */
122:            public AFMChar getCharByCode(int codePoint) {
123:                return (AFMChar) getCharsByCode().get(new Integer(codePoint));
124:            }
125:
126:            /**
127:             * The character representation for an adobe glyph name given in
128:             * <code>name</code>.
129:             * 
130:             * @param name
131:             *            The adobe glyph name.
132:             * 
133:             * @return The character representation for an adobe glyph name given in
134:             *         <code>name</code>.
135:             */
136:            public AFMChar getCharByName(String name) {
137:                return (AFMChar) getCharsByName().get(name);
138:            }
139:
140:            public static String getFontFamilyName(String name) {
141:                if (name == null) {
142:                    return null;
143:                }
144:                int posMinus = name.indexOf('-');
145:                if (posMinus > 0) {
146:                    name = name.substring(0, posMinus);
147:                }
148:                return name;
149:            }
150:
151:            public String getFontName() {
152:                return getAttribute(AFMParser.TOKEN_FontName);
153:            }
154:
155:            public static FontStyle getFontStyle(String name) {
156:                if (name == null) {
157:                    return FontStyle.REGULAR;
158:                }
159:                int posMinus = name.indexOf('-');
160:                if (posMinus > 0) {
161:                    name = name.substring(posMinus + 1);
162:                }
163:                return FontStyle.getFontStyle(name);
164:            }
165:
166:            /*
167:             * (non-Javadoc)
168:             * 
169:             * @see de.intarsys.font.IFont#getFontFamilyName()
170:             */
171:            public String getFontFamilyName() {
172:                return getFontFamilyName(getFontName());
173:            }
174:
175:            /*
176:             * (non-Javadoc)
177:             * 
178:             * @see de.intarsys.font.IFont#getFontStyle()
179:             */
180:            public FontStyle getFontStyle() {
181:                return getFontStyle(getFontName());
182:            }
183:
184:            /**
185:             * Set a generic attribute value. The attributes value is given in <code>
186:             * value</code>,
187:             * the name of the attribute is <code>name</code>.
188:             * 
189:             * @param name
190:             *            The name of the attribute.
191:             * @param value
192:             *            The value of the attribute.
193:             */
194:            protected void setAttribute(String name, String value) {
195:                getAttributes().put(name, value);
196:            }
197:
198:            protected void setAttributes(java.util.Map newAttributes) {
199:                attributes = newAttributes;
200:            }
201:
202:            protected java.util.Map getAttributes() {
203:                return attributes;
204:            }
205:
206:            protected java.util.HashMap getCharsByCode() {
207:                return charsByCode;
208:            }
209:
210:            protected java.util.HashMap getCharsByName() {
211:                return charsByName;
212:            }
213:
214:            protected void addChar(AFMChar c) {
215:                if (c.getCode() != -1) {
216:                    getCharsByCode().put(new Integer(c.getCode()), c);
217:                }
218:
219:                if (c.getName() != null) {
220:                    getCharsByName().put(c.getName(), c);
221:                }
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.