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");
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public bool AddFont(string name, IFontInfo font)
        {
            if (String.IsNullOrEmpty(name) || font == null)
            {
                return(false);
            }

            mTextRenders.Add(name, new TextRender(font));
            return(true);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
            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;
            }
Exemplo n.º 8
0
 public static Typeface ToTypeFace(this IFontInfo fontInfo)
 => fontInfo == null ? null : new Typeface(fontInfo.FontFamily, fontInfo.FontStyle, fontInfo.FontWeight, fontInfo.FontStretch);
Exemplo n.º 9
0
 public static IFormattedTextBuilder Format(this IFontInfo fontInfo, string text)
 => new FormattedTextBuilder(fontInfo, text);
Exemplo n.º 10
0
 protected AbstractVectorRenderer()
 {
     mOutputSize = new Size(300, 300);
     mOutputDpi  = new Vector(96, 96);
     mFontInfo   = new DefaultFontInfo();
 }
Exemplo n.º 11
0
        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;
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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); }
        }
Exemplo n.º 15
0
        public TextRender(IFontInfo aFontInfo)
        {
            mFontInfo = aFontInfo;

            Init();
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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));
        }
Exemplo n.º 19
0
 public Point StringSize(string Text, IFontInfo theFont)
 {
     return SourceDrawOperations.StringSize(Text, theFont);
 }
Exemplo n.º 20
0
        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;
        }
Exemplo n.º 21
0
 public static void Init(IRigelWindowEventHandler eventHandler, IGUIGraphicsBind bind, IFontInfo fontinfo)
 {
     Init(new GUIEventHandler(eventHandler), bind, fontinfo);
 }
Exemplo n.º 22
0
        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));
 }
Exemplo n.º 24
0
 public abstract ITypefaceFont ReadTypefaceAfterVersion(BigEndianReader reader, IFontInfo forReference, string source);