示例#1
0
        public static void SetupDefaultValues()
        {
            //--------
            if (s_isInit)
            {
                return;
            }
            //--------
            PixelFarm.Platforms.StorageService.RegisterProvider(s_filedb);
            myFontLoader = new OpenFontStore();
            //test Typography's custom text break,
            //check if we have that data?

            //string typographyDir = @"/icu/brkitr_src/dictionaries";
            //***
            string typographyDir = @"d:/test/icu60/brkitr_src/dictionaries";

            s_icuDataProvider = new MyIcuDataProvider();
            if (System.IO.Directory.Exists(typographyDir))
            {
                s_icuDataProvider.icuDir = typographyDir;
            }
            Typography.TextBreak.CustomBreakerBuilder.Setup(typographyDir);
            s_isInit = true;
        }
示例#2
0
        public AGSTextComponent(IRenderPipeline pipeline, IBoundingBoxBuilder boundingBoxBuilder,
                                IGLTextureRenderer textureRenderer, BitmapPool bitmapPool,
                                AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes,
                                IGLUtils glUtils, IGraphicsBackend graphics, IFontLoader fonts,
                                IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _pipeline = pipeline;
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();

            _instructionPool = new ObjectPool <Instruction>(pool => new Instruction(pool, glUtils, textureRenderer, _glTextHitTest), 0);

            TextVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged           += onPropertyChanged;
            _shouldUpdateBoundingBoxes = true;
        }
示例#3
0
        public static FontFile Load(string filename)
        {
            IFontLoader fontLoader = GetFontLoader(filename);
            FontFile    fontFile   = fontLoader.ReadFile(filename);

            return(fontFile);
        }
示例#4
0
文件: UIFonts.cs 项目: tivtag/Fly
 public static void Load(IFontLoader fontLoader)
 {
     tahoma10 = fontLoader.Load("Tahoma10");
     tahoma14 = fontLoader.Load("Tahoma14");
     quartz10 = fontLoader.Load("Quartz10");
     quartz14 = fontLoader.Load("Quartz14");
 }
        public static void CreateConvasControlOnExistingControl(
            Control landingControl,
            int xpos, int ypos,
            int w, int h,
            InnerViewportKind internalViewportKind,
            out LayoutFarm.UI.UISurfaceViewportControl canvasViewport)
        {
            //1. init
            InitWinform();
            IFontLoader fontLoader = s_fontstore;

            //2.
            PixelFarm.Drawing.ITextService ifont = null;
            switch (internalViewportKind)
            {
            default:
                ifont = PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.GetIFonts();
                //ifont = new OpenFontTextService();
                break;

            case InnerViewportKind.GL:
                ifont = new OpenFontTextService();
                break;
            }

            PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetFontLoader(fontLoader);

            //

            //---------------------------------------------------------------------------

            MyRootGraphic myRootGfx = new MyRootGraphic(
                w, h,
                ifont
                );

            //---------------------------------------------------------------------------

            var       innerViewport        = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl();
            Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea);

            canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind);
            canvasViewport.Bounds =
                new System.Drawing.Rectangle(xpos, ypos,
                                             screenClientAreaRect.Width,
                                             screenClientAreaRect.Height);

            landingControl.Controls.Add(canvasViewport);
            //
            Form ownerForm = landingControl.FindForm();

            if (ownerForm != null)
            {
                ownerForm.FormClosing += (s, e) =>
                {
                    innerViewport.Close();
                };
            }
        }
示例#6
0
        public VxsTextPrinter(CanvasPainter canvasPainter, IFontLoader fontLoader)
        {
            this.canvasPainter = canvasPainter;
            this._fontLoader   = fontLoader;

            this.ScriptLang = canvasPainter.CurrentFont.GetOpenFontScriptLang();
            ChangeFont(canvasPainter.CurrentFont);
        }
示例#7
0
 public static void SetFontLoader(IFontLoader fontLoader)
 {
     //warning if duplicate
     if (s_fontLoader != null)
     {
     }
     s_fontLoader = fontLoader;
 }
