KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hdf > extractor > FontTable


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17         
18
19 package org.apache.poi.hdf.extractor;
20
21 /**
22  * Comment me
23  *
24  * @author Ryan Ackley
25  */

26
27 public class FontTable
28 {
29   String JavaDoc[] fontNames;
30
31   public FontTable(byte[] fontTable)
32   {
33     int size = Utils.convertBytesToShort(fontTable, 0);
34     fontNames = new String JavaDoc[size];
35
36     int currentIndex = 4;
37     for(int x = 0; x < size; x++)
38     {
39       byte ffnLength = fontTable[currentIndex];
40
41       int nameOffset = currentIndex + 40;
42       StringBuffer JavaDoc nameBuf = new StringBuffer JavaDoc();
43       char ch = Utils.getUnicodeCharacter(fontTable, nameOffset);
44       while(ch != '\0')
45       {
46         nameBuf.append(ch);
47         nameOffset += 2;
48         ch = Utils.getUnicodeCharacter(fontTable, nameOffset);
49       }
50       fontNames[x] = nameBuf.toString();
51       if(fontNames[x].startsWith("Times"))
52       {
53         fontNames[x] = "Times";
54       }
55
56       currentIndex += ffnLength + 1;
57     }
58
59   }
60   public String JavaDoc getFont(int index)
61   {
62     return fontNames[index];
63   }
64 }
65
Popular Tags