/// <summary> /// Gets information about the font. /// </summary> /// <param name="font">The font.</param> /// <returns>Font information.</returns> public override FontInfo GetFontInformation(FontX3D font) { var typeface = WpfFontManager.ToWpf(font.Font); var scale = font.Font.Size; return(new FontInfo(typeface.FontFamily.LineSpacing * scale, typeface.CapsHeight * scale, typeface.FontFamily.LineSpacing * scale - typeface.CapsHeight * scale, font.Font.Size)); }
/// <summary> /// Gets the raw character outline, i.e. the polygonal shape that forms a character. The polygons are in their raw form, i.e. not simplified. /// </summary> /// <param name="textChar">The text character.</param> /// <param name="font">The font. The font size of this font is ignored, because it is given in the next parameter.</param> /// <param name="fontSize">Size of the font.</param> /// <returns>The list of polygons which forms the character.</returns> protected override RawCharacterOutline GetRawCharacterOutline(char textChar, FontX font, double fontSize) { var result = new RawCharacterOutline(); Typeface typeface = WpfFontManager.ToWpf(font); FontFamily fontFamily = typeface.FontFamily; if (!typeface.TryGetGlyphTypeface(out var glyphTypeface)) { return(result); } if (!glyphTypeface.CharacterToGlyphMap.TryGetValue(textChar, out var glyphNumber)) { return(result); } // Fill in the geometry result.AdvanceWidth = fontSize * glyphTypeface.AdvanceWidths[glyphNumber]; result.LeftSideBearing = fontSize * glyphTypeface.LeftSideBearings[glyphNumber]; result.RightSideBearing = fontSize * glyphTypeface.RightSideBearings[glyphNumber]; result.FontSize = fontSize; result.LineSpacing = fontSize * fontFamily.LineSpacing; result.Baseline = fontSize * fontFamily.Baseline; var glyphGeo = (PathGeometry)glyphTypeface.GetGlyphOutline(glyphNumber, fontSize, 0); var polygonList = new List <PolygonClosedD2D>(); foreach (PathFigure figure in glyphGeo.Figures) { var polygon = PathGeometryHelper.GetGlyphPolygon(figure, true, 5, 0.001 * fontSize); polygonList.Add(polygon); } result.Outline = polygonList; return(result); }