示例#8
0
 public DesktopFont(Font font, IFontLoader fontLoader, string path)
 {
     Trace.Assert(font != null, "font is null");
     Trace.Assert(font.FontFamily != null, "font.FontFamily is null");
     InnerFont   = font;
     _fontLoader = fontLoader;
     Path        = path;
 }
示例#9
0
 public OpenFontIFonts(IFontLoader fontloader)
 {
     this._fontloader             = fontloader;
     typefaceStore                = new TypefaceStore();
     typefaceStore.FontCollection = InstalledFontCollection.GetSharedFontCollection(null);
     glyphLayout            = new GlyphLayout(); //create glyph layout with default value
     userGlyphPlanList      = new List <GlyphPlan>();
     userCharToGlyphMapList = new List <UserCharToGlyphIndexMap>();
 }
示例#10
0
 public GLBmpGlyphTextPrinter(GLCanvasPainter painter, IFontLoader fontLoader)
 {
     //create text printer for use with canvas painter
     this.painter  = painter;
     this.canvas2d = painter.Canvas;
     _fontLoader   = fontLoader;
     //------
     ChangeFont(painter.CurrentFont);
 }
示例#11
0
        public FontSystem(IFontLoader fontLoader, ITexture2DManager textureCreator, int width = 1024, int height = 1024, int blurAmount = 0, int strokeAmount = 0, bool premultiplyAlpha = true)
#endif
        {
            if (fontLoader == null)
            {
                throw new ArgumentNullException(nameof(fontLoader));
            }

#if MONOGAME || FNA || STRIDE
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException(nameof(graphicsDevice));
            }

            _graphicsDevice = graphicsDevice;
#else
            if (textureCreator == null)
            {
                throw new ArgumentNullException(nameof(textureCreator));
            }

            _textureCreator = textureCreator;
#endif

            _fontLoader = fontLoader;

            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(width));
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(height));
            }

            if (blurAmount < 0 || blurAmount > 20)
            {
                throw new ArgumentOutOfRangeException(nameof(blurAmount));
            }

            if (strokeAmount < 0 || strokeAmount > 20)
            {
                throw new ArgumentOutOfRangeException(nameof(strokeAmount));
            }

            if (strokeAmount != 0 && blurAmount != 0)
            {
                throw new ArgumentException("Cannot have both blur and stroke.");
            }

            BlurAmount       = blurAmount;
            StrokeAmount     = strokeAmount;
            PremultiplyAlpha = premultiplyAlpha;

            _size = new Point(width, height);
        }
示例#12
0
        public FontTextureFactory(IFontLoader loader)
        {
            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            this.loader = loader;
        }
示例#13
0
        public VxsTextPrinter(CanvasPainter canvasPainter, IFontLoader fontLoader)
        {
            this.canvasPainter = canvasPainter;
            this._fontLoader   = fontLoader;

            _glyphMeshStore = new GlyphMeshStore();
            //
            _pxScaleEngine = new PixelScaleLayoutEngine();
            _pxScaleEngine.HintedFontStore = _glyphMeshStore;//share _glyphMeshStore with pixel-scale-layout-engine
        }
示例#14
0
 public AGSDialogFactory(Resolver resolver, IGameState gameState, IUIFactory ui, IObjectFactory obj,
                         IBrushLoader brushloader, IFontLoader fontLoader)
 {
     _resolver    = resolver;
     _brushLoader = brushloader;
     _fontLoader  = fontLoader;
     _gameState   = gameState;
     _ui          = ui;
     _object      = obj;
 }
