如何修改默认字体呀
我在vs2008 c#环境下写了如下程序:DBText mytext = new DBText();
mytext.TextString = text; // TextString Contents
mytext.Position = Position; // location position
mytext.VerticalMode = TextVerticalMode.TextVerticalMid; //垂直对齐方式
mytext.HorizontalMode = TextHorizontalMode.TextFit; //水平对齐方式
mytext.AlignmentPoint = Position; //文本的坐标
但是不知道如何加字体样式呀,因为默认的是:Standard 我想修改成“宋体”, 但不知道如何做,请高手指点,谢谢!
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=76578&highlight=%D1%F9%CA%BD 怎么能把: TextStyle 字体修改成:“宋体”呀? http://bbs.mjtd.com/thread-82484-1-1.html 已解决了,谢谢超级版本
DBText mytext = new DBText();
mytext.TextStyle = AddTextStyle("宋体", "1", "3", 20, 20);
//建立文字样式
public static ObjectId AddTextStyle(string name, string smallfont, string bigfont, double height, double xscale)
{
Database dbH = HostApplicationServices.WorkingDatabase;
using (Transaction trans = dbH.TransactionManager.StartTransaction())
{
TextStyleTable TST = (TextStyleTable)trans.GetObject(dbH.TextStyleTableId, OpenMode.ForWrite);
ObjectId id =GetIdFromSymbolTable(TST, name);
if (id == ObjectId.Null)
{
TextStyleTableRecord TSTR = new TextStyleTableRecord();
TSTR.Name = name;
TSTR.FileName = smallfont;
TSTR.BigFontFileName = bigfont;
TSTR.TextSize = height;
TSTR.XScale = xscale;
TST.UpgradeOpen();
id = TST.Add(TSTR);
trans.AddNewlyCreatedDBObject(TSTR, true);
}
return id;
}
}
//取得符号表的Id
public static ObjectId GetIdFromSymbolTable(SymbolTable st, string key)
{
Database dbH = HostApplicationServices.WorkingDatabase;
using (Transaction trans = dbH.TransactionManager .StartTransaction ())
{
if (st.Has(key))
{
ObjectId idres = st;
if (!idres.IsErased)
return idres;
foreach (ObjectId id in st)
{
if (!id.IsErased)
{
SymbolTableRecord str = (SymbolTableRecord)trans.GetObject(id, OpenMode.ForRead);
if (str.Name == key)
return id;
}
}
}
}
return ObjectId.Null;
} 受教了。。
页:
[1]