diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index 54f79d230a60..a10bec1db7de 100755 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -207,7 +207,7 @@ def ogr_dxf_6(): gdaltest.post_reason( 'not keeping 2D text as 2D' ) return 'fail' - if feat.GetStyleString() != 'LABEL(f:"Arial",t:"Test",a:30,s:5g,p:7,c:#000000)': + if feat.GetStyleString() != 'LABEL(f:"normallatin1",t:"Test",a:30,s:5g,p:7,c:#000000)': print(feat.GetStyleString()) gdaltest.post_reason( 'got wrong style string' ) return 'fail' @@ -299,7 +299,7 @@ def ogr_dxf_9(): gdaltest.post_reason( 'Did not get expected first mtext.' ) return 'fail' - expected_style = 'LABEL(f:"Arial",t:"'+gdaltest.sample_style+'",a:45,s:0.5g,p:5,c:#000000)' + expected_style = 'LABEL(f:"normallatin1",t:"'+gdaltest.sample_style+'",a:45,s:0.5g,p:5,c:#000000)' if feat.GetStyleString() != expected_style: gdaltest.post_reason( 'Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(),expected_style) ) return 'fail' @@ -730,7 +730,7 @@ def ogr_dxf_16(): gdaltest.post_reason( 'Did not get expected first mtext.' ) return 'fail' - expected_style = 'LABEL(f:"Arial",t:"'+gdaltest.sample_style+'",a:45,s:0.5g,p:5,c:#000000)' + expected_style = 'LABEL(f:"normallatin1",t:"'+gdaltest.sample_style+'",a:45,s:0.5g,p:5,c:#000000)' if feat.GetStyleString() != expected_style: gdaltest.post_reason( 'Got unexpected style string:\n%s\ninstead of:\n%s.' % (feat.GetStyleString(),expected_style) ) return 'fail' diff --git a/gdal/ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp b/gdal/ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp index 4f7fa097e309..4c9cb1d3afae 100644 --- a/gdal/ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp +++ b/gdal/ogr/ogrsf_frmts/dxf/ogrdxflayer.cpp @@ -478,6 +478,7 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT() bool bHaveZ = false; int nAttachmentPoint = -1; CPLString osText; + CPLString osStyleName = "Arial"; while( (nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf))) > 0 ) { @@ -524,6 +525,10 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT() dfAngle = CPLAtof(szLineBuf); break; + case 7: + osStyleName = TextUnescape(szLineBuf); + break; + default: TranslateGenericProperty( poFeature, nCode, szLineBuf ); break; @@ -595,8 +600,8 @@ OGRFeature *OGRDXFLayer::TranslateMTEXT() /* -------------------------------------------------------------------- */ CPLString osStyle; char szBuffer[64]; - - osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\"",osText.c_str()); + + osStyle.Printf("LABEL(f:\"%s\",t:\"%s\"", osStyleName.c_str(), osText.c_str()); if( dfAngle != 0.0 ) { @@ -652,6 +657,7 @@ OGRFeature *OGRDXFLayer::TranslateTEXT() double dfAngle = 0.0; double dfHeight = 0.0; CPLString osText; + CPLString osStyleName = "Arial"; bool bHaveZ = false; int nAnchorPosition = 1; int nHorizontalAlignment = 0; @@ -695,6 +701,10 @@ OGRFeature *OGRDXFLayer::TranslateTEXT() nVerticalAlignment = atoi(szLineBuf); break; + case 7: + osStyleName = TextUnescape(szLineBuf); + break; + default: TranslateGenericProperty( poFeature, nCode, szLineBuf ); break; @@ -804,8 +814,8 @@ OGRFeature *OGRDXFLayer::TranslateTEXT() CPLString osStyle; char szBuffer[64]; - osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\"",osText.c_str()); - + osStyle.Printf("LABEL(f:\"%s\",t:\"%s\"", osStyleName.c_str(), osText.c_str()); + osStyle += CPLString().Printf(",p:%d", nAnchorPosition); if( dfAngle != 0.0 ) @@ -2534,4 +2544,4 @@ int OGRDXFLayer::TestCapability( const char * pszCap ) { return EQUAL(pszCap, OLCStringsAsUTF8); -} +} \ No newline at end of file