KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > ttf > OS2WindowsMetricsTable


1 /**
2  * Copyright (c) 2004, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.ttf;
32
33 import java.io.IOException JavaDoc;
34
35 /**
36  * A table in a true type font.
37  *
38  * @author Ben Litchfield (ben@csh.rit.edu)
39  * @version $Revision: 1.1 $
40  */

41 public class OS2WindowsMetricsTable extends TTFTable
42 {
43     
44     /**
45      * Weight class constant.
46      */

47     public static final int WEIGHT_CLASS_THIN = 100;
48     /**
49      * Weight class constant.
50      */

51     public static final int WEIGHT_CLASS_ULTRA_LIGHT = 200;
52     /**
53      * Weight class constant.
54      */

55     public static final int WEIGHT_CLASS_LIGHT = 300;
56     /**
57      * Weight class constant.
58      */

59     public static final int WEIGHT_CLASS_NORMAL = 400;
60     /**
61      * Weight class constant.
62      */

63     public static final int WEIGHT_CLASS_MEDIUM = 500;
64     /**
65      * Weight class constant.
66      */

67     public static final int WEIGHT_CLASS_SEMI_BOLD = 600;
68     /**
69      * Weight class constant.
70      */

71     public static final int WEIGHT_CLASS_BOLD = 700;
72     /**
73      * Weight class constant.
74      */

75     public static final int WEIGHT_CLASS_EXTRA_BOLD = 800;
76     /**
77      * Weight class constant.
78      */

79     public static final int WEIGHT_CLASS_BLACK = 900;
80     
81     /**
82      * Width class constant.
83      */

84     public static final int WIDTH_CLASS_ULTRA_CONDENSED = 1;
85     /**
86      * Width class constant.
87      */

88     public static final int WIDTH_CLASS_EXTRA_CONDENSED = 2;
89     /**
90      * Width class constant.
91      */

92     public static final int WIDTH_CLASS_CONDENSED = 3;
93     /**
94      * Width class constant.
95      */

96     public static final int WIDTH_CLASS_SEMI_CONDENSED = 4;
97     /**
98      * Width class constant.
99      */

100     public static final int WIDTH_CLASS_MEDIUM = 5;
101     /**
102      * Width class constant.
103      */

104     public static final int WIDTH_CLASS_SEMI_EXPANDED = 6;
105     /**
106      * Width class constant.
107      */

108     public static final int WIDTH_CLASS_EXPANDED = 7;
109     /**
110      * Width class constant.
111      */

112     public static final int WIDTH_CLASS_EXTRA_EXPANDED = 8;
113     /**
114      * Width class constant.
115      */

116     public static final int WIDTH_CLASS_ULTRA_EXPANDED = 9;
117     
118     /**
119      * Family class constant.
120      */

121     public static final int FAMILY_CLASS_NO_CLASSIFICATION = 0;
122     /**
123      * Family class constant.
124      */

125     public static final int FAMILY_CLASS_OLDSTYLE_SERIFS = 1;
126     /**
127      * Family class constant.
128      */

129     public static final int FAMILY_CLASS_TRANSITIONAL_SERIFS = 2;
130     /**
131      * Family class constant.
132      */

133     public static final int FAMILY_CLASS_MODERN_SERIFS = 3;
134     /**
135      * Family class constant.
136      */

137     public static final int FAMILY_CLASS_CLAREDON_SERIFS = 4;
138     /**
139      * Family class constant.
140      */

141     public static final int FAMILY_CLASS_SLAB_SERIFS = 5;
142     /**
143      * Family class constant.
144      */

145     public static final int FAMILY_CLASS_FREEFORM_SERIFS = 7;
146     /**
147      * Family class constant.
148      */

149     public static final int FAMILY_CLASS_SANS_SERIF = 8;
150     /**
151      * Family class constant.
152      */

153     public static final int FAMILY_CLASS_ORNAMENTALS = 9;
154     /**
155      * Family class constant.
156      */

157     public static final int FAMILY_CLASS_SCRIPTS = 10;
158     /**
159      * Family class constant.
160      */

161     public static final int FAMILY_CLASS_SYMBOLIC = 12;
162     
163     /**
164      * @return Returns the achVendId.
165      */

166     public String JavaDoc getAchVendId()
167     {
168         return achVendId;
169     }
170     /**
171      * @param achVendIdValue The achVendId to set.
172      */

173     public void setAchVendId(String JavaDoc achVendIdValue)
174     {
175         this.achVendId = achVendIdValue;
176     }
177     /**
178      * @return Returns the averageCharWidth.
179      */

180     public short getAverageCharWidth()
181     {
182         return averageCharWidth;
183     }
184     /**
185      * @param averageCharWidthValue The averageCharWidth to set.
186      */

187     public void setAverageCharWidth(short averageCharWidthValue)
188     {
189         this.averageCharWidth = averageCharWidthValue;
190     }
191     /**
192      * @return Returns the codePageRange1.
193      */

194     public long getCodePageRange1()
195     {
196         return codePageRange1;
197     }
198     /**
199      * @param codePageRange1Value The codePageRange1 to set.
200      */

201     public void setCodePageRange1(long codePageRange1Value)
202     {
203         this.codePageRange1 = codePageRange1Value;
204     }
205     /**
206      * @return Returns the codePageRange2.
207      */

208     public long getCodePageRange2()
209     {
210         return codePageRange2;
211     }
212     /**
213      * @param codePageRange2Value The codePageRange2 to set.
214      */

215     public void setCodePageRange2(long codePageRange2Value)
216     {
217         this.codePageRange2 = codePageRange2Value;
218     }
219     /**
220      * @return Returns the familyClass.
221      */

222     public short getFamilyClass()
223     {
224         return familyClass;
225     }
226     /**
227      * @param familyClassValue The familyClass to set.
228      */

229     public void setFamilyClass(short familyClassValue)
230     {
231         this.familyClass = familyClassValue;
232     }
233     /**
234      * @return Returns the firstCharIndex.
235      */

236     public int getFirstCharIndex()
237     {
238         return firstCharIndex;
239     }
240     /**
241      * @param firstCharIndexValue The firstCharIndex to set.
242      */

243     public void setFirstCharIndex(int firstCharIndexValue)
244     {
245         this.firstCharIndex = firstCharIndexValue;
246     }
247     /**
248      * @return Returns the fsSelection.
249      */

250     public int getFsSelection()
251     {
252         return fsSelection;
253     }
254     /**
255      * @param fsSelectionValue The fsSelection to set.
256      */

257     public void setFsSelection(int fsSelectionValue)
258     {
259         this.fsSelection = fsSelectionValue;
260     }
261     /**
262      * @return Returns the fsType.
263      */

264     public short getFsType()
265     {
266         return fsType;
267     }
268     /**
269      * @param fsTypeValue The fsType to set.
270      */

271     public void setFsType(short fsTypeValue)
272     {
273         this.fsType = fsTypeValue;
274     }
275     /**
276      * @return Returns the lastCharIndex.
277      */

278     public int getLastCharIndex()
279     {
280         return lastCharIndex;
281     }
282     /**
283      * @param lastCharIndexValue The lastCharIndex to set.
284      */

285     public void setLastCharIndex(int lastCharIndexValue)
286     {
287         this.lastCharIndex = lastCharIndexValue;
288     }
289     /**
290      * @return Returns the panose.
291      */

292     public byte[] getPanose()
293     {
294         return panose;
295     }
296     /**
297      * @param panoseValue The panose to set.
298      */

299     public void setPanose(byte[] panoseValue)
300     {
301         this.panose = panoseValue;
302     }
303     /**
304      * @return Returns the strikeoutPosition.
305      */

306     public short getStrikeoutPosition()
307     {
308         return strikeoutPosition;
309     }
310     /**
311      * @param strikeoutPositionValue The strikeoutPosition to set.
312      */

313     public void setStrikeoutPosition(short strikeoutPositionValue)
314     {
315         this.strikeoutPosition = strikeoutPositionValue;
316     }
317     /**
318      * @return Returns the strikeoutSize.
319      */

320     public short getStrikeoutSize()
321     {
322         return strikeoutSize;
323     }
324     /**
325      * @param strikeoutSizeValue The strikeoutSize to set.
326      */

327     public void setStrikeoutSize(short strikeoutSizeValue)
328     {
329         this.strikeoutSize = strikeoutSizeValue;
330     }
331     /**
332      * @return Returns the subscriptXOffset.
333      */

334     public short getSubscriptXOffset()
335     {
336         return subscriptXOffset;
337     }
338     /**
339      * @param subscriptXOffsetValue The subscriptXOffset to set.
340      */

341     public void setSubscriptXOffset(short subscriptXOffsetValue)
342     {
343         this.subscriptXOffset = subscriptXOffsetValue;
344     }
345     /**
346      * @return Returns the subscriptXSize.
347      */

348     public short getSubscriptXSize()
349     {
350         return subscriptXSize;
351     }
352     /**
353      * @param subscriptXSizeValue The subscriptXSize to set.
354      */

355     public void setSubscriptXSize(short subscriptXSizeValue)
356     {
357         this.subscriptXSize = subscriptXSizeValue;
358     }
359     /**
360      * @return Returns the subscriptYOffset.
361      */

362     public short getSubscriptYOffset()
363     {
364         return subscriptYOffset;
365     }
366     /**
367      * @param subscriptYOffsetValue The subscriptYOffset to set.
368      */

369     public void setSubscriptYOffset(short subscriptYOffsetValue)
370     {
371         this.subscriptYOffset = subscriptYOffsetValue;
372     }
373     /**
374      * @return Returns the subscriptYSize.
375      */

376     public short getSubscriptYSize()
377     {
378         return subscriptYSize;
379     }
380     /**
381      * @param subscriptYSizeValue The subscriptYSize to set.
382      */

383     public void setSubscriptYSize(short subscriptYSizeValue)
384     {
385         this.subscriptYSize = subscriptYSizeValue;
386     }
387     /**
388      * @return Returns the superscriptXOffset.
389      */

390     public short getSuperscriptXOffset()
391     {
392         return superscriptXOffset;
393     }
394     /**
395      * @param superscriptXOffsetValue The superscriptXOffset to set.
396      */

397     public void setSuperscriptXOffset(short superscriptXOffsetValue)
398     {
399         this.superscriptXOffset = superscriptXOffsetValue;
400     }
401     /**
402      * @return Returns the superscriptXSize.
403      */

404     public short getSuperscriptXSize()
405     {
406         return superscriptXSize;
407     }
408     /**
409      * @param superscriptXSizeValue The superscriptXSize to set.
410      */

411     public void setSuperscriptXSize(short superscriptXSizeValue)
412     {
413         this.superscriptXSize = superscriptXSizeValue;
414     }
415     /**
416      * @return Returns the superscriptYOffset.
417      */

418     public short getSuperscriptYOffset()
419     {
420         return superscriptYOffset;
421     }
422     /**
423      * @param superscriptYOffsetValue The superscriptYOffset to set.
424      */

425     public void setSuperscriptYOffset(short superscriptYOffsetValue)
426     {
427         this.superscriptYOffset = superscriptYOffsetValue;
428     }
429     /**
430      * @return Returns the superscriptYSize.
431      */

432     public short getSuperscriptYSize()
433     {
434         return superscriptYSize;
435     }
436     /**
437      * @param superscriptYSizeValue The superscriptYSize to set.
438      */

439     public void setSuperscriptYSize(short superscriptYSizeValue)
440     {
441         this.superscriptYSize = superscriptYSizeValue;
442     }
443     /**
444      * @return Returns the typeLineGap.
445      */

446     public int getTypeLineGap()
447     {
448         return typeLineGap;
449     }
450     /**
451      * @param typeLineGapValue The typeLineGap to set.
452      */

453     public void setTypeLineGap(int typeLineGapValue)
454     {
455         this.typeLineGap = typeLineGapValue;
456     }
457     /**
458      * @return Returns the typoAscender.
459      */

460     public int getTypoAscender()
461     {
462         return typoAscender;
463     }
464     /**
465      * @param typoAscenderValue The typoAscender to set.
466      */

467     public void setTypoAscender(int typoAscenderValue)
468     {
469         this.typoAscender = typoAscenderValue;
470     }
471     /**
472      * @return Returns the typoDescender.
473      */

474     public int getTypoDescender()
475     {
476         return typoDescender;
477     }
478     /**
479      * @param typoDescenderValue The typoDescender to set.
480      */

481     public void setTypoDescender(int typoDescenderValue)
482     {
483         this.typoDescender = typoDescenderValue;
484     }
485     /**
486      * @return Returns the unicodeRange1.
487      */

488     public long getUnicodeRange1()
489     {
490         return unicodeRange1;
491     }
492     /**
493      * @param unicodeRange1Value The unicodeRange1 to set.
494      */

495     public void setUnicodeRange1(long unicodeRange1Value)
496     {
497         this.unicodeRange1 = unicodeRange1Value;
498     }
499     /**
500      * @return Returns the unicodeRange2.
501      */

502     public long getUnicodeRange2()
503     {
504         return unicodeRange2;
505     }
506     /**
507      * @param unicodeRange2Value The unicodeRange2 to set.
508      */

509     public void setUnicodeRange2(long unicodeRange2Value)
510     {
511         this.unicodeRange2 = unicodeRange2Value;
512     }
513     /**
514      * @return Returns the unicodeRange3.
515      */

516     public long getUnicodeRange3()
517     {
518         return unicodeRange3;
519     }
520     /**
521      * @param unicodeRange3Value The unicodeRange3 to set.
522      */

523     public void setUnicodeRange3(long unicodeRange3Value)
524     {
525         this.unicodeRange3 = unicodeRange3Value;
526     }
527     /**
528      * @return Returns the unicodeRange4.
529      */

530     public long getUnicodeRange4()
531     {
532         return unicodeRange4;
533     }
534     /**
535      * @param unicodeRange4Value The unicodeRange4 to set.
536      */

537     public void setUnicodeRange4(long unicodeRange4Value)
538     {
539         this.unicodeRange4 = unicodeRange4Value;
540     }
541     /**
542      * @return Returns the version.
543      */

544     public int getVersion()
545     {
546         return version;
547     }
548     /**
549      * @param versionValue The version to set.
550      */

551     public void setVersion(int versionValue)
552     {
553         this.version = versionValue;
554     }
555     /**
556      * @return Returns the weightClass.
557      */

558     public int getWeightClass()
559     {
560         return weightClass;
561     }
562     /**
563      * @param weightClassValue The weightClass to set.
564      */

565     public void setWeightClass(int weightClassValue)
566     {
567         this.weightClass = weightClassValue;
568     }
569     /**
570      * @return Returns the widthClass.
571      */

572     public int getWidthClass()
573     {
574         return widthClass;
575     }
576     /**
577      * @param widthClassValue The widthClass to set.
578      */

579     public void setWidthClass(int widthClassValue)
580     {
581         this.widthClass = widthClassValue;
582     }
583     /**
584      * @return Returns the winAscent.
585      */

586     public int getWinAscent()
587     {
588         return winAscent;
589     }
590     /**
591      * @param winAscentValue The winAscent to set.
592      */

593     public void setWinAscent(int winAscentValue)
594     {
595         this.winAscent = winAscentValue;
596     }
597     /**
598      * @return Returns the winDescent.
599      */

600     public int getWinDescent()
601     {
602         return winDescent;
603     }
604     /**
605      * @param winDescentValue The winDescent to set.
606      */

607     public void setWinDescent(int winDescentValue)
608     {
609         this.winDescent = winDescentValue;
610     }
611     private int version;
612     private short averageCharWidth;
613     private int weightClass;
614     private int widthClass;
615     private short fsType;
616     private short subscriptXSize;
617     private short subscriptYSize;
618     private short subscriptXOffset;
619     private short subscriptYOffset;
620     private short superscriptXSize;
621     private short superscriptYSize;
622     private short superscriptXOffset;
623     private short superscriptYOffset;
624     private short strikeoutSize;
625     private short strikeoutPosition;
626     private short familyClass;
627     private byte[] panose = new byte[10];
628     private long unicodeRange1;
629     private long unicodeRange2;
630     private long unicodeRange3;
631     private long unicodeRange4;
632     private String JavaDoc achVendId;
633     private int fsSelection;
634     private int firstCharIndex;
635     private int lastCharIndex;
636     private int typoAscender;
637     private int typoDescender;
638     private int typeLineGap;
639     private int winAscent;
640     private int winDescent;
641     private long codePageRange1 = -1;
642     private long codePageRange2 = -1;
643     
644     /**
645      * A tag that identifies this table type.
646      */

647     public static final String JavaDoc TAG = "OS/2";
648     
649     /**
650      * This will read the required data from the stream.
651      *
652      * @param ttf The font that is being read.
653      * @param data The stream to read the data from.
654      * @throws IOException If there is an error reading the data.
655      */

656     public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException JavaDoc
657     {
658         version = data.readUnsignedShort();
659         averageCharWidth = data.readSignedShort();
660         weightClass = data.readUnsignedShort();
661         widthClass = data.readUnsignedShort();
662         fsType = data.readSignedShort();
663         subscriptXSize = data.readSignedShort();
664         subscriptYSize = data.readSignedShort();
665         subscriptXOffset = data.readSignedShort();
666         subscriptYOffset = data.readSignedShort();
667         superscriptXSize = data.readSignedShort();
668         superscriptYSize = data.readSignedShort();
669         superscriptXOffset = data.readSignedShort();
670         superscriptYOffset = data.readSignedShort();
671         strikeoutSize = data.readSignedShort();
672         strikeoutPosition = data.readSignedShort();
673         familyClass = data.readSignedShort();
674         panose = data.read( 10 );
675         unicodeRange1 = data.readUnsignedInt();
676         unicodeRange2 = data.readUnsignedInt();
677         unicodeRange3 = data.readUnsignedInt();
678         unicodeRange4 = data.readUnsignedInt();
679         achVendId = data.readString( 4 );
680         fsSelection = data.readUnsignedShort();
681         firstCharIndex = data.readUnsignedShort();
682         lastCharIndex = data.readUnsignedShort();
683         typoAscender = data.readSignedShort();
684         typoDescender = data.readSignedShort();
685         typeLineGap = data.readSignedShort();
686         winAscent = data.readUnsignedShort();
687         winDescent = data.readUnsignedShort();
688         if( version >= 1 )
689         {
690             codePageRange1 = data.readUnsignedInt();
691             codePageRange2 = data.readUnsignedInt();
692         }
693     }
694 }
695
Popular Tags