AcDbMtext设置宽度及换行问题
如图所示,生成后文字因标尺太短,变成了很多行,如何像右下角那样保持一行?
AcDbObjectId CCreatEnt::AddMText( const AcGePoint3d& ptInsert, const TCHAR* text,
AcDbObjectId style, double height, double width )
{
AcDbMText *pMText = new AcDbMText();
// 设置多行文字的特性
pMText->setTextStyle(style);
pMText->setContents(text);
pMText->setLocation(ptInsert);
pMText->setTextHeight(height);
pMText->setWidth(width);
pMText->setAttachment(AcDbMText::kBottomLeft);
return CCreatEnt::PostToModelSpace(pMText);
}
// 创建多行文字
ptInsert.set(0, 0, 0);
CCreatEnt::AddMText(ptInsert, TEXT("学习和使用ObjectARX需要付出你的努力."));
请问如何设置才能实现不要换行?
Acad::ErrorStatus setWidth( double unnamed); unnamedInput new text block width constraintSets width to be the maximum width allowed for any line of text. This value is used during word wrap calculations as a maximum. It is possible that none of the lines resulting from word wrap formatting will reach this width value, but no lines will ever go past it. |
若没有pMText->setWidth这句,或者pMText->setWidth设置的值为0,则不会有标尺
若设置了标尺,如何实现换行呢?为什么下图设置了标尺宽度,还是不换行呢?
edata(明经) 18:44:54
中文是按字拆分,英文按词拆分
edata(明经) 18:45:31
this is a english word
edata(明经) 18:46:01
要按单词来,分行。
edata(明经) 18:46:41
单词是空格区分,不能省略。
因为对于AAAAAAAAAAAA那个来说,是属于英文,需要用空格来分词,对于汉字则按单字自动分。所以若为纯汉字的情况下,可直接设置宽度就可以实现换行了。若含有英文,则需要自己计算何处需要添加空格来区分,当然也可以通过控制符来实现。