Font and text

Jun 20, 2011 at 10:17 PM

Hi. I played around a bit with the binary download and all seem to work fine at first. I just seemed to run into some trouble when I tried to render text. The text itself renders just fine, the font however didn't load correctly.


When i poked around the code a bit i added a fix for the font (see below), but now the text won't render at all. I tried again with the unmodded source, with the same results. 
I compared the size of the binary download and the dll compiled from source, and they're about 1kb off, so i'm guessing some of the latest changes didn't make it to the source download? I downloaded changeset 63210.

I made the following changes to get the source to run:
SvgText.cs, Ln 192: text was null and the app crashed at this point. I added some coalescing and it runs fine, but ofcourse... no text.

    p.AddString(text ?? string.Empty, font.FontFamily, 0, font.Size, new PointF(0.0f, 0.0f), StringFormat.GenericTypographic);

I made the following changes to load the font correctly:
SvgElementFactory.cs , Ln 176 - 185: The fix allows SVG attributes to be mapped to mutiple CLR properties. The code stops as soon as one of them loads correctly. Next I added some properties to SvgText.cs which accept string input and handle the conversion themselves.

foreach (PropertyDescriptor descriptor in properties) {
	try {
		descriptor.SetValue(element, descriptor.Converter.ConvertFrom(document, CultureInfo.InvariantCulture, attributeValue));
		break;
	} catch {
		Trace.TraceWarning(string.Format("Attribute '{0}' cannot be set - type '{1}' cannot convert from string '{2}'.", attributeName, descriptor.PropertyType.FullName, attributeValue));
	}
}

It's a quickfix, but it does the trick.

