@@ -29,6 +29,7 @@ protected override Document GetFlatDocument(string svgdata, SvgImportConfig conf
2929
3030 ctoken . ThrowIfCancellationRequested ( ) ;
3131 ( int width , int height ) = ( config . RasterWidth , config . RasterHeight ) ;
32+ using BenchmarkScope _ = new BenchmarkScope ( ) ;
3233 using MemoryFailPoint mfp = GetMemoryFailPoint ( width , height , 1 ) ;
3334 ResetProgress ( 1 ) ;
3435 Surface surface = new Surface ( width , height , SurfaceCreationFlags . DoNotZeroFillHint ) ;
@@ -64,13 +65,14 @@ protected override Document GetLayeredDocument(string svgdata, SvgImportConfig c
6465 ArgumentException . ThrowIfNullOrWhiteSpace ( svgdata ) ;
6566 ArgumentNullException . ThrowIfNull ( config ) ;
6667
68+ using BenchmarkScope _ = new BenchmarkScope ( ) ;
6769 SvgDocument svg = SvgDocument . FromSvg < SvgDocument > ( svgdata ) ;
68- using IDisposable _ = svg . UseSetRasterDimensions ( config ) ;
70+ using IDisposable _1 = svg . UseSetRasterDimensions ( config ) ;
6971
7072 List < SvgVisualElement > elements = GetSvgVisualElements ( svg , config , ctoken ) ;
7173 ctoken . ThrowIfCancellationRequested ( ) ;
7274
73- using MemoryFailPoint _1 = GetMemoryFailPoint ( config . RasterWidth , config . RasterHeight , elements . Count ) ; // We will probably need a bit more that this but that's okay.
75+ using MemoryFailPoint _2 = GetMemoryFailPoint ( config . RasterWidth , config . RasterHeight , elements . Count ) ;
7476
7577 ResetProgress ( elements . Count ) ;
7678 List < BitmapLayer > layers = [ ] ;
@@ -146,36 +148,35 @@ protected override Document GetLayeredDocument(string svgdata, SvgImportConfig c
146148
147149 public override Document GetNoPathDocument ( )
148150 {
149- string text = SR . NoPath ;
150151 IDirectWriteFactory dw = Services . Get < IDirectWriteFactory > ( ) ;
151152 IDirect2DFactory d2d = Services . Get < IDirect2DFactory > ( ) ;
152153 using ITextFormat textFormat = dw . CreateTextFormat ( "Arial" , null , FontWeight . Bold , FontStyle . Normal , FontStretch . Normal , UIScaleFactor . ConvertFontPointsToDips ( 24 ) ) ;
153- using ITextLayout textLayout = dw . CreateTextLayout ( text , textFormat ) ;
154+ using ITextLayout textLayout = dw . CreateTextLayout ( SR . NoPath , textFormat ) ;
154155 textLayout . WordWrapping = WordWrapping . NoWrap ;
155- TextMeasurement tm = textLayout . Measure ( ) ;
156- int width = ( int ) tm . Width ;
157- int height = ( int ) tm . Height ;
158- // StrokeStyleProperties ssprops = StrokeStyleProperties.Default;
159- // ssprops .LineJoin = LineJoin.Bevel;
160- // ssprops .MiterLimit = 0;
156+ TextMeasurement textMeasurement = textLayout . Measure ( ) ;
157+ int width = ( int ) textMeasurement . Width ;
158+ int height = ( int ) textMeasurement . Height ;
159+ //StrokeStyleProperties strokeStyleProperties = StrokeStyleProperties.Default;
160+ //strokeStyleProperties .LineJoin = LineJoin.Bevel;
161+ //strokeStyleProperties .MiterLimit = 0;
161162 Surface surface = new Surface ( width , height , SurfaceCreationFlags . DoNotZeroFillHint ) ;
162163 using ( IBitmap < ColorBgra32 > shared = surface . CreateSharedBitmap ( ) )
163164 using ( IBitmap < ColorPbgra32 > premltd = shared . CreatePremultipliedAdapter ( PremultipliedAdapterOptions . UnPremultiplyOnDispose ) )
164165 using ( IDeviceContext dc = d2d . CreateBitmapDeviceContext ( premltd ) )
165166 using ( ISolidColorBrush textBrush = dc . CreateSolidColorBrush ( Color . Black ) )
166167 //using (ISolidColorBrush strokeBrush = dc.CreateSolidColorBrush(Color.Red))
167- //using (IGeometry textGeometry = d2d.CreateGeometryFromTextLayout(layout ))
168- //using (IStrokeStyle strokeStyle = d2d.CreateStrokeStyle(ssprops ))
169- //using (IGeometry widenedGeometry = textGeometry.Widen(10 , strokeStyle))
168+ //using (IGeometry textGeometry = d2d.CreateGeometryFromTextLayout(textLayout ))
169+ //using (IStrokeStyle strokeStyle = d2d.CreateStrokeStyle(strokeStyleProperties ))
170+ //using (IGeometry widenedGeometry = textGeometry.Widen(1 , strokeStyle))
170171 //using (IGeometry outerStrokeGeometry = widenedGeometry.CombineWithGeometry(textGeometry, GeometryCombineMode.Exclude))
171172 using ( dc . UseTextRenderingMode ( TextRenderingMode . Default ) )
172173 using ( dc . UseTextAntialiasMode ( TextAntialiasMode . Grayscale ) )
173174 using ( dc . UseBeginDraw ( ) )
174175 {
175176 dc . Clear ( Color . LightGray ) ;
176177 dc . DrawTextLayout ( 0 , 0 , textLayout , textBrush , DrawTextOptions . EnableColorFont ) ;
177- // dc.FillGeometry(textGeometry, textBrush);
178- // dc.FillGeometry(outerStrokeGeometry, strokeBrush);
178+ //dc.FillGeometry(textGeometry, textBrush);
179+ //dc.FillGeometry(outerStrokeGeometry, strokeBrush);
179180 }
180181 return surface . CreateSingleLayerDocument ( takeOwnership : true ) ;
181182 }
0 commit comments