示例#15
0
 static void InitWinform()
 {
     if (s_platform != null)
     {
         return;
     }
     //----------------------------------------------------
     s_platform  = new LayoutFarm.UI.UIPlatformWinForm();
     s_fontstore = new OpenFontStore();
 }
        public static ActualFont GetTextureFontAtlasOrCreateNew(
            IFontLoader fontLoader,
            RequestFont font,
            out SimpleFontAtlas fontAtlas)
        {
            //check if we have created this font
            var key = new FontTextureKey();

            key.fontName    = font.Name;
            key.scriptLang  = font.ScriptLang.shortname;
            key.sizeInPoint = font.SizeInPoints;
            key.fontStyle   = font.Style;
            //------------------------
            TextureAtlasCache found;
            FontFace          ff = null;

            if (!s_cachedFontAtlas.TryGetValue(key, out found))
            {
                //if not, then create the new one
                string fontfile = fontLoader.GetFont(font.Name, font.Style.ConvToInstalledFontStyle()).FontPath;
                //ptimize here
                //TODO: review
                TextureFontCreationParams creationParams = new TextureFontCreationParams();
                creationParams.originalFontSizeInPoint = font.SizeInPoints;
                creationParams.scriptLang     = font.ScriptLang;
                creationParams.writeDirection = WriteDirection.LTR;//default
                //TODO: review here, langBits can be created with scriptLang ?
                creationParams.langBits = new Typography.OpenFont.Tables.UnicodeLangBits[]
                {
                    Typography.OpenFont.Tables.UnicodeLangBits.BasicLatin, //0-127
                    Typography.OpenFont.Tables.UnicodeLangBits.Thai        //eg. Thai, for test with complex script, you can change to your own
                };
                //
                creationParams.textureKind = Typography.Rendering.TextureKind.AggSubPixel;
                if (font.SizeInPoints >= 4 && font.SizeInPoints <= 14)
                {
                    //creationParams.hintTechnique = Typography.Rendering.HintTechnique.TrueTypeInstruction;
                    //creationParams.hintTechnique = Typography.Rendering.HintTechnique.TrueTypeInstruction_VerticalOnly;
                    creationParams.hintTechnique = Typography.Rendering.HintTechnique.CustomAutoFit;
                }
                //
                ff = TextureFontLoader.LoadFont(fontfile, creationParams, out fontAtlas);


                //cache it
                var textureAtlasCache = new TextureAtlasCache();
                textureAtlasCache.fontFace = ff;
                textureAtlasCache.atlas    = fontAtlas;
                s_cachedFontAtlas.Add(key, textureAtlasCache);
                return(ff.GetFontAtPointSize(font.SizeInPoints));
            }
            fontAtlas = found.atlas;
            ff        = found.fontFace;
            return(ff.GetFontAtPointSize(font.SizeInPoints));
        }
示例#17
0
        public Chip8Emu(IFontLoader fontLoader, IAudioDevice audioDevice, IPPU ppu, IInputDevice inputDevice, byte[] rom)
        {
            _audioDevice = audioDevice;
            _ppu         = ppu;
            _inputDevice = inputDevice;

            Array.Copy(rom, 0, _memory, ROM_INDEX, rom.Length);

            var font = fontLoader.GetFont();

            Array.Copy(font, 0, _memory, FONT_INDEX, font.Length);

            _opCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0x0, Misc0 },
                { 0x1, JumpToNNN },
                { 0x2, CallSubroutine },
                { 0x3, SkipXEqualsNN },
                { 0x4, SkipXNotEqualsNN },
                { 0x5, SkipXEqualsY },
                { 0x6, SetXToNN },
                { 0x7, AddXToNN },
                { 0x8, Arithmetic },
                { 0x9, SkipXNotEqualsY },
                { 0xA, SetIToNNN },
                { 0xB, JumpToNNNPlusV0 },
                { 0xC, SetRandomX },
                { 0xD, DrawSprite },
                { 0xE, KeyPressedOps },
                { 0xF, MiscF },
            };
            _misc0OpCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0xE0, ClearScreen },
                { 0xEE, ReturnSubroutine },
            };
            _miscFOpCodes = new Dictionary <byte, Action <OpCodeData> >
            {
                { 0x07, SetXToTimer },
                { 0x0A, AwaitAndStoreKeyPress },
                { 0x15, SetDelayTimer },
                { 0x18, SetSoundTimer },
                { 0x1E, AddXToI },
                { 0x29, SetIToFont },
                { 0x33, SetIToBCD },
                { 0x55, SetX },
                { 0x65, LoadX },
            };

            var timer = new Timer(1000 / DISPLAY_HZ);

            timer.Elapsed += On60HzTimerTick;
            timer.Start();
        }
