/// <seealso cref="Serialize" /> public void Deserialize(string data, Tag format, Font.Font font = null) { // todo throw an exception if the return value will indicate unsuccessful deserialization var bytes = Encoding.ASCII.GetBytes(data); Api.hb_buffer_deserialize_glyphs(Handle, bytes, bytes.Length, out _, font?.Handle ?? IntPtr.Zero, format); }
/// <summary> /// Shapes <paramref name="buffer" /> using font turning its Unicode characters content to positioned glyphs. /// If <paramref name="features" /> is not empty, it will be used to control the features applied during /// shaping. /// If <paramref cref="shapers" /> is not empty, the specified shapers will be used in the given order, otherwise /// the default shapers list will be used. /// </summary> /// <param name="font"></param> /// <param name="buffer"></param> /// <param name="shapers"></param> /// <param name="features"></param> public static void Shape(this Buffer.Buffer buffer, Font.Font font, IEnumerable <string> shapers, params Feature[] features) { var bytes = shapers.Select(x => Encoding.ASCII.GetBytes(x)).ToArray(); Api.hb_shape_full(font.Handle, buffer.Handle, features, (uint)features.Length, bytes); }
public UIText(Font.Font font, string value, double pointScale, Vector2 position, Vector3 color) { this.font = font; this.value = value; this.pointScale = pointScale; this.Position = position; this.color = color; }
public UIButton(Font.Font font, Vector2 position, Vector2 size, string buttonText, double pointScale) { this.font = font; this.Position = position; this.size = size; this.pointScale = pointScale; this.text = buttonText; // Build the button. renderer = new TriangleStripRender(buildButton(), 2); }
/// <summary> /// Serializes buffer into a textual representation of its glyph content, useful for showing the contents /// of the buffer, for example during debugging. There are currently two supported serialization formats. /// </summary> /// <param name="start">the first item in buffer to serialize.</param> /// <param name="end"> /// thought the official manual says it's "the last item in buffer to serialize", it looks more like /// "actual running length of items to serialize" to me. /// </param> /// <param name="bufferSize">the size of unmanaged buffer for receiving the serialized string.</param> /// <param name="format">the <see cref="SerializeFormat" /> to use for formatting the output.</param> /// <param name="flags">the <see cref="SerializeFlags" /> that control what glyph properties to serialize.</param> /// <param name="font"> /// the <see cref="Font" /> used to shape this buffer, needed to read glyph names and extents. If NULL, /// and empty font will be used. /// </param> public string Serialize(uint start, uint end, uint bufferSize, Tag format, SerializeFlags flags = SerializeFlags.Default, Font.Font font = null) { var buffer = Marshal.AllocHGlobal((int)bufferSize); try { Api.hb_buffer_serialize_glyphs(Handle, start, end, buffer, bufferSize, out var consumed, font?.Handle ?? IntPtr.Zero, format, flags); return(Marshal.PtrToStringAnsi(buffer, (int)consumed)); } finally { Marshal.FreeHGlobal(buffer); } }
/// <summary> /// Shapes <paramref name="buffer" /> using font turning its Unicode characters content to positioned glyphs. /// If <paramref name="features" /> is not empty, it will be used to control the features applied during /// shaping. /// </summary> public static void Shape(this Buffer.Buffer buffer, Font.Font font, params Feature[] features) { Api.hb_shape(font.Handle, buffer.Handle, features, (uint)features.Length); }
public override Stream Render( ReportLayout report, string documentId, string designId, string title, int version, DateTimeOffset timestamp, string photoUri, string resourceUri, bool drawRules, bool drawPageBoxes, Generator generator, ITrace tracer) { AssemblyName assName = Assembly.GetExecutingAssembly().GetName(); string creator = $"Demon report generator {assName.Name} version {assName.Version.Major}.{assName.Version.Minor}.{assName.Version.Revision}"; _generator = generator; Dictionary <string, string> docInfo = new Dictionary <string, string>(); docInfo.Add("Title", title); docInfo.Add("Creator", creator); docInfo.Add("Producer", creator); docInfo.Add("CreationDate", $"D:{timestamp:yyyyMMddHHmmssZ}"); docInfo.Add("Version", $"{version}"); docInfo.Add("DocumentId", documentId); docInfo.Add("ReportDesignId", designId); // In case we're going to draw rules on at least one page, make // sure that we've got a font prepared for that _rulesFont = _generator.GetFont("Helvetica", 400, false, false, false, false); string ruleChars = "0123456789"; foreach (char c in ruleChars) { _rulesFont.MapCharacter(c); } // Lay out the content and apply page breaks _generator.TraceLayoutActivity("Measure and cut content"); List <PageLayout> pageLayouts = report.LayOut(); // Subset the fonts. First map characters actually used by the // layouts into the fonts' glyph character maps, and then create // the subsets using only those glyphs. Do this after laying out // because header and footer content isn't loaded until the layout // phase. See the note in TextLayout.LoadContent before the call // to ExpandProperties. //TODO: find a better way to handle PageNumber and PageCount so that we //can include them in the page body, and so that we can lay out the //header and footer at the same time as the body. report.MapFontCharacters(); _generator.FontCache.Subset(); Demon.PDF.Document doc = new Demon.PDF.Document(docInfo, _generator.FontCache); // Write the content to the PDF tracer.TraceLayoutActivity("Generate document"); foreach (PageLayout pageLayout in pageLayouts) { RenderPageLayout(pageLayout, doc, drawRules); } Stream file = doc.Write(); return(file); }
/// <summary> /// Realize a font from the cache /// </summary> internal Font.Font GetFont(Demon.Report.Style.Font style) { Font.Font font = GetFont(style.FamilyName, style.Weight, style.Bold, style.Italic, style.Underline, style.Strikeout); return(font); }
protected override void LoadContent() { //// other stuffs lastState = Keyboard.GetState(); currentState = DevStates.AnimatedSpriteTesting; lastMovingSpriteUpdate = TimeSpan.Zero; _spriteBatch = new SpriteBatch(GraphicsDevice); fontManager = new FontManager(GraphicsDevice); font = fontManager.GetFont("Content\\PlayfairDisplayRegular-ywLOY.ttf", 32); font2 = fontManager.GetFont("Content\\PlayfairDisplayRegular-ywLOY.ttf", 16); //// create and configure our sprite manager manager = new TextureManager(GraphicsDevice); manager.AutoTextureAtlasBalancingIntervalMilliseconds = 5000; //// register all of the textures we'll be using var animationSize = new Point(400, 450); var hullSize = new Point(288, 192); var hullSizeVector = new Vector2(hullSize.X, hullSize.Y); var tireSize = new Point(45, 45); var tireSizeVector = new Vector2(tireSize.X, tireSize.Y); var textures = new List <(string, Point?, string?)>() { ("TextureAtlasTesting\\11-6.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\beautiful-sunset-33.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\chloe4.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\gorgeous-f2-goldendoodle-puppies-5a7de534c591b.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\OIP.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\R3d398e62bb9b79f54b5c49b4e5f32925.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\Rdb919eda1b98929d3a17685a6d3d7ef8.jpg", ChooseRandomSize(), null), ("TextureAtlasTesting\\Refd96265ac3da1f5b5dc5277f1082d15.jpg", ChooseRandomSize(), null), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_1.jpg", animationSize, "woman1"), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_2.jpg", animationSize, "woman2"), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_3.jpg", animationSize, "woman3"), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_4.jpg", animationSize, "woman4"), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_5.jpg", animationSize, "woman5"), ("AnimationTesting\\woman-silhouette-walk-cycle-vector_6.jpg", animationSize, "woman6"), ("SpriteTesting\\spr_sportscar_0.png", hullSize, "static_car"), ("CompositeSpriteTesting\\spr_sportscar_0_hull.png", hullSize, "car_hull"), ("CompositeSpriteTesting\\spr_sportscar_0_tire.png", tireSize, "car_tire"), ("CompositeSpriteTesting\\spr_sportscar_0_tire_2.png", tireSize, "car_tire2"), ("CompositeSpriteTesting\\spr_sportscar_0_tire_3.png", tireSize, "car_tire3"), ("CompositeSpriteTesting\\spr_sportscar_0_tire_4.png", tireSize, "car_tire4") }; var texturesLoadInfos = new List <TextureLoadInfo>(); for (var i = 0; i < textures.Count; i++) { texturesLoadInfos.Add(new TextureLoadInfo(textures[i].Item3 ?? $"image{i}", $"Content\\{textures[i].Item1}", textures[i].Item2)); } manager.LoadTextures(texturesLoadInfos); //// create sprites // Simple Sprites sprite1 = new Sprites.SimpleSprite(manager, "static_car1", "static_car", hullSizeVector); sprite2 = new Sprites.SimpleSprite(manager, "static_car2", "static_car", hullSizeVector); // Composite Sprites var tire1Location = new Vector2(43, 92); var tire2Location = new Vector2(213, 92); compositeSprite1 = new CompositeSprite( manager, "car_1", hullSizeVector, new Sprites.SimpleSprite(manager, "hull", "car_hull", hullSizeVector), new SimpleSprite(manager, "tire1", "car_tire", tire1Location, tireSizeVector), new SimpleSprite(manager, "tire2", "car_tire", tire2Location, tireSizeVector) ); compositeSprite2 = new CompositeSprite( manager, "car_2", hullSizeVector, new Sprites.SimpleSprite(manager, "hull", "car_hull", hullSizeVector), new Sprites.Sprite(manager, "tire1", "car_tire", tire1Location, tireSizeVector), new Sprites.Sprite(manager, "tire2", "car_tire", tire2Location, tireSizeVector) ); // Composite AnimatedSprites var tire_animation = new Animation( "tire", true, new Frame[] { new Frame("t1", "car_tire", 100), new Frame("t1", "car_tire2", 100), new Frame("t1", "car_tire3", 100), new Frame("t1", "car_tire4", 100) } ); compositeAnimatedSprite1 = new CompositeSprite( manager, "a_car_1", hullSizeVector, new Sprites.SimpleSprite(manager, "hull", "car_hull", hullSizeVector), new AnimatedSprite( manager, "tire1", tire1Location, tireSizeVector, animations: new Animation(tire_animation) ), new AnimatedSprite( manager, "tire2", tire2Location, tireSizeVector, animations: new Animation(tire_animation) ) ); compositeAnimatedSprite2 = new CompositeSprite( manager, "a_car_2", hullSizeVector, new Sprites.SimpleSprite(manager, "hull", "car_hull", hullSizeVector), new AnimatedSprite( manager, "tire1", tire1Location, tireSizeVector, animations: new Animation(tire_animation) ), new AnimatedSprite( manager, "tire2", tire2Location, tireSizeVector, animations: new Animation(tire_animation) ) ); // Animated Sprites var frameTime = 75; animatedSprite1 = new AnimatedSprite( manager, "walking_women", Vector2.Zero, new Vector2(animationSize.X, animationSize.Y), animations: new Animation( "walking", true, new Frame[] { new Frame("f1", "woman1", frameTime), new Frame("f2", "woman2", frameTime), new Frame("f3", "woman3", frameTime), new Frame("f4", "woman4", frameTime), new Frame("f5", "woman5", frameTime), new Frame("f6", "woman6", frameTime) } ) ); animatedSprite2 = new AnimatedSprite( manager, "walking_women2", Vector2.Zero, new Vector2(animationSize.X, animationSize.Y), animations: new Animation( "walking", true, new Frame[] { new Frame("f1", "woman1", frameTime), new Frame("f2", "woman2", frameTime), new Frame("f3", "woman3", frameTime), new Frame("f4", "woman4", frameTime), new Frame("f5", "woman5", frameTime), new Frame("f6", "woman6", frameTime) } ) ); ChangeState(currentState, DevStates.SimpleSpriteTesting); }