using System.Runtime.InteropServices; #pragma warning disable CS3001, CS3002, CS3003, CS1591 namespace FastReport.Fonts { ///////////////////////////////////////////////////////////////////////////////////////////////// // PostScript table ///////////////////////////////////////////////////////////////////////////////////////////////// public class PostScriptClass : TrueTypeTable { #region "Type definition" [StructLayout(LayoutKind.Explicit, Pack = 1)] public struct PostScript { [FieldOffset(0)] public uint Version; // version number 0x00010000 for version 1.0. [FieldOffset(4)] public int ItalicAngle; // Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward). [FieldOffset(8)] public short underlinePosition; // This is the suggested distance of the top of the underline from the baseline (negative values indicate below baseline). [FieldOffset(10)] public short underlineThickness; // Suggested values for the underline thickness. [FieldOffset(12)] public uint isFixedPitch; // Set to 0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced (i.e. monospaced). [FieldOffset(16)] public uint minMemType42; // Minimum memory usage when an OpenType font is downloaded. [FieldOffset(20)] public uint maxMemType42; // Maximum memory usage when an OpenType font is downloaded. [FieldOffset(24)] public uint minMemType1; // Minimum memory usage when an OpenType font is downloaded as a Type 1 font. [FieldOffset(28)] public uint maxMemType1; // Maximum memory usage when an OpenType font is downloaded as a Type 1 font. } #endregion internal PostScript post_script; public bool IsItalic { get { return post_script.ItalicAngle != 0; } set { post_script.ItalicAngle = value ? post_script.ItalicAngle != 0 ? post_script.ItalicAngle : 1 : 0; } } public bool IsFixedPitch { get { return post_script.isFixedPitch != 0; } } private void ChangeEndian() { post_script.Version = SwapUInt32(post_script.Version); post_script.ItalicAngle = SwapInt32(post_script.ItalicAngle); post_script.underlinePosition = SwapInt16(post_script.underlinePosition); post_script.underlineThickness = SwapInt16(post_script.underlineThickness); post_script.isFixedPitch = SwapUInt32(post_script.isFixedPitch); post_script.minMemType42 = SwapUInt32(post_script.minMemType42); post_script.maxMemType42 = SwapUInt32(post_script.maxMemType42); post_script.minMemType1 = SwapUInt32(post_script.minMemType1); post_script.maxMemType1 = SwapUInt32(post_script.maxMemType1); } internal override void Load(FontStream stream) { stream.Seek(this.Offset, System.IO.SeekOrigin.Begin); post_script.Version = stream.ReadUInt32(); // version number 0x00010000 for version 1.0. post_script.ItalicAngle = stream.ReadInt32(); // Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward). post_script.underlinePosition = stream.ReadInt16(); // This is the suggested distance of the top of the underline from the baseline (negative values indicate below baseline). post_script.underlineThickness = stream.ReadInt16(); // Suggested values for the underline thickness. post_script.isFixedPitch = stream.ReadUInt32(); // Set to 0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced (i.e. monospaced). post_script.minMemType42 = stream.ReadUInt32(); // Minimum memory usage when an OpenType font is downloaded. post_script.maxMemType42 = stream.ReadUInt32(); // Maximum memory usage when an OpenType font is downloaded. post_script.minMemType1 = stream.ReadUInt32(); // Minimum memory usage when an OpenType font is downloaded as a Type 1 font. post_script.maxMemType1 = stream.ReadUInt32(); // Maximum memory usage when an OpenType font is downloaded as a Type 1 font. } internal override uint Save(FontStream source_not_used, FontStream font, uint offset) { font.Position = offset; post_script.Version = 0x00030000; font.WriteUInt32(post_script.Version); // public uint Version; // version number 0x00010000 for version 1.0. font.WriteInt32(post_script.Version); // public int ItalicAngle; // Italic angle in counter-clockwise degrees from the vertical. Zero for upright text, negative for text that leans to the right (forward). font.WriteInt16(post_script.underlinePosition); // public short underlinePosition; // This is the suggested distance of the top of the underline from the baseline (negative values indicate below baseline). font.WriteInt16(post_script.underlineThickness); // public short underlineThickness; // Suggested values for the underline thickness. font.WriteUInt32(post_script.isFixedPitch); // public uint isFixedPitch; // Set to 0 if the font is proportionally spaced, non-zero if the font is not proportionally spaced (i.e. monospaced). font.WriteUInt32(post_script.minMemType42); // public uint minMemType42; // Minimum memory usage when an OpenType font is downloaded. font.WriteUInt32(post_script.maxMemType42); // public uint maxMemType42; // Maximum memory usage when an OpenType font is downloaded. font.WriteUInt32(post_script.minMemType1); // public uint minMemType1; // Minimum memory usage when an OpenType font is downloaded as a Type 1 font. font.WriteUInt32(post_script.maxMemType1); // public uint maxMemType1; // Maximum memory usage when an OpenType font is downloaded as a Type 1 font. return offset + (uint)this.Length; } public int ItalicAngle { get { return post_script.ItalicAngle; } } public PostScriptClass(TrueTypeTable src) : base(src) { } } }