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); } }
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); }
private void LoadFontInfo(string fileName) { var bar = _dataContent.FileOpen(fileName) .Using(stream => Bar.Read(stream)); FontContext.Read(bar); }
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, };
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, };
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, };
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)); }
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(); }
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(); } }
internal Fonts(FontContext context) { ctx = context; }