阅读:1741回复:0
[求助]为什么我的动态修改文本图元字体大小的代码不能实现?
<P>大家帮我看看,我要动态修改图层里的文本图元的字体大小,但是没有达到目标。代码如下:</P>
<P>procedure SetFontSize(lyname: string; fsize: integer);<BR>var<BR> ly : layer;<BR> i : integer;<BR> tmpFont : variant;<BR> myfont : TFont;<BR>begin<BR> myfont := TFont.Create;<BR> try<BR> ly := Map1.Layers.Item[lyname];<BR> if ly <> nil then<BR> begin<BR> for i := 1 to ly.AllFeatures.Count do<BR> begin<BR> if ly.AllFeatures.Item.type_=5 then //文本图元<BR> begin<BR> tmpFont := ly.AllFeatures.Item.Style.TextFont;<BR> olefonttofont(tmpFont,myFont);<BR> myfont.size := 6;<BR> tmpFont := fonttoolefont(myfont);<BR> ly.AllFeatures.Item.Update(true,emptyParam);<BR> end;<BR> end;<BR> end;<BR> finally<BR> myfont.Free;<BR> myfont := nil;<BR> end;<BR>end;</P> |
|