Source Code Cross Referenced for FontFactory.java in  » PDF » pdf-itext » com » lowagie » text » 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 itext » com.lowagie.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: FontFactory.java 2366 2006-09-14 23:10:58Z xlv $
003:         * $Name$
004:         *
005:         * Copyright 2002 by Bruno Lowagie.
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version 1.1
008:         * (the "License"); you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010:         *
011:         * Software distributed under the License is distributed on an "AS IS" basis,
012:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013:         * for the specific language governing rights and limitations under the License.
014:         *
015:         * The Original Code is 'iText, a free JAVA-PDF library'.
016:         *
017:         * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018:         * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019:         * All Rights Reserved.
020:         * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021:         * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022:         *
023:         * Contributor(s): all the names of the contributors are added in the source code
024:         * where applicable.
025:         *
026:         * Alternatively, the contents of this file may be used under the terms of the
027:         * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028:         * provisions of LGPL are applicable instead of those above.  If you wish to
029:         * allow use of your version of this file only under the terms of the LGPL
030:         * License and not to allow others to use your version of this file under
031:         * the MPL, indicate your decision by deleting the provisions above and
032:         * replace them with the notice and other provisions required by the LGPL.
033:         * If you do not delete the provisions above, a recipient may use your version
034:         * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035:         *
036:         * This library is free software; you can redistribute it and/or modify it
037:         * under the terms of the MPL as stated above or under the terms of the GNU
038:         * Library General Public License as published by the Free Software Foundation;
039:         * either version 2 of the License, or any later version.
040:         *
041:         * This library is distributed in the hope that it will be useful, but WITHOUT
042:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043:         * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044:         * details.
045:         *
046:         * If you didn't download this code from the following link, you should check if
047:         * you aren't using an obsolete version:
048:         * http://www.lowagie.com/iText/
049:         */
050:
051:        package com.lowagie.text;
052:
053:        import java.awt.Color;
054:        import java.util.Properties;
055:        import java.util.Set;
056:
057:        import com.lowagie.text.pdf.BaseFont;
058:
059:        /**
060:         * If you are using True Type fonts, you can declare the paths of the different ttf- and ttc-files
061:         * to this static class first and then create fonts in your code using one of the static getFont-method
062:         * without having to enter a path as parameter.
063:         *
064:         * @author  Bruno Lowagie
065:         */
066:
067:        public class FontFactory {
068:
069:            /** This is a possible value of a base 14 type 1 font */
070:            public static final String COURIER = BaseFont.COURIER;
071:
072:            /** This is a possible value of a base 14 type 1 font */
073:            public static final String COURIER_BOLD = BaseFont.COURIER_BOLD;
074:
075:            /** This is a possible value of a base 14 type 1 font */
076:            public static final String COURIER_OBLIQUE = BaseFont.COURIER_OBLIQUE;
077:
078:            /** This is a possible value of a base 14 type 1 font */
079:            public static final String COURIER_BOLDOBLIQUE = BaseFont.COURIER_BOLDOBLIQUE;
080:
081:            /** This is a possible value of a base 14 type 1 font */
082:            public static final String HELVETICA = BaseFont.HELVETICA;
083:
084:            /** This is a possible value of a base 14 type 1 font */
085:            public static final String HELVETICA_BOLD = BaseFont.HELVETICA_BOLD;
086:
087:            /** This is a possible value of a base 14 type 1 font */
088:            public static final String HELVETICA_OBLIQUE = BaseFont.HELVETICA_OBLIQUE;
089:
090:            /** This is a possible value of a base 14 type 1 font */
091:            public static final String HELVETICA_BOLDOBLIQUE = BaseFont.HELVETICA_BOLDOBLIQUE;
092:
093:            /** This is a possible value of a base 14 type 1 font */
094:            public static final String SYMBOL = BaseFont.SYMBOL;
095:
096:            /** This is a possible value of a base 14 type 1 font */
097:            public static final String TIMES = "Times";
098:
099:            /** This is a possible value of a base 14 type 1 font */
100:            public static final String TIMES_ROMAN = BaseFont.TIMES_ROMAN;
101:
102:            /** This is a possible value of a base 14 type 1 font */
103:            public static final String TIMES_BOLD = BaseFont.TIMES_BOLD;
104:
105:            /** This is a possible value of a base 14 type 1 font */
106:            public static final String TIMES_ITALIC = BaseFont.TIMES_ITALIC;
107:
108:            /** This is a possible value of a base 14 type 1 font */
109:            public static final String TIMES_BOLDITALIC = BaseFont.TIMES_BOLDITALIC;
110:
111:            /** This is a possible value of a base 14 type 1 font */
112:            public static final String ZAPFDINGBATS = BaseFont.ZAPFDINGBATS;
113:
114:            private static FontFactoryImp fontImp = new FontFactoryImp();
115:
116:            /** This is the default encoding to use. */
117:            public static String defaultEncoding = BaseFont.WINANSI;
118:
119:            /** This is the default value of the <VAR>embedded</VAR> variable. */
120:            public static boolean defaultEmbedding = BaseFont.NOT_EMBEDDED;
121:
122:            /** Creates new FontFactory */
123:            private FontFactory() {
124:            }
125:
126:            /**
127:             * Constructs a <CODE>Font</CODE>-object.
128:             *
129:             * @param	fontname    the name of the font
130:             * @param	encoding    the encoding of the font
131:             * @param       embedded    true if the font is to be embedded in the PDF
132:             * @param	size	    the size of this font
133:             * @param	style	    the style of this font
134:             * @param	color	    the <CODE>Color</CODE> of this font.
135:             * @return the Font constructed based on the parameters
136:             */
137:
138:            public static Font getFont(String fontname, String encoding,
139:                    boolean embedded, float size, int style, Color color) {
140:                return fontImp.getFont(fontname, encoding, embedded, size,
141:                        style, color);
142:            }
143:
144:            /**
145:             * Constructs a <CODE>Font</CODE>-object.
146:             *
147:             * @param	fontname    the name of the font
148:             * @param	encoding    the encoding of the font
149:             * @param       embedded    true if the font is to be embedded in the PDF
150:             * @param	size	    the size of this font
151:             * @param	style	    the style of this font
152:             * @param	color	    the <CODE>Color</CODE> of this font.
153:             * @param	cached 		true if the font comes from the cache or is added to
154:             * 				the cache if new, false if the font is always created new
155:             * @return the Font constructed based on the parameters
156:             */
157:
158:            public static Font getFont(String fontname, String encoding,
159:                    boolean embedded, float size, int style, Color color,
160:                    boolean cached) {
161:                return fontImp.getFont(fontname, encoding, embedded, size,
162:                        style, color, cached);
163:            }
164:
165:            /**
166:             * Constructs a <CODE>Font</CODE>-object.
167:             *
168:             * @param   attributes  the attributes of a <CODE>Font</CODE> object.
169:             * @return the Font constructed based on the attributes
170:             */
171:
172:            public static Font getFont(Properties attributes) {
173:                fontImp.defaultEmbedding = defaultEmbedding;
174:                fontImp.defaultEncoding = defaultEncoding;
175:                return fontImp.getFont(attributes);
176:            }
177:
178:            /**
179:             * Constructs a <CODE>Font</CODE>-object.
180:             *
181:             * @param	fontname    the name of the font
182:             * @param	encoding    the encoding of the font
183:             * @param       embedded    true if the font is to be embedded in the PDF
184:             * @param	size	    the size of this font
185:             * @param	style	    the style of this font
186:             * @return the Font constructed based on the parameters
187:             */
188:
189:            public static Font getFont(String fontname, String encoding,
190:                    boolean embedded, float size, int style) {
191:                return getFont(fontname, encoding, embedded, size, style, null);
192:            }
193:
194:            /**
195:             * Constructs a <CODE>Font</CODE>-object.
196:             *
197:             * @param	fontname    the name of the font
198:             * @param	encoding    the encoding of the font
199:             * @param       embedded    true if the font is to be embedded in the PDF
200:             * @param	size	    the size of this font
201:             * @return the Font constructed based on the parameters
202:             */
203:
204:            public static Font getFont(String fontname, String encoding,
205:                    boolean embedded, float size) {
206:                return getFont(fontname, encoding, embedded, size,
207:                        Font.UNDEFINED, null);
208:            }
209:
210:            /**
211:             * Constructs a <CODE>Font</CODE>-object.
212:             *
213:             * @param	fontname    the name of the font
214:             * @param	encoding    the encoding of the font
215:             * @param       embedded    true if the font is to be embedded in the PDF
216:             * @return the Font constructed based on the parameters
217:             */
218:
219:            public static Font getFont(String fontname, String encoding,
220:                    boolean embedded) {
221:                return getFont(fontname, encoding, embedded, Font.UNDEFINED,
222:                        Font.UNDEFINED, null);
223:            }
224:
225:            /**
226:             * Constructs a <CODE>Font</CODE>-object.
227:             *
228:             * @param	fontname    the name of the font
229:             * @param	encoding    the encoding of the font
230:             * @param	size	    the size of this font
231:             * @param	style	    the style of this font
232:             * @param	color	    the <CODE>Color</CODE> of this font.
233:             * @return the Font constructed based on the parameters
234:             */
235:
236:            public static Font getFont(String fontname, String encoding,
237:                    float size, int style, Color color) {
238:                return getFont(fontname, encoding, defaultEmbedding, size,
239:                        style, color);
240:            }
241:
242:            /**
243:             * Constructs a <CODE>Font</CODE>-object.
244:             *
245:             * @param	fontname    the name of the font
246:             * @param	encoding    the encoding of the font
247:             * @param	size	    the size of this font
248:             * @param	style	    the style of this font
249:             * @return the Font constructed based on the parameters
250:             */
251:
252:            public static Font getFont(String fontname, String encoding,
253:                    float size, int style) {
254:                return getFont(fontname, encoding, defaultEmbedding, size,
255:                        style, null);
256:            }
257:
258:            /**
259:             * Constructs a <CODE>Font</CODE>-object.
260:             *
261:             * @param	fontname    the name of the font
262:             * @param	encoding    the encoding of the font
263:             * @param	size	    the size of this font
264:             * @return the Font constructed based on the parameters
265:             */
266:
267:            public static Font getFont(String fontname, String encoding,
268:                    float size) {
269:                return getFont(fontname, encoding, defaultEmbedding, size,
270:                        Font.UNDEFINED, null);
271:            }
272:
273:            /**
274:             * Constructs a <CODE>Font</CODE>-object.
275:             *
276:             * @param	fontname    the name of the font
277:             * @param	encoding    the encoding of the font
278:             * @return the Font constructed based on the parameters
279:             */
280:
281:            public static Font getFont(String fontname, String encoding) {
282:                return getFont(fontname, encoding, defaultEmbedding,
283:                        Font.UNDEFINED, Font.UNDEFINED, null);
284:            }
285:
286:            /**
287:             * Constructs a <CODE>Font</CODE>-object.
288:             *
289:             * @param	fontname    the name of the font
290:             * @param	size	    the size of this font
291:             * @param	style	    the style of this font
292:             * @param	color	    the <CODE>Color</CODE> of this font.
293:             * @return the Font constructed based on the parameters
294:             */
295:
296:            public static Font getFont(String fontname, float size, int style,
297:                    Color color) {
298:                return getFont(fontname, defaultEncoding, defaultEmbedding,
299:                        size, style, color);
300:            }
301:
302:            /**
303:             * Constructs a <CODE>Font</CODE>-object.
304:             *
305:             * @param	fontname    the name of the font
306:             * @param	size	    the size of this font
307:             * @param	style	    the style of this font
308:             * @return the Font constructed based on the parameters
309:             */
310:
311:            public static Font getFont(String fontname, float size, int style) {
312:                return getFont(fontname, defaultEncoding, defaultEmbedding,
313:                        size, style, null);
314:            }
315:
316:            /**
317:             * Constructs a <CODE>Font</CODE>-object.
318:             *
319:             * @param	fontname    the name of the font
320:             * @param	size	    the size of this font
321:             * @return the Font constructed based on the parameters
322:             */
323:
324:            public static Font getFont(String fontname, float size) {
325:                return getFont(fontname, defaultEncoding, defaultEmbedding,
326:                        size, Font.UNDEFINED, null);
327:            }
328:
329:            /**
330:             * Constructs a <CODE>Font</CODE>-object.
331:             *
332:             * @param	fontname    the name of the font
333:             * @return the Font constructed based on the parameters
334:             */
335:
336:            public static Font getFont(String fontname) {
337:                return getFont(fontname, defaultEncoding, defaultEmbedding,
338:                        Font.UNDEFINED, Font.UNDEFINED, null);
339:            }
340:
341:            /**
342:             * Register a font by giving explicitly the font family and name.
343:             * @param familyName the font family
344:             * @param fullName the font name
345:             * @param path the font path
346:             */
347:            public void registerFamily(String familyName, String fullName,
348:                    String path) {
349:                fontImp.registerFamily(familyName, fullName, path);
350:            }
351:
352:            /**
353:             * Register a ttf- or a ttc-file.
354:             *
355:             * @param   path    the path to a ttf- or ttc-file
356:             */
357:
358:            public static void register(String path) {
359:                register(path, null);
360:            }
361:
362:            /**
363:             * Register a font file and use an alias for the font contained in it.
364:             *
365:             * @param   path    the path to a font file
366:             * @param   alias   the alias you want to use for the font
367:             */
368:
369:            public static void register(String path, String alias) {
370:                fontImp.register(path, alias);
371:            }
372:
373:            /** Register all the fonts in a directory.
374:             * @param dir the directory
375:             * @return the number of fonts registered
376:             */
377:            public static int registerDirectory(String dir) {
378:                return fontImp.registerDirectory(dir);
379:            }
380:
381:            /** Register fonts in some probable directories. It usually works in Windows,
382:             * Linux and Solaris.
383:             * @return the number of fonts registered
384:             */
385:            public static int registerDirectories() {
386:                return fontImp.registerDirectories();
387:            }
388:
389:            /**
390:             * Gets a set of registered fontnames.
391:             * @return a set of registered fonts
392:             */
393:
394:            public static Set getRegisteredFonts() {
395:                return fontImp.getRegisteredFonts();
396:            }
397:
398:            /**
399:             * Gets a set of registered fontnames.
400:             * @return a set of registered font families
401:             */
402:
403:            public static Set getRegisteredFamilies() {
404:                return fontImp.getRegisteredFamilies();
405:            }
406:
407:            /**
408:             * Gets a set of registered fontnames.
409:             * @param fontname of a font that may or may not be registered
410:             * @return true if a given font is registered
411:             */
412:
413:            public static boolean contains(String fontname) {
414:                return fontImp.isRegistered(fontname);
415:            }
416:
417:            /**
418:             * Checks if a certain font is registered.
419:             *
420:             * @param   fontname    the name of the font that has to be checked.
421:             * @return  true if the font is found
422:             */
423:
424:            public static boolean isRegistered(String fontname) {
425:                return fontImp.isRegistered(fontname);
426:            }
427:
428:            /**
429:             * Gets the font factory implementation.
430:             * @return the font factory implementation
431:             */
432:            public static FontFactoryImp getFontImp() {
433:                return fontImp;
434:            }
435:
436:            /**
437:             * Sets the font factory implementation.
438:             * @param fontImp the font factory implementation
439:             */
440:            public static void setFontImp(FontFactoryImp fontImp) {
441:                if (fontImp == null)
442:                    throw new NullPointerException(
443:                            "FontFactoryImp cannot be null.");
444:                FontFactory.fontImp = fontImp;
445:            }
446:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.