public BigEnd32(byte[] data, int offset) { this._sval = 0; this._val = 0; this._loword = new BigEnd16(data, offset); this._hiword = new BigEnd16(data, offset + 2); }
public string ReadUnicodeString(int len) { if (_unicodelocked) { throw new NotSupportedException("Cannot handle multitheaded use of a single instance"); } _unicodelocked = true; byte[] data = new byte[len]; this.BaseStream.Read(data, 0, len); _unicodechars.Clear(); len = data.Length % 2 == 0 ? data.Length : data.Length - 1; for (int i = 0; i < len; i += 2) { BigEnd16 word = new BigEnd16(data, i); ushort character = word.UnsignedValue; _unicodechars.Append((char)character); } string value = _unicodechars.ToString(); _unicodelocked = false; return(value); }
public short ReadInt16() { //byte[] data = new byte[2]; byte b1 = (byte)this.BaseStream.ReadByte(); byte b2 = (byte)this.BaseStream.ReadByte(); //this.BaseStream.Read(data, 0, 2); BigEnd16 word = new BigEnd16(b1, b2); return(word.SignedValue); }
/// <summary> /// Gets a version reader for a typeface from the reader at the current position /// </summary> /// <param name="reader">The bigendian reader to read the version from</param> /// <param name="vers">Set to the version reader if known</param> /// <returns>True if the version is known, otherwise false</returns> /// <remarks>This will check the current reader for a known version and move the position on 4 bytes</remarks> public static bool TryGetVersion(BigEndianReader reader, out TypefaceVersionReader vers, bool thrownOnUnsupported = false) { vers = null; byte[] data = reader.Read(4); char[] chars = ConvertToChars(data, 4); if (chars[0] == 'O' && chars[1] == 'T' && chars[2] == 'T' && chars[3] == 'O') //OTTO { vers = new OTTO.CCFOpenTypeVersionReader(new string(chars), data); } else if (chars[0] == 't' && chars[1] == 'r' && chars[2] == 'u' && chars[3] == 'e') //true { vers = new TTF.TrueTypeVersionReader(new string(chars), data); } else if (chars[0] == 't' && chars[1] == 'y' && chars[2] == 'p' && chars[3] == '1') //typ1 { vers = new TTF.TrueTypeVersionReader(new string(chars), data); } else if (chars[0] == 't' && chars[1] == 't' && chars[2] == 'c' && chars[3] == 'f') //ttcf { vers = new TTC.TTCollectionVersionReader(new string(chars), data); } else if (chars[0] == 'w' && chars[1] == 'O' && chars[2] == 'F' && chars[3] == 'F') //wOFF { vers = new Woff.WoffVersionReader(new string(chars), data); } else if (chars[0] == 'w' && chars[1] == 'O' && chars[2] == 'F' && chars[3] == '2') //wOF2 { vers = null; // new Woff2.Woff2VersionReader(new string(chars), data); } //throw new NotSupportedException("The Woff2 format is not currently supported."); else //1.0 { BigEnd16 wrd1 = new BigEnd16(data, 0); BigEnd16 wrd2 = new BigEnd16(data, 2); if (((int)wrd1.UnsignedValue) == 1 && ((int)wrd2.UnsignedValue) == 0) { vers = new OTTO.OpenType1VersionReader(wrd1.UnsignedValue, wrd2.UnsignedValue, data); } } return(vers != null); }