001: /*
002: * $Id: MaxpTable.java,v 1.2 2007/12/20 18:33:31 rbair Exp $
003: *
004: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005: * Santa Clara, California 95054, U.S.A. All rights reserved.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020: */
021:
022: package com.sun.pdfview.font.ttf;
023:
024: import java.nio.ByteBuffer;
025:
026: /**
027: *
028: * @author jkaplan
029: */
030: public class MaxpTable extends TrueTypeTable {
031:
032: /** Holds value of property version. */
033: private int version;
034:
035: /** Holds value of property numGlyphs. */
036: private short numGlyphs;
037:
038: /** Holds value of property maxPoints. */
039: private short maxPoints;
040:
041: /** Holds value of property maxContours. */
042: private short maxContours;
043:
044: /** Holds value of property maxComponentPoints. */
045: private short maxComponentPoints;
046:
047: /** Holds value of property maxComponentContours. */
048: private short maxComponentContours;
049:
050: /** Holds value of property maxZones. */
051: private short maxZones;
052:
053: /** Holds value of property maxTwilightPoints. */
054: private short maxTwilightPoints;
055:
056: /** Holds value of property maxStorage. */
057: private short maxStorage;
058:
059: /** Holds value of property maxFunctionDefs. */
060: private short maxFunctionDefs;
061:
062: /** Holds value of property maxInstructionDefs. */
063: private short maxInstructionDefs;
064:
065: /** Holds value of property maxStackElements. */
066: private short maxStackElements;
067:
068: /** Holds value of property maxSizeOfInstructions. */
069: private short maxSizeOfInstructions;
070:
071: /** Holds value of property maxComponentElements. */
072: private short maxComponentElements;
073:
074: /** Holds value of property maxComponentDepth. */
075: private short maxComponentDepth;
076:
077: /** Creates a new instance of MaxpTable */
078: protected MaxpTable() {
079: super (TrueTypeTable.MAXP_TABLE);
080:
081: setVersion(0x10000);
082: setNumGlyphs((short) 0);
083: setMaxPoints((short) 0);
084: setMaxContours((short) 0);
085: setMaxComponentPoints((short) 0);
086: setMaxComponentContours((short) 0);
087: setMaxZones((short) 2);
088: setMaxTwilightPoints((short) 0);
089: setMaxStorage((short) 0);
090: setMaxFunctionDefs((short) 0);
091: setMaxInstructionDefs((short) 0);
092: setMaxStackElements((short) 0);
093: setMaxSizeOfInstructions((short) 0);
094: setMaxComponentElements((short) 0);
095: setMaxComponentDepth((short) 0);
096: }
097:
098: /**
099: * Set the values from data
100: */
101: public void setData(ByteBuffer data) {
102: if (data.remaining() != 32) {
103: throw new IllegalArgumentException(
104: "Bad size for Maxp table");
105: }
106:
107: setVersion(data.getInt());
108: setNumGlyphs(data.getShort());
109: setMaxPoints(data.getShort());
110: setMaxContours(data.getShort());
111: setMaxComponentPoints(data.getShort());
112: setMaxComponentContours(data.getShort());
113: setMaxZones(data.getShort());
114: setMaxTwilightPoints(data.getShort());
115: setMaxStorage(data.getShort());
116: setMaxFunctionDefs(data.getShort());
117: setMaxInstructionDefs(data.getShort());
118: setMaxStackElements(data.getShort());
119: setMaxSizeOfInstructions(data.getShort());
120: setMaxComponentElements(data.getShort());
121: setMaxComponentDepth(data.getShort());
122: }
123:
124: /**
125: * Get a buffer from the data
126: */
127: public ByteBuffer getData() {
128: ByteBuffer buf = ByteBuffer.allocate(getLength());
129:
130: buf.putInt(getVersion());
131: buf.putShort(getNumGlyphs());
132: buf.putShort(getMaxPoints());
133: buf.putShort(getMaxContours());
134: buf.putShort(getMaxComponentPoints());
135: buf.putShort(getMaxComponentContours());
136: buf.putShort(getMaxZones());
137: buf.putShort(getMaxTwilightPoints());
138: buf.putShort(getMaxStorage());
139: buf.putShort(getMaxFunctionDefs());
140: buf.putShort(getMaxInstructionDefs());
141: buf.putShort(getMaxStackElements());
142: buf.putShort(getMaxSizeOfInstructions());
143: buf.putShort(getMaxComponentElements());
144: buf.putShort(getMaxComponentDepth());
145:
146: // reset the position to the beginning of the buffer
147: buf.flip();
148:
149: return buf;
150: }
151:
152: /**
153: * Get the length of this table
154: */
155: public int getLength() {
156: return 32;
157: }
158:
159: /** Getter for property version.
160: * @return Value of property version.
161: *
162: */
163: public int getVersion() {
164: return this .version;
165: }
166:
167: /** Setter for property version.
168: * @param version New value of property version.
169: *
170: */
171: public void setVersion(int version) {
172: this .version = version;
173: }
174:
175: /** Getter for property numGlyphs.
176: * @return Value of property numGlyphs.
177: *
178: */
179: public short getNumGlyphs() {
180: return this .numGlyphs;
181: }
182:
183: /** Setter for property numGlyphs.
184: * @param numGlyphs New value of property numGlyphs.
185: *
186: */
187: public void setNumGlyphs(short numGlyphs) {
188: this .numGlyphs = numGlyphs;
189: }
190:
191: /** Getter for property maxPoints.
192: * @return Value of property maxPoints.
193: *
194: */
195: public short getMaxPoints() {
196: return this .maxPoints;
197: }
198:
199: /** Setter for property maxPoints.
200: * @param maxPoints New value of property maxPoints.
201: *
202: */
203: public void setMaxPoints(short maxPoints) {
204: this .maxPoints = maxPoints;
205: }
206:
207: /** Getter for property maxContours.
208: * @return Value of property maxContours.
209: *
210: */
211: public short getMaxContours() {
212: return this .maxContours;
213: }
214:
215: /** Setter for property maxContours.
216: * @param maxContours New value of property maxContours.
217: *
218: */
219: public void setMaxContours(short maxContours) {
220: this .maxContours = maxContours;
221: }
222:
223: /** Getter for property maxComponentPoints.
224: * @return Value of property maxComponentPoints.
225: *
226: */
227: public short getMaxComponentPoints() {
228: return this .maxComponentPoints;
229: }
230:
231: /** Setter for property maxComponentPoints.
232: * @param maxComponentPoints New value of property maxComponentPoints.
233: *
234: */
235: public void setMaxComponentPoints(short maxComponentPoints) {
236: this .maxComponentPoints = maxComponentPoints;
237: }
238:
239: /** Getter for property maxComponentContours.
240: * @return Value of property maxComponentContours.
241: *
242: */
243: public short getMaxComponentContours() {
244: return this .maxComponentContours;
245: }
246:
247: /** Setter for property maxComponentContours.
248: * @param maxComponentContours New value of property maxComponentContours.
249: *
250: */
251: public void setMaxComponentContours(short maxComponentContours) {
252: this .maxComponentContours = maxComponentContours;
253: }
254:
255: /** Getter for property maxZones.
256: * @return Value of property maxZones.
257: *
258: */
259: public short getMaxZones() {
260: return this .maxZones;
261: }
262:
263: /** Setter for property maxZones.
264: * @param maxZones New value of property maxZones.
265: *
266: */
267: public void setMaxZones(short maxZones) {
268: this .maxZones = maxZones;
269: }
270:
271: /** Getter for property maxTwilightPoints.
272: * @return Value of property maxTwilightPoints.
273: *
274: */
275: public short getMaxTwilightPoints() {
276: return this .maxTwilightPoints;
277: }
278:
279: /** Setter for property maxTwilightPoints.
280: * @param maxTwilightPoints New value of property maxTwilightPoints.
281: *
282: */
283: public void setMaxTwilightPoints(short maxTwilightPoints) {
284: this .maxTwilightPoints = maxTwilightPoints;
285: }
286:
287: /** Getter for property maxStorage.
288: * @return Value of property maxStorage.
289: *
290: */
291: public short getMaxStorage() {
292: return this .maxStorage;
293: }
294:
295: /** Setter for property maxStorage.
296: * @param maxStorage New value of property maxStorage.
297: *
298: */
299: public void setMaxStorage(short maxStorage) {
300: this .maxStorage = maxStorage;
301: }
302:
303: /** Getter for property maxFunctionDefs.
304: * @return Value of property maxFunctionDefs.
305: *
306: */
307: public short getMaxFunctionDefs() {
308: return this .maxFunctionDefs;
309: }
310:
311: /** Setter for property maxFunctionDefs.
312: * @param maxFunctionDefs New value of property maxFunctionDefs.
313: *
314: */
315: public void setMaxFunctionDefs(short maxFunctionDefs) {
316: this .maxFunctionDefs = maxFunctionDefs;
317: }
318:
319: /** Getter for property maxInstructionDefs.
320: * @return Value of property maxInstructionDefs.
321: *
322: */
323: public short getMaxInstructionDefs() {
324: return this .maxInstructionDefs;
325: }
326:
327: /** Setter for property maxInstructionDefs.
328: * @param maxInstructionDefs New value of property maxInstructionDefs.
329: *
330: */
331: public void setMaxInstructionDefs(short maxInstructionDefs) {
332: this .maxInstructionDefs = maxInstructionDefs;
333: }
334:
335: /** Getter for property maxStackElements.
336: * @return Value of property maxStackElements.
337: *
338: */
339: public short getMaxStackElements() {
340: return this .maxStackElements;
341: }
342:
343: /** Setter for property maxStackElements.
344: * @param maxStackElements New value of property maxStackElements.
345: *
346: */
347: public void setMaxStackElements(short maxStackElements) {
348: this .maxStackElements = maxStackElements;
349: }
350:
351: /** Getter for property maxSizeOfInstructions.
352: * @return Value of property maxSizeOfInstructions.
353: *
354: */
355: public short getMaxSizeOfInstructions() {
356: return this .maxSizeOfInstructions;
357: }
358:
359: /** Setter for property maxSizeOfInstructions.
360: * @param maxSizeOfInstructions New value of property maxSizeOfInstructions.
361: *
362: */
363: public void setMaxSizeOfInstructions(short maxSizeOfInstructions) {
364: this .maxSizeOfInstructions = maxSizeOfInstructions;
365: }
366:
367: /** Getter for property maxComponentElements.
368: * @return Value of property maxComponentElements.
369: *
370: */
371: public short getMaxComponentElements() {
372: return this .maxComponentElements;
373: }
374:
375: /** Setter for property maxComponentElements.
376: * @param maxComponentElements New value of property maxComponentElements.
377: *
378: */
379: public void setMaxComponentElements(short maxComponentElements) {
380: this .maxComponentElements = maxComponentElements;
381: }
382:
383: /** Getter for property maxComponentDepth.
384: * @return Value of property maxComponentDepth.
385: *
386: */
387: public short getMaxComponentDepth() {
388: return this .maxComponentDepth;
389: }
390:
391: /** Setter for property maxComponentDepth.
392: * @param maxComponentDepth New value of property maxComponentDepth.
393: *
394: */
395: public void setMaxComponentDepth(short maxComponentDepth) {
396: this .maxComponentDepth = maxComponentDepth;
397: }
398:
399: /**
400: * Create a pretty String
401: */
402: public String toString() {
403: StringBuffer buf = new StringBuffer();
404: String indent = " ";
405:
406: buf.append(indent + "Version : "
407: + Integer.toHexString(getVersion()) + "\n");
408: buf.append(indent + "NumGlyphs : " + getNumGlyphs()
409: + "\n");
410: buf.append(indent + "MaxPoints : " + getMaxPoints()
411: + "\n");
412: buf.append(indent + "MaxContours : " + getMaxContours()
413: + "\n");
414: buf.append(indent + "MaxCompPoints : "
415: + getMaxComponentPoints() + "\n");
416: buf.append(indent + "MaxCompContours : "
417: + getMaxComponentContours() + "\n");
418: buf.append(indent + "MaxZones : " + getMaxZones()
419: + "\n");
420: buf.append(indent + "MaxTwilightPoints: "
421: + getMaxTwilightPoints() + "\n");
422: buf.append(indent + "MaxStorage : " + getMaxStorage()
423: + "\n");
424: buf.append(indent + "MaxFuncDefs : "
425: + getMaxFunctionDefs() + "\n");
426: buf.append(indent + "MaxInstDefs : "
427: + getMaxInstructionDefs() + "\n");
428: buf.append(indent + "MaxStackElements : "
429: + getMaxStackElements() + "\n");
430: buf.append(indent + "MaxSizeInst : "
431: + getMaxSizeOfInstructions() + "\n");
432: buf.append(indent + "MaxCompElements : "
433: + getMaxComponentElements() + "\n");
434: buf.append(indent + "MaxCompDepth : "
435: + getMaxComponentDepth() + "\n");
436:
437: return buf.toString();
438: }
439: }
|