//-------------------------------------------------------------------------------------------------- void IDrawingRenderer.EndPath() { if (_ContentBuilder.HasContent) { _ContentBuilder.EndPath(); _Content.Add(_ContentBuilder.Finish()); } _ContentBuilder = new PdfContentBuilder(); }
//-------------------------------------------------------------------------------------------------- internal bool Update(GlyphTypeface glyphTypeface, ICollection <ushort> glyphs, ref string finalFontName) { // Write font file to embed var bytes = glyphTypeface.ComputeSubset(glyphs); if (bytes?.Length > 0) { _FontStream.Add(bytes); _FontStream.Attributes["Length1"] = bytes.Length; Attributes["FontFile2"] = _FontStream; finalFontName = $"AAAAAA+{finalFontName}"; _HasFontFile = true; } Attributes["FontName"] = $"/{finalFontName}"; Attributes["FontFamily"] = $"({glyphTypeface.FamilyNames[CultureInfo.GetCultureInfo("en-us")]})"; Attributes["FontWeight"] = $"{glyphTypeface.Weight.ToOpenTypeWeight()}"; Attributes["FontStretch"] = $"/{glyphTypeface.Stretch}"; // Set attributes var flags = glyphTypeface.Symbol ? Flags.Symbolic : Flags.Nonsymbolic; if (glyphTypeface.Style == FontStyles.Italic) { flags = flags.Added(Flags.Italic); } Attributes["Flags"] = (int)flags; Attributes["FontBBox"] = new[] { // Left -(glyphs.Max(glyph => glyphTypeface.LeftSideBearings[glyph]) * 1000.0).ToRoundedInt(), // Bottom -(glyphs.Max(glyph => glyphTypeface.DistancesFromHorizontalBaselineToBlackBoxBottom[glyph]) * 1000.0).ToRoundedInt(), // Right (glyphs.Max(glyph => (glyphTypeface.AdvanceWidths[glyph] + glyphTypeface.RightSideBearings[glyph]) * 1000.0)).ToRoundedInt(), // Top (glyphTypeface.Baseline * 1000.0).ToRoundedInt() // Top }; Attributes["ItalicAngle"] = glyphTypeface.Style == FontStyles.Italic ? -75 : 0; Attributes["Ascent"] = (glyphTypeface.Baseline * 1000.0).ToRoundedInt(); Attributes["Descent"] = ((glyphTypeface.Baseline - glyphTypeface.Height) * 1000.0).ToRoundedInt(); Attributes["CapHeight"] = (glyphTypeface.CapsHeight * 1000.0).ToRoundedInt(); Attributes["XHeight"] = (glyphTypeface.XHeight * 1000.0).ToRoundedInt(); // StemV seems to be not used. // https://stackoverflow.com/questions/35485179/stemv-value-of-the-truetype-font Attributes["StemV"] = 80; Attributes["StemH"] = 80; return(true); }