public void TestFontGlypthReader() { var geom = FontGlyphReader.Read("NetTopologySuite", new FontFamily(GenericFontFamilies.SansSerif), FontStyle.Regular, 36, new PointF(0, 0), GeometryFactory.Default); Assert.IsNotNull(geom); Assert.IsFalse(geom.IsEmpty); Assert.IsInstanceOf(typeof(IMultiPolygon), geom); Console.WriteLine(geom.ToString()); }
public void TestFontGlypthReader() { var geom = FontGlyphReader.Read("NetTopologySuite", new WpfFontFamily("SansSerif"), WpfFontStyles.Normal, 36, new WpfPoint(0, 0), Geometries.GeometryFactory.Default); Assert.IsNotNull(geom); Assert.IsFalse(geom.IsEmpty); Assert.IsInstanceOf(typeof(IGeometryCollection), geom); Console.WriteLine(geom.ToString()); }
private static IGeometry FontGlyph(IGeometry g, String text, Font font) { var env = FunctionsUtil.GetEnvelopeOrDefault(g); var geomFact = FunctionsUtil.GetFactoryOrDefault(g); var textGeom = FontGlyphReader.Read(text, font, geomFact); var envText = textGeom.EnvelopeInternal; if (g != null) { // transform to baseline var baseText0 = new Coordinate(envText.MinX, envText.MinY); var baseText1 = new Coordinate(envText.MaxX, envText.MinY); var baseGeom0 = new Coordinate(env.MinX, env.MinY); var baseGeom1 = new Coordinate(env.MaxX, env.MinY); AffineTransformation trans = AffineTransformationFactory.CreateFromBaseLines(baseText0, baseText1, baseGeom0, baseGeom1); return(trans.Transform(textGeom)); } return(textGeom); }