示例#18
0
        public GLText(IGraphicsBackend graphics, IFontLoader fonts, BitmapPool pool, string text = "", int maxWidth = int.MaxValue)
        {
            _fonts           = fonts;
            _graphics        = graphics;
            this._maxWidth   = maxWidth;
            this._text       = text;
            this._bitmapPool = pool;
            _texture         = createTexture();
            _config          = new AGSTextConfig();

            drawToBitmap();
        }
示例#19
0
        public static void Init(IFontLoader fontLoader)
        {
            const string path = "Fonts/Font Awesome 5 Free-Solid-900.otf";

            var font = fontLoader.LoadFontFromPath(path, 14f, FontStyle.Regular);

            IconConfig = new AGSTextConfig(font: font, autoFit: AutoFit.NoFitting, alignment: Alignment.MiddleCenter,
                                           paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            ButtonConfig = new AGSTextConfig(font: font, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                             paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);
        }
示例#20
0
#pragma warning restore CS0067

        public GLLabelRenderer(Dictionary <string, ITexture> textures,
                               IBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes, IGraphicsFactory graphicsFactory,
                               IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IFontLoader fonts,
                               IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _bindings = new List <IComponentBinding>();
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _glUtils                     = glUtils;
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _viewport                    = viewportMatrix;
            _textureRenderer             = textureRenderer;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();
            _bgRenderer                  = new GLImageRenderer(textures,
                                                               colorBuilder, _textureRenderer, graphicsFactory, glUtils, bitmapLoader);

            _colorBuilder = colorBuilder;

            TextVisible           = true;
            TextBackgroundVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(TextBackgroundVisible))
                {
                    return;
                }
                onBoundingBoxShouldChange();
                if (e.PropertyName == nameof(Config))
                {
                    subscribeTextConfigChanges();
                }
            };
            _shouldUpdateBoundingBoxes = true;
        }
示例#21
0
        public FontManager(IIdGenerator idGenerator,
                           IStartupPropertiesCache startUpPropertiesCache,
                           IFontCollection fontCollection,
                           IFontLoader fontLoader)
        {
            _idGenerator        = idGenerator;
            _fontLoader         = fontLoader;
            _userFontCollection = fontCollection;
            _startUpProperties  = startUpPropertiesCache.User;

            LoadSystemFonts();

            _fontsForDestruction = new List <Tuple <ulong, bool> >();
        }
示例#22
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontFactory fonts, IFont defaultFont, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            _maxWidth          = maxWidth;
            _text       = text;
            _bitmapPool = pool;
            _config     = fonts.GetTextConfig(font: defaultFont);

            prepareBitmapDraw();
        }
示例#23
0
 public AGSGameFactory(IGraphicsFactory graphics, IInventoryFactory inventory, IUIFactory ui,
                       IRoomFactory room, IOutfitFactory outfit, IObjectFactory obj, IDialogFactory dialog,
                       IAudioFactory sound, IFontLoader fontFactory)
 {
     Graphics  = graphics;
     Inventory = inventory;
     UI        = ui;
     Room      = room;
     Outfit    = outfit;
     Object    = obj;
     Dialog    = dialog;
     Sound     = sound;
     Fonts     = fontFactory;
 }
示例#24
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontLoader fonts, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            this._maxWidth     = maxWidth;
            this._text         = text;
            this._bitmapPool   = pool;
            _config            = new AGSTextConfig();

            prepareBitmapDraw();
        }
示例#25
0
        public OpenFontIFonts(IFontLoader fontloader)
        {
            this._fontloader             = fontloader;
            typefaceStore                = new TypefaceStore();
            typefaceStore.FontCollection = InstalledFontCollection.GetSharedFontCollection(null);
            glyphLayout = new GlyphLayout();

            glyphLayout.ScriptLang        = Typography.OpenFont.ScriptLangs.Thai;//test conplex script
            glyphLayout.PositionTechnique = PositionTechnique.OpenFont;
            //assign fitting engine


            //
            userGlyphPlanList      = new List <GlyphPlan>();
            userCharToGlyphMapList = new List <UserCharToGlyphIndexMap>();
        }
