Ejemplo n.º 1
0
 public int GetFontSize(AdaptiveFontType fontType, AdaptiveTextSize requestedSize)
 {
     return(FontTypes.GetFontType(fontType).FontSizes.GetFontSize(requestedSize)
            ?? FontTypes.Default.FontSizes.GetFontSize(requestedSize)
            ?? FontSizes.GetFontSize(requestedSize)
            ?? FontSizesConfig.GetDefaultFontSize(requestedSize));
 }
Ejemplo n.º 2
0
 private FontInfo(FontTypes type, float size)
 {
     FontSize = size;
     FontName = type;
     Font     = new System.Drawing.Font(GetName(type), size);
     GFont    = Program.GameLogic.Graphics.Fonts.CreateFont(Font.Name, Font, GorgonLibrary.Graphics.FontAntiAliasMode.AntiAlias);
 }
Ejemplo n.º 3
0
 public GuiString(FontStyle font_style, FontTypes font_type, bool Center, string text)
 {
     this.font_style = font_style;
     this.font_type  = font_type;
     this.Center     = Center;
     this.Text       = text;
 }
Ejemplo n.º 4
0
 public int GetFontWeight(AdaptiveFontType fontType, AdaptiveTextWeight requestedWeight)
 {
     return(FontTypes.GetFontType(fontType).FontWeights.GetFontWeight(requestedWeight)
            ?? FontTypes.Default.FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeights.GetFontWeight(requestedWeight)
            ?? FontWeightsConfig.GetDefaultFontWeight(requestedWeight));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a font object loaded from a stream of data. The font is loaded
 /// into the document. The caller does not need to free the returned object.
 /// </summary>
 /// <param name="document">Handle to the document.</param>
 /// <param name="cid">A value specifying if the font is a CID font or not.</param>
 /// <param name="data">The data, which will be copied by the font object.</param>
 /// <param name="index">The index of the first byte to be copied from <paramref name="data"/>.</param>
 /// <param name="count">The number of bytes to copy from <paramref name="data"/> or a negative value to copy all bytes.</param>
 /// <returns>Returns NULL on failure.</returns>
 public static FPDF_FONT FPDFText_LoadFont(FPDF_DOCUMENT document, FontTypes font_type, bool cid, byte[] data, int index = -1, int count = 0)
 {
     if (count < 0)
     {
         count = data.Length - index;
     }
     return(FPDFText_LoadFont(document, ref data[index], (uint)count, font_type, cid));
 }
Ejemplo n.º 6
0
 private FontManager(TGraphics graphics, FontTypes type, float size)
 {
     _graphics = graphics;
     FontSize  = size;
     FontName  = type;
     Font      = new System.Drawing.Font(GetName(type), size);
     Bitmap    = graphics.Content.Load <SpriteFont>(string.Format("{0}-{1}", GetName(type), FontFileSize));
 }
Ejemplo n.º 7
0
        protected void Create(FontTypes fontType, int width, int height, int tileWidth, int tileHeight, int tileHeightBank, int bankCount)
        {
            this.Create(width, height, tileWidth, tileHeight);

            this.BankCount      = bankCount;
            this.TileHeightBank = tileHeightBank;
            this.TileSizeBank   = (tileHeightBank * tileHeight) * width;
            this.AddressBank0   = this.Address;
            this.FontType       = FontType;
        }
Ejemplo n.º 8
0
        public void Initialize(Argb32[] pixels, int address, FontTypes fontType, int width, int height, int tileWidth, int tileHeight, int tileHeightBank, int bankCount)
        {
            this.Initialize(pixels, address, width, height, tileWidth, tileHeight);

            this.BankCount      = bankCount;
            this.TileHeightBank = tileHeightBank;
            this.TileSizeBank   = (tileHeightBank * tileHeight) * width;
            this.AddressBank0   = this.Address;
            this.FontType       = fontType;
        }
Ejemplo n.º 9
0
        // private HashTable charecterMetrics;

        public PdfFont(string fontName, FontTypes subType, InstalledFonts baseFont)
        {
            nameObj     = new PdfName(fontName);
            subTypeObj  = new PdfName(subType.ToString());
            baseFontObj = new PdfName(baseFont.ToString());
            this.Add(type, new PdfName("Font"));
            this.Add(this.name, nameObj);
            this.Add(this.subType, subTypeObj);
            this.Add(this.baseFont, baseFontObj);
            // this.Add(new PdfName("Encoding"), new PdfName("MacRomanEncoding"));
        }
Ejemplo n.º 10
0
        public Font GetFont(FontTypes type, FontStyle s)
        {
            int i = ((s & FontStyle.Bold) == FontStyle.Bold ? 1 : 0) |
                    ((s & FontStyle.Italic) == FontStyle.Italic ? 2 : 0) |
                    ((s & FontStyle.Underline) == FontStyle.Underline ? 4 : 0);

            if (shared_fonts[(int)type, i] == null)
            {
                shared_fonts[(int)type, i] = new Font(shared_fonts[(int)type, 0].FontFamily, shared_fonts[(int)type, 0].SizeInPoints, s);
            }

            return(shared_fonts[(int)type, i]);
        }
Ejemplo n.º 11
0
        private static int EnumerateFontCallback(
            ref ENUMLOGFONTEXDV fontAttributes,
            ref NEWTEXTMETRICEX textMetrics,
            FontTypes fontType,
            LPARAM lParam)
        {
            var info = (List <FontInformation>)GCHandle.FromIntPtr(lParam).Target;

            info.Add(new FontInformation {
                FontType = fontType, TextMetrics = textMetrics, FontAttributes = fontAttributes
            });
            return(1);
        }
Ejemplo n.º 12
0
        public static FontInfo GetInstance(float size, FontTypes name)
        {
            foreach (FontInfo obj in _data)
            {
                if (obj.FontName == name && obj.FontSize == size)
                {
                    return(obj);
                }
            }
            FontInfo font = new FontInfo(name, size);

            _data.Add(font);
            return(font);
        }
Ejemplo n.º 13
0
        public static FontManager GetInstance(TGraphics graphics, float size, FontTypes name)
        {
            foreach (FontManager obj in _data)
            {
                if (obj.FontName == name && obj.FontSize == size && obj._graphics == graphics)
                {
                    return(obj);
                }
            }
            FontManager font = new FontManager(graphics, name, size);

            _data.Add(font);
            return(font);
        }
Ejemplo n.º 14
0
        private static string GetName(FontTypes type)
        {
            switch (type)
            {
            default: return(@"Arial");

            case FontTypes.Sans: return(@"Arial");

            case FontTypes.Serif_Mono: return(@"Courier New");

            case FontTypes.Serif: return(@"Times New Roman");

            case FontTypes.Sans_Mono: return(@"Lucida Sans Typewriter");
            }
        }
Ejemplo n.º 15
0
        public static void LoadFonts(ObservableCollection <KeyName> target, FontTypes type, TappedEventHandler tapped, Action callback)
        {
            var fonts = FontHelper.FontList.Where(x => type == FontTypes.All ? true : x.Type == type.ToString());

            if (!FontHelper.IsLoaded)
            {
                ThreadPoolTimer.CreatePeriodicTimer((s) =>
                {
                    if (FontHelper.IsLoaded)
                    {
                        s.Cancel();
                        int i = 0;
                        foreach (var font in fonts)
                        {
                            DispatcherHelper.CheckBeginInvokeOnUI(() =>
                            {
                                font.ItemTapped = tapped;
                                target.Add(font);

                                if (callback != null && ++i == fonts.Count())
                                {
                                    callback();
                                }
                            });
                        }
                    }
                }, TimeSpan.FromMilliseconds(300));
            }
            else
            {
                foreach (var font in fonts)
                {
                    font.ItemTapped = tapped;
                    target.Add(font);
                    //System.Diagnostics.Debug.WriteLine($"{type} 폰트 로드 : {font.Key}");
                }

                callback?.Invoke();
            }
        }
Ejemplo n.º 16
0
// Ignore deprecation warnings for Font[Family|Weights|Sizes]
#pragma warning disable 0618
        // Handles inheritance behavior for retrieving the name of the font family given the desired AdaptiveFontType
        public string GetFontFamily(AdaptiveFontType fontType)
        {
            // Value saved in FontTypes.<desiredStyle>
            string fontFamilyValue = FontTypes.GetFontType(fontType).FontFamily;

            if (string.IsNullOrWhiteSpace(fontFamilyValue))
            {
                if (fontType == AdaptiveFontType.Monospace)
                {
                    fontFamilyValue = GetDefaultFontFamily(fontType);
                }
                else
                {
                    // Fallback to deprecated fontFamily value
                    fontFamilyValue = FontFamily;
                    if (string.IsNullOrEmpty(fontFamilyValue))
                    {
                        // Fallback to predefined system default value
                        fontFamilyValue = GetDefaultFontFamily(fontType);
                    }
                }
            }
            return(fontFamilyValue);
        }
Ejemplo n.º 17
0
// ---------------------------------------------------------------------------
        public void Write(Stream stream)
        {
            using (ZipFile zip = new ZipFile()) {
                FontTypes f   = new FontTypes();
                byte[]    pdf = Utility.PdfBytes(f);
                zip.AddEntry(Utility.ResultFileName(f.ToString() + ".pdf"), pdf);
                IEnumerable <String> set1 = from m
                                            in new ListUsedFonts().ListFonts(pdf)
                                            orderby m select m;
                StringBuilder sb = new StringBuilder();

/*
 * i don't have c:/windows/fonts/ARBLI__.TTF on my system;
 * if you compare to Java example __THIS__ result file will have
 * one __LESS__ font listed!
 */
                foreach (String fontname in set1)
                {
                    sb.AppendLine(fontname);
                }
                zip.AddEntry(RESULT, sb.ToString());
                zip.Save(stream);
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Create a Font of the specific type, horizontal scale and vertical scale
 /// </summary>
 /// <param name="type">The type of the font</param>
 /// <param name="hscale">The horizontal scale of the font</param>
 /// <param name="vscale">the vertical scale of the fonr</param>
 public Font(FontTypes type, double hscale, double vscale)
     : this()
 {
     CvCoreInvoke.cvInitFont(ref this, type, hscale, vscale, 0, 1, LineTypes.EightConnected);
 }
Ejemplo n.º 19
0
 public void SetFont(FontTypes aFont, string sourceName = "Global")
 {
     // m_DisplayText.fontStyle = m_TypesOfFonts[(int)aFont];
 }
Ejemplo n.º 20
0
 public static unsafe extern void cvInitFont(ref Font font, FontTypes fontFace, double hscale, double vscale, double shear,
     int thickness, LineTypes lineType);
Ejemplo n.º 21
0
 public GuiString( FontStyle font_style, FontTypes font_type, bool Center, string text )
 {
     this.font_style = font_style;
     this.font_type = font_type;
     this.Center = Center;
     this.Text = text;
 }
Ejemplo n.º 22
0
        public static async void LoadAllFont(ObservableCollection <PickerItem <string, string> > fontListSource, FontTypes fontTypes, Action callback)
        {
            await ThreadPool.RunAsync(async handler =>
            {
                if (fontTypes == FontTypes.All || fontTypes == FontTypes.CustomFont)
                {
                    //사용자 폰트
                    var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists);
                    var files  = await folder.GetFilesAsync();

                    foreach (var file in files.OrderByDescending(x => x.DateCreated))
                    {
                        await DispatcherHelper.RunAsync(async() =>
                        {
                            foreach (var fontItem in await GetFontItems(file))
                            {
                                if (!IgnoreFonts.Contains(fontItem.Name) && !fontListSource.Any(x => x.Name == fontItem.Name))
                                {
                                    fontListSource.Add(fontItem);
                                }
                            }
                        });
                    }
                }

                if (fontTypes == FontTypes.All || fontTypes == FontTypes.SystemFont)
                {
                    var defaultFontName = "Global User Interface";

                    //시스템 폰트
                    IList <NativeHelper.Font> fontList = NativeHelper.FontList.GetSystemFontList("en-us");
                    for (int i = 0; i < fontList.Count; i++)
                    {
                        NativeHelper.Font font = fontList[i];

                        string name = font.FamilyName;
                        //System.Diagnostics.Debug.WriteLine(name);
                        await Task.Delay(1);//한개씩 순차적 처리하기 위해 ...
                        await DispatcherHelper.RunAsync(() =>
                        {
                            if (!fontListSource.Any(x => x.Name == defaultFontName))
                            {
                                var defaultValueIndex = fontListSource.IndexOf(fontListSource.FirstOrDefault(x => x.Name.CompareTo(defaultFontName) > 0));

                                fontListSource.Insert(defaultValueIndex == -1 ? 0 : i, new PickerItem <string, string>()
                                {
                                    Name    = defaultFontName,
                                    Key     = defaultFontName,
                                    Payload = FontTypes.SystemFont.ToString()
                                });
                            }

                            if (!IgnoreFonts.Contains(name) && !fontListSource.Any(x => x.Name == name))
                            {
                                fontListSource.Add(new PickerItem <string, string>()
                                {
                                    Name    = name,
                                    Key     = name,
                                    Payload = FontTypes.SystemFont.ToString()
                                });
                            }
                        });
                    }
                }

                if (callback != null)
                {
                    callback.Invoke();
                }
            });
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Create a Font of the specific type, horizontal scale and vertical scale
 /// </summary>
 /// <param name="type">The type of the font.</param>
 /// <param name="hscale">The horizontal scale of the font.</param>
 /// <param name="vscale">The vertical scale of the font.</param>
 /// <param name="thickness">Font thickness.</param>
 public Font(FontTypes type, double hscale, double vscale, int thickness = 1)
     : this()
 {
     CvCoreInvoke.cvInitFont(ref this, type, hscale, vscale, 0, thickness, LineTypes.EightConnected);
 }
Ejemplo n.º 24
0
 public unsafe static extern void cvInitFont(ref Font font, FontTypes fontFace, double hscale, double vscale, double shear,
                                             int thickness, LineTypes lineType);
Ejemplo n.º 25
0
        public static void DrawString(TGraphics graphics, string text, float size, FontTypes name, Point position, Color color)
        {
            FontManager font = GetInstance(graphics, size, name);

            DrawString(font, text, position, color);
        }
Ejemplo n.º 26
0
        private static void PrepareBank(AssetFontSheet font, int tileWidth, int tileHeight, FontTypes fontType, int mapHeightBank)
        {
            font.TileWidth  = tileWidth;
            font.TileHeight = tileHeight;

            int fontMapHeight = font.Height / tileHeight;

            switch (fontType)
            {
            case FontTypes.PolychromeStatic:

                if (mapHeightBank <= 0)
                {
                    mapHeightBank = fontMapHeight;
                }
                font.BankCount = fontMapHeight / mapHeightBank;
                break;

            case FontTypes.MonochromeDynamic:
                // en mono il n'y a qu'une seule bank au départ
                mapHeightBank  = fontMapHeight;
                font.BankCount = 1;
                break;
            }

            font.MapHeightBank = mapHeightBank;
            font.FontType      = fontType;
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Draw some text (or don't) relative to the camera
 /// </summary>
 /// <param name="text"></param>
 /// <param name="position"></param>
 /// <param name="fontSize"></param>
 /// <param name="color"></param>
 /// <param name="type"></param>
 public static void DrawGameText(this string text, Vector2 position, float fontSize, Color?color = null, FontTypes type = FontTypes.Pericles)
 {
     // Only draw if on screen
     if (position.X > Globals.Camera.LeftDrawBound && position.X < Globals.Camera.RightDrawBound && position.Y > Globals.Camera.TopDrawBound && position.Y < Globals.Camera.BottomDrawBound)
     {
         var font    = Globals.Fonts[type];
         var size    = font.MeasureString(text);
         var scale   = fontSize / 50f;
         var scaledX = (position - scale * size / 2).X;
         var x       = scaledX - Globals.Camera.ScreenLeft;
         var y       = position.Y - Globals.Camera.ScreenTop;
         text.DrawLeftAlign(new Vector2(x, y), fontSize, color, type);
     }
 }
Ejemplo n.º 28
0
 public static void LoadFont(string fileName, FontTypes type)
 {
     Fonts[type] = ContentManager.Load <SpriteFont>(fileName);
 }
Ejemplo n.º 29
0
        public Font GetFont( FontTypes type, FontStyle s )
        {
            int i = ((s & FontStyle.Bold) == FontStyle.Bold ? 1 : 0 ) |
                ((s & FontStyle.Italic) == FontStyle.Italic ? 2 : 0 ) |
                ((s & FontStyle.Underline) == FontStyle.Underline ? 4 : 0 );
            if( shared_fonts[(int)type,i] == null )
                shared_fonts[(int)type,i] = new Font( shared_fonts[(int)type,0].FontFamily, shared_fonts[(int)type,0].SizeInPoints, s );

            return shared_fonts[(int)type,i];
        }
Ejemplo n.º 30
0
        public static void DrawLeftAlign(this string text, Vector2 position, float fontSize, Color?color = null, FontTypes type = FontTypes.Pericles)
        {
            var font      = Globals.Fonts[type];
            var size      = font.MeasureString(text);
            var scale     = fontSize / 50f;
            var y         = (position - scale * size / 2).Y;
            var fontColor = color ?? Color.Black;

            Globals.SpriteDrawer.DrawString(font, text, new Vector2(position.X, y), fontColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
        }
Ejemplo n.º 31
0
        public static void DrawRightAlign(this string text, Vector2 position, float fontSize, Color?color = null, FontTypes type = FontTypes.Pericles)
        {
            var font  = Globals.Fonts[type];
            var size  = font.MeasureString(text);
            var scale = fontSize / 50f;
            var x     = (position - scale * size).X;

            text.DrawLeftAlign(new Vector2(x, position.Y), fontSize, color, type);
        }
Ejemplo n.º 32
0
        public static string Wrap(this string text, float maxLineWidth, float fontSize, FontTypes fontType = FontTypes.Pericles)
        {
            var font       = Globals.Fonts[fontType];
            var words      = text.Split(' ');
            var sb         = new StringBuilder();
            var lineWidth  = 0f;
            var spaceWidth = font.MeasureString(" ").X;

            foreach (var word in words)
            {
                var size = font.MeasureString(word) * fontSize / CodingConstants.FontSize;

                if (lineWidth + size.X < maxLineWidth)
                {
                    sb.Append(word + " ");
                    lineWidth += size.X + spaceWidth;
                }
                else
                {
                    sb.Append("\n" + word + " ");
                    lineWidth = size.X + spaceWidth;
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Importation
        /// </summary>
        /// <param name="assetName"></param>
        /// <param name="stream"></param>
        /// <param name="fontType"></param>
        /// <param name="tileWidth"></param>
        /// <param name="tileHeight"></param>
        /// <param name="mapHeightBank"></param>
        /// <returns></returns>

        public static AssetFontSheet Import(Cartridge cartridge, string assetName, Stream stream, int tileWidth, int tileHeight, FontTypes fontType, int mapHeightBank = int.MaxValue)
        {
            AssetFontSheet font = new AssetFontSheet(cartridge);

            font.Name = assetName;
            font.ImportImage(stream);

            font.TileWidth  = tileWidth;
            font.TileHeight = tileHeight;

            if (mapHeightBank == int.MaxValue)
            {
                mapHeightBank = font.Height / font.TileHeight;
            }

            PrepareBank(font, tileWidth, tileHeight, fontType, mapHeightBank);

            return(font);
        }