internal static bool AreEqual(IFontInfo forReference, IFontInfo reference) { return(forReference.FamilyName == reference.FamilyName && forReference.FontWeight == reference.FontWeight && forReference.FontWidth == reference.FontWidth && forReference.Restrictions == reference.Restrictions && forReference.Selections == reference.Selections); }
public void EnsureReferenceMatched(IFontInfo reference) { this._ref = reference; if (reference.FamilyName != this.Tables.Names.GetInvariantName((int)NameTypes.FontFamily)) { throw new TypefaceReadException("The loaded font does not match the reference"); } }
public GuiLabs.Canvas.Point StringSize(string Text, IFontInfo theFont) { System.Drawing.SizeF s = new System.Drawing.SizeF(); s = mGraphics.MeasureString(Text, ((GDIPlusFontWrapper)theFont).Font); GuiLabs.Canvas.Point result = new GuiLabs.Canvas.Point((int)s.Width, (int)s.Height); return(result); }
public bool AddFont(string name, IFontInfo font) { if (String.IsNullOrEmpty(name) || font == null) { return(false); } mTextRenders.Add(name, new TextRender(font)); return(true); }
public Point StringSize(string Text, IFontInfo theFont) { SizeF s = new SizeF(); s = mGraphics.MeasureString(Text, ((GDIPlusFontWrapper)theFont).Font); Point result = new Point((int)s.Width, (int)s.Height); return(result); }
public Point StringSize(string Text, IFontInfo theFont) { IntPtr hOldFont = API.SelectObject(hDC, ((GDIFont)theFont).hFont); API.SIZE theSize = new API.SIZE(); API.GetTextExtentPoint32(hDC, Text, Text.Length, out theSize); Point result = new Point(theSize.x, theSize.y); API.SelectObject(hDC, hOldFont); return(result); }
public FormattedTextBuilder([NotNull] IFontInfo fontInfo, string text) { mFontInfo = fontInfo ?? throw new ArgumentNullException(nameof(fontInfo)); mText = text ?? string.Empty; mCulture = CultureInfo.CurrentCulture; mFlowDirection = System.Windows.FlowDirection.LeftToRight; mForeground = Brushes.Black; mNumberSubstitution = null; mTextFormattingMode = System.Windows.Media.TextFormattingMode.Display; mDpi = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null, null) as double? ?? 96.0; }
public static Typeface ToTypeFace(this IFontInfo fontInfo) => fontInfo == null ? null : new Typeface(fontInfo.FontFamily, fontInfo.FontStyle, fontInfo.FontWeight, fontInfo.FontStretch);
public static IFormattedTextBuilder Format(this IFontInfo fontInfo, string text) => new FormattedTextBuilder(fontInfo, text);
protected AbstractVectorRenderer() { mOutputSize = new Size(300, 300); mOutputDpi = new Vector(96, 96); mFontInfo = new DefaultFontInfo(); }
public static void Init(IGUIEventHandler eventHandler, IGUIGraphicsBind graphicsBind, IFontInfo fontinfo) { s_eventHandler = eventHandler; s_graphicsBind = graphicsBind; s_ctx = new GUICtx(); s_ctx.Font = fontinfo; GUI.Context = s_ctx; s_drawStages = new List <GUIDrawStage>(); s_drawStages.Add(new GUIDrawStageOverlay("Overlay", 1)); s_drawStages.Add(new GUIDrawStageMain("Main", 499)); s_drawStages.Sort((a, b) => { return(a.Order.CompareTo(b.Order)); }); eventHandler.EventUpdate += Update; }
public override ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source) { this.EnsureSeekable(reader); Utility.SingleTypefaceInfo found = null; if (forReference is Utility.SingleTypefaceInfo single) { found = single; } else { reader.Position = 0; var collection = this.ReadCollection(reader, null); for (int i = 0; i < collection.Count; i++) { var reference = collection[i]; if (Utility.SingleTypefaceInfo.AreEqual(forReference, reference)) { found = (Utility.SingleTypefaceInfo)reference; } } } if (null != found) { byte[] data = TTCollectionFile.ExtractTTFfromTTC(reader.BaseStream, (int)found.OffsetInFile); if (null != data && data.Length > 0) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data)) return(new TypefaceReader().GetFont(ms, source, forReference)); } } return(null); }
protected virtual ITypefaceFont ReadFile(TrueTypeHeader header, IEnumerable <TrueTypeTableEntry> dirs, BigEndianReader reader, long startOffset, IFontInfo reference) { var entries = new TrueTypeTableEntryList(dirs); TrueTypeFile file = new TrueTypeFile(header, entries); TrueTypeTableFactory factory = this.GetTableFactory(); foreach (TrueTypeTableEntry dir in dirs) { TrueTypeFontTable tbl = factory.ReadTable(dir, entries, reader); if (tbl != null) { dir.SetTable(tbl); } } file.EnsureReferenceMatched(reference); byte[] data = CopyStreamData(reader.BaseStream, startOffset); file.SetFileData(data, this.DataFormat); return(file); }
public override ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source) { long startOffset = reader.BaseStream.Position - 4; TrueTypeHeader header; if (TrueTypeHeader.TryReadHeaderAfterVersion(reader, this, false, out header) == false) { throw new TypefaceReadException("Could not read the TrueType header for " + forReference.ToString() + " font"); } List <TrueTypeTableEntry> dirs; try { dirs = new List <TrueTypeTableEntry>(); for (int i = 0; i < header.NumberOfTables; i++) { TrueTypeTableEntry dir = new TrueTypeTableEntry(); dir.Read(reader); dirs.Add(dir); } dirs.Sort(delegate(TrueTypeTableEntry one, TrueTypeTableEntry two) { return(one.Offset.CompareTo(two.Offset)); }); return(ReadFile(header, dirs, reader, startOffset, forReference)); } catch (Exception ex) { throw new TypefaceReadException("Could not read the TTF File", ex); } }
public TextRender(IFontInfo aFontInfo) { mFontInfo = aFontInfo; Init(); }
public override ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source) { long startOffset = reader.Position - VersionByteSize; WoffHeader header = WoffHeader.ReadHeader(this, reader); List <WoffTableEntry> list = new List <WoffTableEntry>(); for (var i = 0; i < header.NumberOfTables; i++) { WoffTableEntry entry = new WoffTableEntry(); entry.Read(reader); list.Add(entry); } list.Sort(delegate(WoffTableEntry one, WoffTableEntry two) { return(one.Offset.CompareTo(two.Offset)); }); var entries = new WoffTableEntryList(list); var file = new WoffFontFile(header, entries); var factory = this.GetTableFactory(); foreach (var entry in entries) { var tbl = factory.ReadTable(entry.Tag, entries, reader); if (null != tbl) { entry.SetTable(tbl); } } file.EnsureReferenceMatched(forReference); byte[] data = CopyStreamData(reader.BaseStream, startOffset); file.SetFileData(data, DataFormat.Woff); return(file); }
public Point StringSize(string Text, IFontInfo theFont) { SizeF s = new SizeF(); s = mGraphics.MeasureString(Text, ((GDIPlusFontWrapper)theFont).Font); Point result = new Point((int)s.Width, (int)s.Height); return result; }
public override ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source) { Woff2CacheData cache; //Because of the complexity of extracting even the info from a Woff2 typeface we can cache the data //between reading. if (!TryGetCached(source, out cache)) { cache = this.ReadCachableDataAfterVersion(reader, source); if (null == cache) { throw new TypefaceReadException("Could not read the typeface table data"); } SetCache(source, cache); } this.EnsureTablesDecoded(cache); return(base.ReadTypefaceAfterVersion(reader, forReference, source)); }
public Point StringSize(string Text, IFontInfo theFont) { return SourceDrawOperations.StringSize(Text, theFont); }
public GuiLabs.Canvas.Point StringSize(string Text, IFontInfo theFont) { System.Drawing.SizeF s = new System.Drawing.SizeF(); s = mGraphics.MeasureString(Text, ((GDIPlusFontWrapper)theFont).Font); GuiLabs.Canvas.Point result = new GuiLabs.Canvas.Point((int)s.Width, (int)s.Height); return result; }
public static void Init(IRigelWindowEventHandler eventHandler, IGUIGraphicsBind bind, IFontInfo fontinfo) { Init(new GUIEventHandler(eventHandler), bind, fontinfo); }
public Point StringSize(string Text, IFontInfo theFont) { IntPtr hOldFont = API.SelectObject(hDC, ((GDIFont)theFont).hFont); API.SIZE theSize = new API.SIZE(); API.GetTextExtentPoint32(hDC, Text, Text.Length, out theSize); Point result = new Point(theSize.x, theSize.y); API.SelectObject(hDC, hOldFont); return result; }
public Point StringSize(string Text, IFontInfo theFont) { return(SourceDrawOperations.StringSize(Text, theFont)); }
public abstract ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source);