SvgText.cs, Ln N/A: The added properties. Please note the original properties were also preserved (in case they do work for other SVG's ??). 

[SvgAttribute("font-family")]
public virtual string FontFamilyName {
	get {
		return this._font.Name;
	}
	set {
		this._font = new System.Drawing.Font(value, this._font.SizeInPoints);
		this.IsPathDirty = true;
	}
}

[SvgAttribute("font")]
public virtual string FontName {
	get {
		return this._font.Name;
	}
	set {
		this._font = new System.Drawing.Font(value, this._font.SizeInPoints);
		this.IsPathDirty = true;
	}
}

There is a problem with visibility property in SvgVisualElement.cs as well. It expects a bool but is passed either "visible" or "hidden". I constructed a similar fix for this, but this is ommited since it's quite irrelevant here.

Here is a sample of the SVG I used. It comes straight from the highcharts.com demo (not affiliated).

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="962" height="410"><defs><clipPath id="highcharts-5"><rect rx="0" ry="0" fill="none" x="0" y="0" width="942" height="325" stroke-width="0.000001"></rect></clipPath></defs><rect rx="5" ry="5" fill="#FFFFFF" x="0" y="0" width="962" height="410" stroke-width="0.000001" stroke="#4572A7"></rect><text x="481" y="25" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#3e576f;font-size:16px;fill:#3e576f;" text-anchor="middle" class="highcharts-title" ><tspan x="481">Daily visits at www.highcharts.com</tspan></text><text x="481" y="40" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#6d869f;fill:#6d869f;" text-anchor="middle" class="highcharts-subtitle" ><tspan x="481">Source: Google Analytics</tspan></text><g class="highcharts-grid" ><path d="M 50.5 55 L 50.5 380" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 266.5 55 L 266.5 380" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 481.5 55 L 481.5 380" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 696.5 55 L 696.5 380" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 912.5 55 L 912.5 380" fill="none" stroke="#C0C0C0" stroke-width="1"></path></g><g class="highcharts-grid" ><path d="M 10 380.5 L 952 380.5" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 10 299.5 L 952 299.5" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 10 218.5 L 952 218.5" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 10 136.5 L 952 136.5" fill="none" stroke="#C0C0C0" stroke-width="1"></path><path d="M 10 55.5 L 952 55.5" fill="none" stroke="#C0C0C0" stroke-width="1"></path></g><g class="highcharts-grid" ></g><g class="highcharts-series-group" ><g class="highcharts-series" clip-path="url(#highcharts-5)" visibility="visible" transform="translate(10,55)"><path d="M 9.235294117647058 246.5125 L 40.01960784313725 123.90625 L 70.80392156862744 53.94999999999999 L 101.58823529411765 64.10624999999999 L 132.37254901960785 62.64375000000001 L 163.15686274509804 97.3375 L 193.94117647058823 230.1 L 224.72549019607843 234.8125 L 255.50980392156862 72.14999999999998 L 286.29411764705884 33.3125 L 317.078431372549 38.26875000000001 L 347.8627450980392 39.08125000000001 L 378.6470588235294 24.69999999999999 L 409.4313725490196 211.25 L 440.2156862745098 219.21249999999998 L 471 52.974999999999966 L 501.78431372549016 32.01249999999999 L 532.5686274509803 55.25 L 563.3529411764706 107.49375 L 594.1372549019608 97.90625 L 624.9215686274509 219.45625 L 655.7058823529412 228.39375 L 686.4901960784314 65.89375000000001 L 717.2745098039215 63.131249999999966 L 748.0588235294117 62.48124999999999 L 778.843137254902 31.849999999999966 L 809.6274509803922 85.71875 L 840.4117647058823 239.0375 L 871.1960784313725 234.4875 L 901.9803921568628 99.61249999999998 L 932.7647058823529 107.33124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="5" stroke-opacity="0.05" transform="translate(1,1)"></path><path d="M 9.235294117647058 246.5125 L 40.01960784313725 123.90625 L 70.80392156862744 53.94999999999999 L 101.58823529411765 64.10624999999999 L 132.37254901960785 62.64375000000001 L 163.15686274509804 97.3375 L 193.94117647058823 230.1 L 224.72549019607843 234.8125 L 255.50980392156862 72.14999999999998 L 286.29411764705884 33.3125 L 317.078431372549 38.26875000000001 L 347.8627450980392 39.08125000000001 L 378.6470588235294 24.69999999999999 L 409.4313725490196 211.25 L 440.2156862745098 219.21249999999998 L 471 52.974999999999966 L 501.78431372549016 32.01249999999999 L 532.5686274509803 55.25 L 563.3529411764706 107.49375 L 594.1372549019608 97.90625 L 624.9215686274509 219.45625 L 655.7058823529412 228.39375 L 686.4901960784314 65.89375000000001 L 717.2745098039215 63.131249999999966 L 748.0588235294117 62.48124999999999 L 778.843137254902 31.849999999999966 L 809.6274509803922 85.71875 L 840.4117647058823 239.0375 L 871.1960784313725 234.4875 L 901.9803921568628 99.61249999999998 L 932.7647058823529 107.33124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="3" stroke-opacity="0.1" transform="translate(1,1)"></path><path d="M 9.235294117647058 246.5125 L 40.01960784313725 123.90625 L 70.80392156862744 53.94999999999999 L 101.58823529411765 64.10624999999999 L 132.37254901960785 62.64375000000001 L 163.15686274509804 97.3375 L 193.94117647058823 230.1 L 224.72549019607843 234.8125 L 255.50980392156862 72.14999999999998 L 286.29411764705884 33.3125 L 317.078431372549 38.26875000000001 L 347.8627450980392 39.08125000000001 L 378.6470588235294 24.69999999999999 L 409.4313725490196 211.25 L 440.2156862745098 219.21249999999998 L 471 52.974999999999966 L 501.78431372549016 32.01249999999999 L 532.5686274509803 55.25 L 563.3529411764706 107.49375 L 594.1372549019608 97.90625 L 624.9215686274509 219.45625 L 655.7058823529412 228.39375 L 686.4901960784314 65.89375000000001 L 717.2745098039215 63.131249999999966 L 748.0588235294117 62.48124999999999 L 778.843137254902 31.849999999999966 L 809.6274509803922 85.71875 L 840.4117647058823 239.0375 L 871.1960784313725 234.4875 L 901.9803921568628 99.61249999999998 L 932.7647058823529 107.33124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="1" stroke-opacity="0.15000000000000002" transform="translate(1,1)"></path><path d="M 9.235294117647058 246.5125 L 40.01960784313725 123.90625 L 70.80392156862744 53.94999999999999 L 101.58823529411765 64.10624999999999 L 132.37254901960785 62.64375000000001 L 163.15686274509804 97.3375 L 193.94117647058823 230.1 L 224.72549019607843 234.8125 L 255.50980392156862 72.14999999999998 L 286.29411764705884 33.3125 L 317.078431372549 38.26875000000001 L 347.8627450980392 39.08125000000001 L 378.6470588235294 24.69999999999999 L 409.4313725490196 211.25 L 440.2156862745098 219.21249999999998 L 471 52.974999999999966 L 501.78431372549016 32.01249999999999 L 532.5686274509803 55.25 L 563.3529411764706 107.49375 L 594.1372549019608 97.90625 L 624.9215686274509 219.45625 L 655.7058823529412 228.39375 L 686.4901960784314 65.89375000000001 L 717.2745098039215 63.131249999999966 L 748.0588235294117 62.48124999999999 L 778.843137254902 31.849999999999966 L 809.6274509803922 85.71875 L 840.4117647058823 239.0375 L 871.1960784313725 234.4875 L 901.9803921568628 99.61249999999998 L 932.7647058823529 107.33124999999998" fill="none" stroke="#4572A7" stroke-width="4"></path><circle cx="932.7647058823529" cy="107.33124999999998" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="901.9803921568628" cy="99.61249999999998" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="871.1960784313725" cy="234.4875" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="840.4117647058823" cy="239.0375" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="809.6274509803922" cy="85.71875" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="778.843137254902" cy="31.849999999999966" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="748.0588235294117" cy="62.48124999999999" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="717.2745098039215" cy="63.131249999999966" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="686.4901960784314" cy="65.89375000000001" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="655.7058823529412" cy="228.39375" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="624.9215686274509" cy="219.45625" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="594.1372549019608" cy="97.90625" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="563.3529411764706" cy="107.49375" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="532.5686274509803" cy="55.25" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="501.78431372549016" cy="32.01249999999999" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="471" cy="52.974999999999966" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="440.2156862745098" cy="219.21249999999998" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="409.4313725490196" cy="211.25" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="378.6470588235294" cy="24.69999999999999" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="347.8627450980392" cy="39.08125000000001" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="317.078431372549" cy="38.26875000000001" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="286.29411764705884" cy="33.3125" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="255.50980392156862" cy="72.14999999999998" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="224.72549019607843" cy="234.8125" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="193.94117647058823" cy="230.1" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="163.15686274509804" cy="97.3375" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="132.37254901960785" cy="62.64375000000001" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="101.58823529411765" cy="64.10624999999999" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="70.80392156862744" cy="53.94999999999999" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="40.01960784313725" cy="123.90625" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle><circle cx="9.235294117647058" cy="246.5125" r="4" stroke="#FFFFFF" stroke-width="1" fill="#4572A7"></circle></g><g class="highcharts-series" clip-path="url(#highcharts-5)" visibility="visible" transform="translate(10,55)"><path d="M 9.235294117647058 289.81875 L 40.01960784313725 245.13125 L 70.80392156862744 206.13125 L 101.58823529411765 218.075 L 132.37254901960785 215.23125 L 163.15686274509804 221.8125 L 193.94117647058823 275.925 L 224.72549019607843 284.5375 L 255.50980392156862 215.14999999999998 L 286.29411764705884 192.8875 L 317.078431372549 199.14375 L 347.8627450980392 197.1125 L 378.6470588235294 188.5 L 409.4313725490196 269.99375 L 440.2156862745098 276.00625 L 471 205.39999999999998 L 501.78431372549016 197.4375 L 532.5686274509803 208.1625 L 563.3529411764706 232.375 L 594.1372549019608 222.95 L 624.9215686274509 277.14375 L 655.7058823529412 281.69375 L 686.4901960784314 223.19375 L 717.2745098039215 222.1375 L 748.0588235294117 223.51875 L 778.843137254902 188.17499999999998 L 809.6274509803922 228.71875 L 840.4117647058823 287.625 L 871.1960784313725 284.45625 L 901.9803921568628 233.10625 L 932.7647058823529 239.93124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="5" stroke-opacity="0.05" transform="translate(1,1)"></path><path d="M 9.235294117647058 289.81875 L 40.01960784313725 245.13125 L 70.80392156862744 206.13125 L 101.58823529411765 218.075 L 132.37254901960785 215.23125 L 163.15686274509804 221.8125 L 193.94117647058823 275.925 L 224.72549019607843 284.5375 L 255.50980392156862 215.14999999999998 L 286.29411764705884 192.8875 L 317.078431372549 199.14375 L 347.8627450980392 197.1125 L 378.6470588235294 188.5 L 409.4313725490196 269.99375 L 440.2156862745098 276.00625 L 471 205.39999999999998 L 501.78431372549016 197.4375 L 532.5686274509803 208.1625 L 563.3529411764706 232.375 L 594.1372549019608 222.95 L 624.9215686274509 277.14375 L 655.7058823529412 281.69375 L 686.4901960784314 223.19375 L 717.2745098039215 222.1375 L 748.0588235294117 223.51875 L 778.843137254902 188.17499999999998 L 809.6274509803922 228.71875 L 840.4117647058823 287.625 L 871.1960784313725 284.45625 L 901.9803921568628 233.10625 L 932.7647058823529 239.93124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="3" stroke-opacity="0.1" transform="translate(1,1)"></path><path d="M 9.235294117647058 289.81875 L 40.01960784313725 245.13125 L 70.80392156862744 206.13125 L 101.58823529411765 218.075 L 132.37254901960785 215.23125 L 163.15686274509804 221.8125 L 193.94117647058823 275.925 L 224.72549019607843 284.5375 L 255.50980392156862 215.14999999999998 L 286.29411764705884 192.8875 L 317.078431372549 199.14375 L 347.8627450980392 197.1125 L 378.6470588235294 188.5 L 409.4313725490196 269.99375 L 440.2156862745098 276.00625 L 471 205.39999999999998 L 501.78431372549016 197.4375 L 532.5686274509803 208.1625 L 563.3529411764706 232.375 L 594.1372549019608 222.95 L 624.9215686274509 277.14375 L 655.7058823529412 281.69375 L 686.4901960784314 223.19375 L 717.2745098039215 222.1375 L 748.0588235294117 223.51875 L 778.843137254902 188.17499999999998 L 809.6274509803922 228.71875 L 840.4117647058823 287.625 L 871.1960784313725 284.45625 L 901.9803921568628 233.10625 L 932.7647058823529 239.93124999999998" fill="none" stroke="rgb(0, 0, 0)" stroke-width="1" stroke-opacity="0.15000000000000002" transform="translate(1,1)"></path><path d="M 9.235294117647058 289.81875 L 40.01960784313725 245.13125 L 70.80392156862744 206.13125 L 101.58823529411765 218.075 L 132.37254901960785 215.23125 L 163.15686274509804 221.8125 L 193.94117647058823 275.925 L 224.72549019607843 284.5375 L 255.50980392156862 215.14999999999998 L 286.29411764705884 192.8875 L 317.078431372549 199.14375 L 347.8627450980392 197.1125 L 378.6470588235294 188.5 L 409.4313725490196 269.99375 L 440.2156862745098 276.00625 L 471 205.39999999999998 L 501.78431372549016 197.4375 L 532.5686274509803 208.1625 L 563.3529411764706 232.375 L 594.1372549019608 222.95 L 624.9215686274509 277.14375 L 655.7058823529412 281.69375 L 686.4901960784314 223.19375 L 717.2745098039215 222.1375 L 748.0588235294117 223.51875 L 778.843137254902 188.17499999999998 L 809.6274509803922 228.71875 L 840.4117647058823 287.625 L 871.1960784313725 284.45625 L 901.9803921568628 233.10625 L 932.7647058823529 239.93124999999998" fill="none" stroke="#AA4643" stroke-width="2"></path><path d="M 932.7647058823529 235.93124999999998 L 936.7647058823529 239.93124999999998 932.7647058823529 243.93124999999998 928.7647058823529 239.93124999999998 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 901.9803921568628 229.10625 L 905.9803921568628 233.10625 901.9803921568628 237.10625 897.9803921568628 233.10625 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 871.1960784313725 280.45625 L 875.1960784313725 284.45625 871.1960784313725 288.45625 867.1960784313725 284.45625 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 840.4117647058823 283.625 L 844.4117647058823 287.625 840.4117647058823 291.625 836.4117647058823 287.625 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 809.6274509803922 224.71875 L 813.6274509803922 228.71875 809.6274509803922 232.71875 805.6274509803922 228.71875 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 778.843137254902 184.17499999999998 L 782.843137254902 188.17499999999998 778.843137254902 192.17499999999998 774.843137254902 188.17499999999998 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 748.0588235294117 219.51875 L 752.0588235294117 223.51875 748.0588235294117 227.51875 744.0588235294117 223.51875 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 717.2745098039215 218.1375 L 721.2745098039215 222.1375 717.2745098039215 226.1375 713.2745098039215 222.1375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 686.4901960784314 219.19375 L 690.4901960784314 223.19375 686.4901960784314 227.19375 682.4901960784314 223.19375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 655.7058823529412 277.69375 L 659.7058823529412 281.69375 655.7058823529412 285.69375 651.7058823529412 281.69375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 624.9215686274509 273.14375 L 628.9215686274509 277.14375 624.9215686274509 281.14375 620.9215686274509 277.14375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 594.1372549019608 218.95 L 598.1372549019608 222.95 594.1372549019608 226.95 590.1372549019608 222.95 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 563.3529411764706 228.375 L 567.3529411764706 232.375 563.3529411764706 236.375 559.3529411764706 232.375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 532.5686274509803 204.1625 L 536.5686274509803 208.1625 532.5686274509803 212.1625 528.5686274509803 208.1625 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 501.78431372549016 193.4375 L 505.78431372549016 197.4375 501.78431372549016 201.4375 497.78431372549016 197.4375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 471 201.39999999999998 L 475 205.39999999999998 471 209.39999999999998 467 205.39999999999998 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 440.2156862745098 272.00625 L 444.2156862745098 276.00625 440.2156862745098 280.00625 436.2156862745098 276.00625 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 409.4313725490196 265.99375 L 413.4313725490196 269.99375 409.4313725490196 273.99375 405.4313725490196 269.99375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 378.6470588235294 184.5 L 382.6470588235294 188.5 378.6470588235294 192.5 374.6470588235294 188.5 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 347.8627450980392 193.1125 L 351.8627450980392 197.1125 347.8627450980392 201.1125 343.8627450980392 197.1125 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 317.078431372549 195.14375 L 321.078431372549 199.14375 317.078431372549 203.14375 313.078431372549 199.14375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 286.29411764705884 188.8875 L 290.29411764705884 192.8875 286.29411764705884 196.8875 282.29411764705884 192.8875 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 255.50980392156862 211.14999999999998 L 259.5098039215686 215.14999999999998 255.50980392156862 219.14999999999998 251.50980392156862 215.14999999999998 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 224.72549019607843 280.5375 L 228.72549019607843 284.5375 224.72549019607843 288.5375 220.72549019607843 284.5375 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 193.94117647058823 271.925 L 197.94117647058823 275.925 193.94117647058823 279.925 189.94117647058823 275.925 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 163.15686274509804 217.8125 L 167.15686274509804 221.8125 163.15686274509804 225.8125 159.15686274509804 221.8125 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 132.37254901960785 211.23125 L 136.37254901960785 215.23125 132.37254901960785 219.23125 128.37254901960785 215.23125 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 101.58823529411765 214.075 L 105.58823529411765 218.075 101.58823529411765 222.075 97.58823529411765 218.075 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 70.80392156862744 202.13125 L 74.80392156862744 206.13125 70.80392156862744 210.13125 66.80392156862744 206.13125 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 40.01960784313725 241.13125 L 44.01960784313725 245.13125 40.01960784313725 249.13125 36.01960784313725 245.13125 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path><path d="M 9.235294117647058 285.81875 L 13.235294117647058 289.81875 9.235294117647058 293.81875 5.235294117647058 289.81875 Z" fill="#AA4643" stroke="#FFFFFF" stroke-width="1"></path></g></g><g class="highcharts-legend" transform="translate(10,30)"><text x="30" y="18" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:#3e576f;fill:#3e576f;" ><tspan x="30">All visits</tspan></text><path d="M -21 0 L -5 0" fill="none" stroke-width="4" stroke="#4572A7" transform="translate(30,14)"></path><text x="117" y="18" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:#3e576f;fill:#3e576f;" ><tspan x="117">New visitors</tspan></text><path d="M -21 0 L -5 0" fill="none" stroke-width="2" stroke="#AA4643" transform="translate(117,14)"></path><circle cx="17" cy="14" r="4" stroke="#4572A7" fill="#4572A7"></circle><path d="M 104 10 L 108 14 104 18 100 14 Z" fill="#AA4643" stroke="#AA4643"></path></g><g class="highcharts-axis" ><text x="53.01960784313725" y="377" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="53.01960784313725">6. Sep</tspan></text><text x="268.5098039215686" y="377" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="268.5098039215686">13. Sep</tspan></text><text x="484" y="377" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="484">20. Sep</tspan></text><text x="699.4901960784314" y="377" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="699.4901960784314">27. Sep</tspan></text><text x="914.9803921568628" y="377" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="914.9803921568628">4. Oct</tspan></text></g><g class="highcharts-axis" ><text x="13" y="314.75" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="13">1,000</tspan></text><text x="13" y="233.5" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="13">2,000</tspan></text><text x="13" y="152.25" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="13">3,000</tspan></text><text x="13" y="71" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="start"><tspan x="13">4,000</tspan></text></g><g class="highcharts-axis" ><text x="949" y="314.75" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="end"><tspan x="949">1,000</tspan></text><text x="949" y="233.5" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="end"><tspan x="949">2,000</tspan></text><text x="949" y="152.25" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="end"><tspan x="949">3,000</tspan></text><text x="949" y="71" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;width:451px;color:#666;font-size:11px;line-height:14px;fill:#666;" text-anchor="end"><tspan x="949">4,000</tspan></text></g><path d="M 10 380.5 L 952 380.5" fill="none" stroke="#C0D0E0" stroke-width="1" ></path><g class="highcharts-tooltip" visibility="hidden"><rect rx="5" ry="5" fill="none" x="2" y="2" width="0" height="0" stroke-width="5" fill-opacity="0.85" stroke="rgb(0, 0, 0)" stroke-opacity="0.05" transform="translate(1,1)"></rect><rect rx="5" ry="5" fill="none" x="2" y="2" width="0" height="0" stroke-width="3" fill-opacity="0.85" stroke="rgb(0, 0, 0)" stroke-opacity="0.1" transform="translate(1,1)"></rect><rect rx="5" ry="5" fill="none" x="2" y="2" width="0" height="0" stroke-width="1" fill-opacity="0.85" stroke="rgb(0, 0, 0)" stroke-opacity="0.15000000000000002" transform="translate(1,1)"></rect><rect rx="5" ry="5" fill="rgb(255,255,255)" x="2" y="2" width="0" height="0" stroke-width="2" fill-opacity="0.85"></rect><text x="2" y="14" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;color:#333333;font-size:12px;padding:0;white-space:nowrap;fill:#333333;" ><tspan x="2"> </tspan></text></g><text x="952" y="405" style="font-family:'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:#909090;font-size:10px;fill:#909090;" text-anchor="end" ><tspan x="952">Highcharts.com</tspan></text><g class="highcharts-tracker" transform="translate(10,55)"><path d="M -0.764705882352942 246.5125 L 9.235294117647058 246.5125 L 40.01960784313725 123.90625 L 70.80392156862744 53.94999999999999 L 101.58823529411765 64.10624999999999 L 132.37254901960785 62.64375000000001 L 163.15686274509804 97.3375 L 193.94117647058823 230.1 L 224.72549019607843 234.8125 L 255.50980392156862 72.14999999999998 L 286.29411764705884 33.3125 L 317.078431372549 38.26875000000001 L 347.8627450980392 39.08125000000001 L 378.6470588235294 24.69999999999999 L 409.4313725490196 211.25 L 440.2156862745098 219.21249999999998 L 471 52.974999999999966 L 501.78431372549016 32.01249999999999 L 532.5686274509803 55.25 L 563.3529411764706 107.49375 L 594.1372549019608 97.90625 L 624.9215686274509 219.45625 L 655.7058823529412 228.39375 L 686.4901960784314 65.89375000000001 L 717.2745098039215 63.131249999999966 L 748.0588235294117 62.48124999999999 L 778.843137254902 31.849999999999966 L 809.6274509803922 85.71875 L 840.4117647058823 239.0375 L 871.1960784313725 234.4875 L 901.9803921568628 99.61249999999998 L 932.7647058823529 107.33124999999998 L 942.7647058823529 107.33124999999998" fill="none" stroke-opacity="0.000001" stroke="rgb(192,192,192)" stroke-width="24" visibility="visible" style="cursor:pointer;"></path><path d="M -0.764705882352942 289.81875 L 9.235294117647058 289.81875 L 40.01960784313725 245.13125 L 70.80392156862744 206.13125 L 101.58823529411765 218.075 L 132.37254901960785 215.23125 L 163.15686274509804 221.8125 L 193.94117647058823 275.925 L 224.72549019607843 284.5375 L 255.50980392156862 215.14999999999998 L 286.29411764705884 192.8875 L 317.078431372549 199.14375 L 347.8627450980392 197.1125 L 378.6470588235294 188.5 L 409.4313725490196 269.99375 L 440.2156862745098 276.00625 L 471 205.39999999999998 L 501.78431372549016 197.4375 L 532.5686274509803 208.1625 L 563.3529411764706 232.375 L 594.1372549019608 222.95 L 624.9215686274509 277.14375 L 655.7058823529412 281.69375 L 686.4901960784314 223.19375 L 717.2745098039215 222.1375 L 748.0588235294117 223.51875 L 778.843137254902 188.17499999999998 L 809.6274509803922 228.71875 L 840.4117647058823 287.625 L 871.1960784313725 284.45625 L 901.9803921568628 233.10625 L 932.7647058823529 239.93124999999998 L 942.7647058823529 239.93124999999998" fill="none" stroke-opacity="0.000001" stroke="rgb(192,192,192)" stroke-width="22" visibility="visible" style="cursor:pointer;"></path></g></svg>

Jun 21, 2011 at 11:13 PM

I ended up using the binary download together with a helper class which sanitizes the input svg using Regex before passing it to the rendering engine. It works fine for my purposes.

public static class SvgCleaner {
	private static Regex _fontExp = new Regex(@"font-family:(?<v>[^"";]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
	private static Regex _visExp = new Regex(@"visibility=\""(?<v>[^\""]+?)\""", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
	
	public static string Clean(string svg) {
		if (string.IsNullOrEmpty(svg))
			return svg;
		svg = _fontExp.Replace(svg, delegate(Match m) {
			Font f = new Font(m.Groups["v"].Value, 1.0f);
			return string.Format("font-family:{0}", f.Name);
		});
		svg = _visExp.Replace(svg, delegate(Match m) {
			return string.Format("visibility=\"{0}\"", (m.Groups["v"].Value == "visible"));
		});            
		return svg;
	}

}

I also messed around a bit with librsvg (through GtkSharp). It was a real pain to get everything set up and get all the right dlls in the right place.
The results for the graphics are great, nice rendering, blazing performance, but it (or rather libpango) can't handle the the text-anchor attribute properly, which pretty much renders it useless for my purposes.
If anyone else is having trouble using librsvg just pm me, i can probably give you some pointers.

Nov 26, 2013 at 7:27 AM
Thanks a lot. SvgCleaner method helped me a lot. This needs to be fixed in Svg converter as well.