internal Font(Workbook wb, FontRecord f) : base(wb) { _height = f.FontHeight; _options = f.Options; _color = wb.Palette.GetColor(f.ColorIdx); _boldNess = f.Boldness; _escapement = f.Escapement; _underline = f.Underline; _family = f.FontFamily; _characterSet = f.CharacterSet; _fontName = f.FontName; }
/// <summary> /// Initializes a new instance of the <see cref="Text" /> class. /// </summary> /// <param name="height">The height.</param> /// <param name="width">The width.</param> /// <param name="weight">The weight.</param> /// <param name="mipLevels">The mip levels.</param> /// <param name="isItalic">if set to <c>true</c> [is italic].</param> /// <param name="characterSet">The character set.</param> /// <param name="precision">The precision.</param> /// <param name="quality">The quality.</param> /// <param name="pitchAndFamily">The pitch and family.</param> /// <param name="faceName">Name of the face.</param> public Text(int height, int width, FontWeight weight, int mipLevels, bool isItalic, FontCharacterSet characterSet, FontPrecision precision, FontQuality quality, FontPitchAndFamily pitchAndFamily, string faceName) { font = new Font( Drawing.Direct3DDevice, height, width, weight, mipLevels, isItalic, characterSet, precision, quality, pitchAndFamily, faceName); }
public Text( string textValue, int height, int width, FontWeight weight, int mipLevels, bool isItalic, FontCharacterSet characterSet, FontPrecision precision, FontQuality quality, FontPitchAndFamily pitchAndFamily, string faceName) { // Initialize properties _textValue = textValue; ReplaceFont(height, width, weight, mipLevels, isItalic, characterSet, precision, quality, pitchAndFamily, faceName); RegisterEventHandlers(); }
public void ReplaceFont( int height, int width, FontWeight weight, int mipLevels, bool isItalic, FontCharacterSet characterSet, FontPrecision precision, FontQuality quality, FontPitchAndFamily pitchAndFamily, string faceName) { if (TextHandle != null) { TextHandle.Dispose(); } TextHandle = new Font(Drawing.Direct3DDevice, height, width, weight, mipLevels, isItalic, characterSet, precision, quality, pitchAndFamily, faceName); RecalculateBoundingAndDisplayedText(); }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the FONT record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public FontRecord(GenericBiff biff) { if(biff.Id == (ushort)RecordType.Font) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontHeight = reader.ReadUInt16(); _options = (FontOptions)reader.ReadUInt16(); _colorIdx = reader.ReadUInt16(); _boldness = new FontBoldness(reader.ReadUInt16()); _escapement = (FontEscape)reader.ReadUInt16(); _underline = (FontUnderline)reader.ReadByte(); _fontFamily = (FontFamily)reader.ReadByte(); _characterSet = (FontCharacterSet)reader.ReadByte(); /* byte reserved = */ reader.ReadByte(); byte len = reader.ReadByte(); _fontName = Reader.ReadComplexString(reader, len); } else throw new InvalidRecordIdException(biff.Id, RecordType.Font); }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the FONT record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public FontRecord(GenericBiff biff) { if (biff.Id == (ushort)RecordType.Font) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontHeight = reader.ReadUInt16(); _options = (FontOptions)reader.ReadUInt16(); _colorIdx = reader.ReadUInt16(); _boldness = new FontBoldness(reader.ReadUInt16()); _escapement = (FontEscape)reader.ReadUInt16(); _underline = (FontUnderline)reader.ReadByte(); _fontFamily = (FontFamily)reader.ReadByte(); _characterSet = (FontCharacterSet)reader.ReadByte(); byte reserved = reader.ReadByte(); byte len = reader.ReadByte(); _fontName = Reader.ReadComplexString(reader, len); } else { throw new InvalidRecordIdException(biff.Id, RecordType.Font); } }
/// <summary> /// Initializes a new instance of the <see cref="Font"/> class. /// </summary> /// <param name="device">The device.</param> /// <param name="height">The height.</param> /// <param name="width">The width.</param> /// <param name="weight">The weight.</param> /// <param name="mipLevels">The mip levels.</param> /// <param name="isItalic">if set to <c>true</c> [is italic].</param> /// <param name="characterSet">The character set.</param> /// <param name="precision">The precision.</param> /// <param name="quality">The quality.</param> /// <param name="pitchAndFamily">The pitch and family.</param> /// <param name="faceName">Name of the face.</param> public Font(Device device, int height, int width, FontWeight weight, int mipLevels, bool isItalic, FontCharacterSet characterSet, FontPrecision precision, FontQuality quality, FontPitchAndFamily pitchAndFamily, string faceName) { D3DX9.CreateFont(device, height, width, (int)weight, mipLevels, isItalic, (int)characterSet, (int)precision, (int)quality, (int)pitchAndFamily, faceName, this); }
/// <summary> Add a new font specification. </summary> /// <param name="fontSpecification"> The font specification string. <see cref="System.String"/> </param> /// <remarks> Syntax is: "-foundry-family-weight-slant-width-additional style-pixels-tenths of points-horz resolution DPI-vert resolution DPI-spacing-tenths of average pixel width-charter set" </remarks> public void AddFontSpecification(string fontSpecification) { string[] spec = fontSpecification.Split('-'); if (!string.IsNullOrEmpty(spec[0])) { SimpleLog.LogLine(TraceEventType.Warning, CLASS_NAME + "::AddFontSpecification (" + fontSpecification + ") Font specification has leading characters '" + spec[0] + "' but shouldn't."); } if (spec.Length < 14) { SimpleLog.LogLine(TraceEventType.Error, CLASS_NAME + "::AddFontSpecification (" + fontSpecification + ") Font specification contains only " + spec.Length + " parts but must contain 14!"); return; } FontFoundry foundry = GetFoundry(spec[1]); if (foundry == null) { foundry = new FontFoundry(spec[1]); Foundries.Add(foundry); } FontFamily family = foundry.GetFamily(spec[2]); if (family == null) { family = new FontFamily(spec[2], _preferredCharSet); foundry.Families.Add(family); } FontCharacterSet characterSet = family.GetCharacterSet(spec[13], (spec.Length > 14 ? spec[14] : "")); if (characterSet == null) { characterSet = new FontCharacterSet(spec[13], (spec.Length > 14 ? spec[14] : "")); family.CharacterSets.Add(characterSet); } string styleName = FontWeightSlantWidthFlag.ToName(spec[3], spec[4], spec[5], spec[6]); FontWeightSlantWidthFlag weightSlantWidth = characterSet.GetWeightSlantWidthFlag(styleName); if (weightSlantWidth == null) { weightSlantWidth = new FontWeightSlantWidthFlag(spec[3], spec[4], spec[5], spec[6]); characterSet.WeightSlantWidths.Add(weightSlantWidth); } string resolutionName = FontHorzResolutionDpiVertResolutionDpi.ToName(spec[9], spec[10]); FontHorzResolutionDpiVertResolutionDpi resolution = weightSlantWidth.GetHorzResolutionDpiVertResolutionDpi(resolutionName); if (resolution == null) { resolution = new FontHorzResolutionDpiVertResolutionDpi(spec[9], spec[10]); weightSlantWidth.ResolutionDpis.Add(resolution); } string sizeName = FontPixelTenthOfPointSpacingTenthOfAveragePixelWidth.ToName(spec[7], spec[8], spec[11], spec[12]); FontPixelTenthOfPointSpacingTenthOfAveragePixelWidth size = resolution.GetPixelTenthOfPointSpacingTenthOfAveragePixelWidth(sizeName); if (size == null) { size = new FontPixelTenthOfPointSpacingTenthOfAveragePixelWidth(spec[7], spec[8], spec[11], spec[12]); resolution.Sizes.Add(size); } }