1 /* 2 3 ============================================================================ 4 The Apache Software License, Version 1.1 5 ============================================================================ 6 7 Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. 8 9 Redistribution and use in source and binary forms, with or without modifica- 10 tion, are permitted provided that the following conditions are met: 11 12 1. Redistributions of source code must retain the above copyright notice, 13 this list of conditions and the following disclaimer. 14 15 2. Redistributions in binary form must reproduce the above copyright notice, 16 this list of conditions and the following disclaimer in the documentation 17 and/or other materials provided with the distribution. 18 19 3. The end-user documentation included with the redistribution, if any, must 20 include the following acknowledgment: "This product includes software 21 developed by the Apache Software Foundation (http://www.apache.org/)." 22 Alternately, this acknowledgment may appear in the software itself, if 23 and wherever such third-party acknowledgments normally appear. 24 25 4. The names "Batik" and "Apache Software Foundation" must not be 26 used to endorse or promote products derived from this software without 27 prior written permission. For written permission, please contact 28 apache@apache.org. 29 30 5. Products derived from this software may not be called "Apache", nor may 31 "Apache" appear in their name, without prior written permission of the 32 Apache Software Foundation. 33 34 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 35 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 36 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 37 APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 38 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 39 DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 40 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 41 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 42 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 43 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 45 This software consists of voluntary contributions made by many individuals 46 on behalf of the Apache Software Foundation. For more information on the 47 Apache Software Foundation, please see <http://www.apache.org/>. 48 49 */ 50 51 package jogamp.graph.font.typecast.ot.table; 52 53 import java.io.DataInput; 54 import java.io.IOException; 55 56 import jogamp.graph.font.typecast.ot.Fixed; 57 58 59 /** 60 * @version $Id: HeadTable.java,v 1.2 2004-12-21 10:23:20 davidsch Exp $ 61 * @author <a href="mailto:davidsch@dev.java.net">David Schweinsberg</a> 62 */ 63 public class HeadTable implements Table { 64 65 private final DirectoryEntry _de; 66 private final int _versionNumber; 67 private final int _fontRevision; 68 private final int _checkSumAdjustment; 69 private final int _magicNumber; 70 private final short _flags; 71 private final short _unitsPerEm; 72 private final long _created; 73 private final long _modified; 74 private final short _xMin; 75 private final short _yMin; 76 private final short _xMax; 77 private final short _yMax; 78 private final short _macStyle; 79 private final short _lowestRecPPEM; 80 private final short _fontDirectionHint; 81 private final short _indexToLocFormat; 82 private final short _glyphDataFormat; 83 HeadTable(final DirectoryEntry de, final DataInput di)84 protected HeadTable(final DirectoryEntry de, final DataInput di) throws IOException { 85 this._de = (DirectoryEntry) de.clone(); 86 _versionNumber = di.readInt(); 87 _fontRevision = di.readInt(); 88 _checkSumAdjustment = di.readInt(); 89 _magicNumber = di.readInt(); 90 _flags = di.readShort(); 91 _unitsPerEm = di.readShort(); 92 _created = di.readLong(); 93 _modified = di.readLong(); 94 _xMin = di.readShort(); 95 _yMin = di.readShort(); 96 _xMax = di.readShort(); 97 _yMax = di.readShort(); 98 _macStyle = di.readShort(); 99 _lowestRecPPEM = di.readShort(); 100 _fontDirectionHint = di.readShort(); 101 _indexToLocFormat = di.readShort(); 102 _glyphDataFormat = di.readShort(); 103 } 104 getCheckSumAdjustment()105 public int getCheckSumAdjustment() { 106 return _checkSumAdjustment; 107 } 108 getCreated()109 public long getCreated() { 110 return _created; 111 } 112 getFlags()113 public short getFlags() { 114 return _flags; 115 } 116 getFontDirectionHint()117 public short getFontDirectionHint() { 118 return _fontDirectionHint; 119 } 120 getFontRevision()121 public int getFontRevision(){ 122 return _fontRevision; 123 } 124 getGlyphDataFormat()125 public short getGlyphDataFormat() { 126 return _glyphDataFormat; 127 } 128 getIndexToLocFormat()129 public short getIndexToLocFormat() { 130 return _indexToLocFormat; 131 } 132 getLowestRecPPEM()133 public short getLowestRecPPEM() { 134 return _lowestRecPPEM; 135 } 136 getMacStyle()137 public short getMacStyle() { 138 return _macStyle; 139 } 140 getModified()141 public long getModified() { 142 return _modified; 143 } 144 145 @Override getType()146 public int getType() { 147 return head; 148 } 149 getUnitsPerEm()150 public short getUnitsPerEm() { 151 return _unitsPerEm; 152 } 153 getVersionNumber()154 public int getVersionNumber() { 155 return _versionNumber; 156 } 157 getXMax()158 public short getXMax() { 159 return _xMax; 160 } 161 getXMin()162 public short getXMin() { 163 return _xMin; 164 } 165 getYMax()166 public short getYMax() { 167 return _yMax; 168 } 169 getYMin()170 public short getYMin() { 171 return _yMin; 172 } 173 174 @Override toString()175 public String toString() { 176 return new StringBuilder() 177 .append("'head' Table - Font Header\n--------------------------") 178 .append("\n 'head' version: ").append(Fixed.floatValue(_versionNumber)) 179 .append("\n fontRevision: ").append(Fixed.roundedFloatValue(_fontRevision, 8)) 180 .append("\n checkSumAdjustment: 0x").append(Integer.toHexString(_checkSumAdjustment).toUpperCase()) 181 .append("\n magicNumber: 0x").append(Integer.toHexString(_magicNumber).toUpperCase()) 182 .append("\n flags: 0x").append(Integer.toHexString(_flags).toUpperCase()) 183 .append("\n unitsPerEm: ").append(_unitsPerEm) 184 .append("\n created: ").append(_created) 185 .append("\n modified: ").append(_modified) 186 .append("\n xMin: ").append(_xMin) 187 .append("\n yMin: ").append(_yMin) 188 .append("\n xMax: ").append(_xMax) 189 .append("\n yMax: ").append(_yMax) 190 .append("\n macStyle bits: ").append(Integer.toHexString(_macStyle).toUpperCase()) 191 .append("\n lowestRecPPEM: ").append(_lowestRecPPEM) 192 .append("\n fontDirectionHint: ").append(_fontDirectionHint) 193 .append("\n indexToLocFormat: ").append(_indexToLocFormat) 194 .append("\n glyphDataFormat: ").append(_glyphDataFormat) 195 .toString(); 196 } 197 198 /** 199 * Get a directory entry for this table. This uniquely identifies the 200 * table in collections where there may be more than one instance of a 201 * particular table. 202 * @return A directory entry 203 */ 204 @Override getDirectoryEntry()205 public DirectoryEntry getDirectoryEntry() { 206 return _de; 207 } 208 209 } 210