示例#26
0
        public VxsTextPrinter(Painter painter, IFontLoader fontLoader)
        {
            StartDrawOnLeftTop = true;
            //
            this._painter    = painter;
            this._fontLoader = fontLoader;

            _glyphMeshStore = new GlyphMeshStore();
            _glyphMeshStore.FlipGlyphUpward = true;

            //
            _pxScaleEngine = new PixelScaleLayoutEngine();
            _pxScaleEngine.HintedFontStore = _glyphMeshStore;//share _glyphMeshStore with pixel-scale-layout-engine
            //
            //_glyphLayout.PxScaleLayout = _pxScaleEngine; //assign the pxscale-layout-engine to main glyphLayout engine
            this.PositionTechnique = PositionTechnique.OpenFont;
        }
示例#27
0
        public FontSystem(IFontLoader fontLoader, ITexture2DCreator textureCreator, int width, int height, int blurAmount = 0, int strokeAmount = 0, bool premultiplyAlpha = true)
        {
            if (fontLoader == null)
            {
                throw new ArgumentNullException(nameof(fontLoader));
            }

            if (textureCreator == null)
            {
                throw new ArgumentNullException(nameof(textureCreator));
            }

            _fontLoader     = fontLoader;
            _textureCreator = textureCreator;

            if (width <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(width));
            }

            if (height <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(height));
            }

            if (blurAmount < 0 || blurAmount > 20)
            {
                throw new ArgumentOutOfRangeException(nameof(blurAmount));
            }

            if (strokeAmount < 0 || strokeAmount > 20)
            {
                throw new ArgumentOutOfRangeException(nameof(strokeAmount));
            }

            if (strokeAmount != 0 && blurAmount != 0)
            {
                throw new ArgumentException("Cannot have both blur and stroke.");
            }

            BlurAmount       = blurAmount;
            StrokeAmount     = strokeAmount;
            PremultiplyAlpha = premultiplyAlpha;

            _size = new Point(width, height);
        }
示例#28
0
        public void AddFontSystem(string title, IFontLoader fontLoader)
        {
            var panel = new DesktopPanel
            {
                FontLoader = fontLoader
            };

            panel._labelHeader.Text = title;

            if (Widgets.Count > 0)
            {
                Proportions.Add(new Proportion(ProportionType.Auto));
                Widgets.Add(new VerticalSeparator());
            }

            Proportions.Add(new Proportion(ProportionType.Auto));
            Widgets.Add(panel);
            _panels.Add(panel);
        }
示例#29
0
        public AGSGameFactory(IGraphicsFactory graphics, IInventoryFactory inventory, IUIFactory ui,
                              IRoomFactory room, IOutfitFactory outfit, IObjectFactory obj, IDialogFactory dialog,
                              IAudioFactory sound, IFontLoader fontFactory, IResourceLoader resources, IShaderFactory shaders,
                              Resolver resolver)
        {
            Graphics  = graphics;
            Inventory = inventory;
            UI        = ui;
            Room      = room;
            Outfit    = outfit;
            Object    = obj;
            Dialog    = dialog;
            Sound     = sound;
            Fonts     = fontFactory;
            Resources = resources;
            TypedParameter gameFactoryParam = new TypedParameter(typeof(IGameFactory), this);

            Masks   = resolver.Container.Resolve <IMaskLoader>(gameFactoryParam);
            Shaders = shaders;
        }
        public GLBmpGlyphTextPrinter(GLCanvasPainter painter, IFontLoader fontLoader)
        {
            //create text printer for use with canvas painter
            this.painter       = painter;
            this.canvas2d      = painter.Canvas;
            GlyphPosPixelSnapX = GlyphPosPixelSnapKind.Integer;
            GlyphPosPixelSnapY = GlyphPosPixelSnapKind.Integer;

            _fontLoader = fontLoader;
            ChangeFont(painter.CurrentFont);
            this._glyphLayout.ScriptLang = painter.CurrentFont.GetOpenFontScriptLang();

            _loadedGlyphs = new GLBitmapCache <SimpleFontAtlas>(atlas =>
            {
                //create new one
                Typography.Rendering.GlyphImage totalGlyphImg = atlas.TotalGlyph;
                //load to glbmp
                GLBitmap found = new GLBitmap(totalGlyphImg.Width, totalGlyphImg.Height, totalGlyphImg.GetImageBuffer(), false);
                found.IsInvert = false;
                return(found);
            });
        }