Source Code Cross Referenced for PDFontDescriptorAFM.java in  » PDF » PDFBox-0.7.3 » org » pdfbox » pdmodel » font » 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 » PDFBox 0.7.3 » org.pdfbox.pdmodel.font 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2004, www.pdfbox.org
003:         * All rights reserved.
004:         *
005:         * Redistribution and use in source and binary forms, with or without
006:         * modification, are permitted provided that the following conditions are met:
007:         *
008:         * 1. Redistributions of source code must retain the above copyright notice,
009:         *    this list of conditions and the following disclaimer.
010:         * 2. 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:         * 3. Neither the name of pdfbox; nor the names of its
014:         *    contributors may be used to endorse or promote products derived from this
015:         *    software without specific prior written permission.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020:         * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022:         * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025:         * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027:         *
028:         * http://www.pdfbox.org
029:         *
030:         */package org.pdfbox.pdmodel.font;
031:
032:        import java.io.IOException;
033:
034:        import org.fontbox.afm.FontMetric;
035:
036:        import org.pdfbox.pdmodel.common.PDRectangle;
037:
038:        import org.fontbox.util.BoundingBox;
039:
040:        /**
041:         * This class represents the font descriptor when the font information
042:         * is coming from an AFM file.
043:         *
044:         * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
045:         * @version $Revision: 1.3 $
046:         */
047:        public class PDFontDescriptorAFM extends PDFontDescriptor {
048:            private FontMetric afm;
049:
050:            /**
051:             * Constructor.
052:             *
053:             * @param afmFile The AFM file.
054:             */
055:            public PDFontDescriptorAFM(FontMetric afmFile) {
056:                afm = afmFile;
057:            }
058:
059:            /**
060:             * Get the font name.
061:             *
062:             * @return The name of the font.
063:             */
064:            public String getFontName() {
065:                return afm.getFontName();
066:            }
067:
068:            /**
069:             * This will set the font name.
070:             *
071:             * @param fontName The new name for the font.
072:             */
073:            public void setFontName(String fontName) {
074:                throw new UnsupportedOperationException(
075:                        "The AFM Font descriptor is immutable");
076:            }
077:
078:            /**
079:             * A string representing the preferred font family.
080:             *
081:             * @return The font family.
082:             */
083:            public String getFontFamily() {
084:                return afm.getFamilyName();
085:            }
086:
087:            /**
088:             * This will set the font family.
089:             *
090:             * @param fontFamily The font family.
091:             */
092:            public void setFontFamily(String fontFamily) {
093:                throw new UnsupportedOperationException(
094:                        "The AFM Font descriptor is immutable");
095:            }
096:
097:            /**
098:             * The weight of the font.  According to the PDF spec "possible values are
099:             * 100, 200, 300, 400, 500, 600, 700, 800 or 900"  Where a higher number is
100:             * more weight and appears to be more bold.
101:             *
102:             * @return The font weight.
103:             */
104:            public float getFontWeight() {
105:                String weight = afm.getWeight();
106:                float retval = 500;
107:                if (weight != null && weight.equalsIgnoreCase("bold")) {
108:                    retval = 900;
109:                } else if (weight != null && weight.equalsIgnoreCase("light")) {
110:                    retval = 100;
111:                }
112:                return retval;
113:            }
114:
115:            /**
116:             * Set the weight of the font.
117:             *
118:             * @param fontWeight The new weight of the font.
119:             */
120:            public void setFontWeight(float fontWeight) {
121:                throw new UnsupportedOperationException(
122:                        "The AFM Font descriptor is immutable");
123:            }
124:
125:            /**
126:             * A string representing the preferred font stretch.
127:             *
128:             * @return The font stretch.
129:             */
130:            public String getFontStretch() {
131:                return null;
132:            }
133:
134:            /**
135:             * This will set the font stretch.
136:             *
137:             * @param fontStretch The font stretch
138:             */
139:            public void setFontStretch(String fontStretch) {
140:                throw new UnsupportedOperationException(
141:                        "The AFM Font descriptor is immutable");
142:            }
143:
144:            /**
145:             * This will get the font flags.
146:             *
147:             * @return The font flags.
148:             */
149:            public int getFlags() {
150:                //I believe that the only flag that AFM supports is the is fixed pitch
151:                return afm.isFixedPitch() ? 1 : 0;
152:            }
153:
154:            /**
155:             * This will set the font flags.
156:             *
157:             * @param flags The new font flags.
158:             */
159:            public void setFlags(int flags) {
160:                throw new UnsupportedOperationException(
161:                        "The AFM Font descriptor is immutable");
162:            }
163:
164:            /**
165:             * This will get the fonts bouding box.
166:             *
167:             * @return The fonts bouding box.
168:             */
169:            public PDRectangle getFontBoundingBox() {
170:                BoundingBox box = afm.getFontBBox();
171:                PDRectangle retval = null;
172:                if (box != null) {
173:                    retval = new PDRectangle(box);
174:                }
175:                return retval;
176:            }
177:
178:            /**
179:             * Set the fonts bounding box.
180:             *
181:             * @param rect The new bouding box.
182:             */
183:            public void setFontBoundingBox(PDRectangle rect) {
184:                throw new UnsupportedOperationException(
185:                        "The AFM Font descriptor is immutable");
186:            }
187:
188:            /**
189:             * This will get the italic angle for the font.
190:             *
191:             * @return The italic angle.
192:             */
193:            public float getItalicAngle() {
194:                return afm.getItalicAngle();
195:            }
196:
197:            /**
198:             * This will set the italic angle for the font.
199:             *
200:             * @param angle The new italic angle for the font.
201:             */
202:            public void setItalicAngle(float angle) {
203:                throw new UnsupportedOperationException(
204:                        "The AFM Font descriptor is immutable");
205:            }
206:
207:            /**
208:             * This will get the ascent for the font.
209:             *
210:             * @return The ascent.
211:             */
212:            public float getAscent() {
213:                return afm.getAscender();
214:            }
215:
216:            /**
217:             * This will set the ascent for the font.
218:             *
219:             * @param ascent The new ascent for the font.
220:             */
221:            public void setAscent(float ascent) {
222:                throw new UnsupportedOperationException(
223:                        "The AFM Font descriptor is immutable");
224:            }
225:
226:            /**
227:             * This will get the descent for the font.
228:             *
229:             * @return The descent.
230:             */
231:            public float getDescent() {
232:                return afm.getDescender();
233:            }
234:
235:            /**
236:             * This will set the descent for the font.
237:             *
238:             * @param descent The new descent for the font.
239:             */
240:            public void setDescent(float descent) {
241:                throw new UnsupportedOperationException(
242:                        "The AFM Font descriptor is immutable");
243:            }
244:
245:            /**
246:             * This will get the leading for the font.
247:             *
248:             * @return The leading.
249:             */
250:            public float getLeading() {
251:                //AFM does not support setting the leading so we will just ignore it.
252:                return 0f;
253:            }
254:
255:            /**
256:             * This will set the leading for the font.
257:             *
258:             * @param leading The new leading for the font.
259:             */
260:            public void setLeading(float leading) {
261:                throw new UnsupportedOperationException(
262:                        "The AFM Font descriptor is immutable");
263:            }
264:
265:            /**
266:             * This will get the CapHeight for the font.
267:             *
268:             * @return The cap height.
269:             */
270:            public float getCapHeight() {
271:                return afm.getCapHeight();
272:            }
273:
274:            /**
275:             * This will set the cap height for the font.
276:             *
277:             * @param capHeight The new cap height for the font.
278:             */
279:            public void setCapHeight(float capHeight) {
280:                throw new UnsupportedOperationException(
281:                        "The AFM Font descriptor is immutable");
282:            }
283:
284:            /**
285:             * This will get the x height for the font.
286:             *
287:             * @return The x height.
288:             */
289:            public float getXHeight() {
290:                return afm.getXHeight();
291:            }
292:
293:            /**
294:             * This will set the x height for the font.
295:             *
296:             * @param xHeight The new x height for the font.
297:             */
298:            public void setXHeight(float xHeight) {
299:                throw new UnsupportedOperationException(
300:                        "The AFM Font descriptor is immutable");
301:            }
302:
303:            /**
304:             * This will get the stemV for the font.
305:             *
306:             * @return The stem v value.
307:             */
308:            public float getStemV() {
309:                //afm does not have a stem v
310:                return 0;
311:            }
312:
313:            /**
314:             * This will set the stem V for the font.
315:             *
316:             * @param stemV The new stem v for the font.
317:             */
318:            public void setStemV(float stemV) {
319:                throw new UnsupportedOperationException(
320:                        "The AFM Font descriptor is immutable");
321:            }
322:
323:            /**
324:             * This will get the stemH for the font.
325:             *
326:             * @return The stem h value.
327:             */
328:            public float getStemH() {
329:                //afm does not have a stem h
330:                return 0;
331:            }
332:
333:            /**
334:             * This will set the stem H for the font.
335:             *
336:             * @param stemH The new stem h for the font.
337:             */
338:            public void setStemH(float stemH) {
339:                throw new UnsupportedOperationException(
340:                        "The AFM Font descriptor is immutable");
341:            }
342:
343:            /**
344:             * This will get the average width for the font.
345:             *
346:             * @return The average width value.
347:             *
348:             * @throws IOException If there is an error calculating the average width.
349:             */
350:            public float getAverageWidth() throws IOException {
351:                return afm.getAverageCharacterWidth();
352:            }
353:
354:            /**
355:             * This will set the average width for the font.
356:             *
357:             * @param averageWidth The new average width for the font.
358:             */
359:            public void setAverageWidth(float averageWidth) {
360:                throw new UnsupportedOperationException(
361:                        "The AFM Font descriptor is immutable");
362:            }
363:
364:            /**
365:             * This will get the max width for the font.
366:             *
367:             * @return The max width value.
368:             */
369:            public float getMaxWidth() {
370:                //afm does not support max width;
371:                return 0;
372:            }
373:
374:            /**
375:             * This will set the max width for the font.
376:             *
377:             * @param maxWidth The new max width for the font.
378:             */
379:            public void setMaxWidth(float maxWidth) {
380:                throw new UnsupportedOperationException(
381:                        "The AFM Font descriptor is immutable");
382:            }
383:
384:            /**
385:             * This will get the missing width for the font.
386:             *
387:             * @return The missing width value.
388:             */
389:            public float getMissingWidth() {
390:                return 0;
391:            }
392:
393:            /**
394:             * This will set the missing width for the font.
395:             *
396:             * @param missingWidth The new missing width for the font.
397:             */
398:            public void setMissingWidth(float missingWidth) {
399:                throw new UnsupportedOperationException(
400:                        "The AFM Font descriptor is immutable");
401:            }
402:
403:            /**
404:             * This will get the character set for the font.
405:             *
406:             * @return The character set value.
407:             */
408:            public String getCharSet() {
409:                return afm.getCharacterSet();
410:            }
411:
412:            /**
413:             * This will set the character set for the font.
414:             *
415:             * @param charSet The new character set for the font.
416:             */
417:            public void setCharacterSet(String charSet) {
418:                throw new UnsupportedOperationException(
419:                        "The AFM Font descriptor is immutable");
420:            }
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.