示例#1
0
        public GlyphRasterizer()
        {
            _metricsContext = new FontContext();
            _contexts       = new FontContext[Environment.ProcessorCount];
            _fontDatas      = new Dictionary <FontFaceKey, FontData>();
            _exceptions     = new ConcurrentBag <Exception>();
            _freeContexts   = Channel.CreateUnbounded <FontContext>(
                new UnboundedChannelOptions
            {
                SingleReader = false,
                SingleWriter = false
            }
                );
            _rasterBatches = Channel.CreateUnbounded <RasterBatch>(
                new UnboundedChannelOptions
            {
                SingleReader = true,
                SingleWriter = true
            }
                );

            ChannelWriter <FontContext> ctxWriter = _freeContexts.Writer;

            for (int i = 0; i < _contexts.Length; i++)
            {
                var ctx = new FontContext();
                _contexts[i] = ctx;
                ctxWriter.TryWrite(ctx);
            }
        }
示例#2
0
        private static void LoadFontTest(
            int expectedWidth,
            int expectedHeight,
            int bitsPerPixel,
            string name,
            Func <FontContext, IImage> getter)
        {
            var expectedLength = expectedWidth * expectedHeight * bitsPerPixel / 8;

            var fontContext = new FontContext();
            var entry       = new Bar.Entry
            {
                Name   = name,
                Type   = Bar.EntryType.RawBitmap,
                Stream = CreateStream(expectedLength)
            };

            fontContext.Read(new Bar.Entry[] { entry });

            var image = getter(fontContext);

            Assert.NotNull(image);
            Assert.Equal(expectedWidth, image.Size.Width);
            Assert.Equal(expectedHeight, image.Size.Height);
            Assert.Equal(expectedLength, entry.Stream.Position);
        }
示例#3
0
        private void LoadFontInfo(string fileName)
        {
            var bar = _dataContent.FileOpen(fileName)
                      .Using(stream => Bar.Read(stream));

            FontContext.Read(bar);
        }
示例#4
0
 public static RenderingMessageContext ToKh2EuSystemTextContext(this FontContext fontContext) =>
 new RenderingMessageContext
 {
     Font        = fontContext.ImageSystem,
     Font2       = fontContext.ImageSystem2,
     Icon        = fontContext.ImageIcon,
     FontSpacing = fontContext.SpacingSystem,
     IconSpacing = fontContext.SpacingIcon,
     Encoder     = Encoders.InternationalSystem,
     FontWidth   = Constants.FontEuropeanSystemWidth,
     FontHeight  = Constants.FontEuropeanSystemHeight,
     TableHeight = Constants.FontTableSystemHeight,
 };
示例#5
0
 public static RenderingMessageContext ToKh2JpEventTextContext(this FontContext fontContext) =>
 new RenderingMessageContext
 {
     Font        = fontContext.ImageEvent,
     Font2       = fontContext.ImageEvent2,
     Icon        = fontContext.ImageIcon,
     FontSpacing = fontContext.SpacingEvent,
     IconSpacing = fontContext.SpacingIcon,
     Encoder     = Encoders.JapaneseEvent,
     FontWidth   = Constants.FontJapaneseEventWidth,
     FontHeight  = Constants.FontJapaneseEventHeight,
     TableHeight = Constants.FontTableEventHeight,
 };
示例#6
0
 public static RenderingMessageContext ToKh2ELEventTextContext(this FontContext fontContext) =>
 new RenderingMessageContext
 {
     Font        = fontContext.ImageEvent,
     Font2       = fontContext.ImageEvent2,
     Icon        = fontContext.ImageIcon,
     FontSpacing = fontContext.SpacingEvent,
     IconSpacing = fontContext.SpacingIcon,
     Encoder     = Encoders.GreekSystem,
     FontWidth   = Constants.FontEuropeanEventWidth,
     FontHeight  = Constants.FontEuropeanEventHeight,
     TableHeight = Constants.FontTableEventHeight,
 };
示例#7
0
        private static IEnumerable <IImageRead> ReadKh2Font(Stream inputStream)
        {
            var fontContext = new FontContext();

            fontContext.Read(Bar.Read(inputStream.SetPosition(0))
                             .Where(x => x.Type == Bar.EntryType.RawBitmap));

            return(new[]
            {
                fontContext.ImageSystem,
                fontContext.ImageSystem2,
                fontContext.ImageEvent,
                fontContext.ImageEvent2,
                fontContext.ImageIcon
            }.Where(x => x != null));
        }
示例#8
0
        public TicketDetailsForm(
            FormContext context,
            FontContext font,
            DateTimeFormatter formatter,
            Project project,
            Ticket ticket)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (font == null)
            {
                throw new ArgumentNullException(nameof(font));
            }
            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            mContext     = context;
            mFontContext = font;
            mFormatter   = formatter;
            mProject     = project;
            mTicket      = ticket;

            InitializeComponent();

            SetTitle();
            InitializeFontContext();
            InitializeComboBoxes(
                project != null ?
                new[] { project } :
                Project.GetProjects(context),
                project != null ?
                mProject.GetMilestones(context) :
                new Milestone[0]);
            InitializeTicketControls();
        }
示例#9
0
        public Kernel(IDataContent dataContent)
        {
            _dataContent = dataContent;

            FontContext     = new FontContext();
            MessageProvider = new Kh2MessageProvider();
            RegionId        = DetectRegion(dataContent);
            IsReMix         = DetectReMix(dataContent, Region);

            // Load files in the same order as KH2 does
            ObjEntries = LoadFile("00objentry.bin", stream => Objentry.Read(stream));
            // 00progress
            LoadSystem("03system.bin");
            LoadBattle("00battle.bin");
            // 00common
            // 00worldpoint
            // 07localset
            // 12soundinfo
            // 14mission

            LoadFontImage($"msg/{Language}/fontimage.bar");
            LoadFontInfo($"msg/{Language}/fontinfo.bar");
            Places = LoadFile($"msg/{Language}/place.bin", stream => Place.Read(stream));
            LoadMessage("sys");
            // 15jigsaw

            if (Language == "jp")
            {
                SystemMessageContext = FontContext.ToKh2JpSystemTextContext();
                EventMessageContext  = FontContext.ToKh2JpEventTextContext();
            }
            else
            {
                SystemMessageContext = FontContext.ToKh2EuSystemTextContext();
                EventMessageContext  = FontContext.ToKh2EuEventTextContext();
            }
        }
示例#10
0
 internal Fonts(FontContext context)
 {
     ctx = context;
 }
示例#11
0
 internal Fonts(FontContext context)
 {
     ctx = context;
 }