I'm looking for some insight. I've got some code, (attached below), which has been eating away at my nerves for the last 2 hours. It is designed to change the font size of a specified text style based on the current drawing scale. However, it is having problems accessing the font iso3098b.
The code works in selecting simple fonts like romans, or times new romans...
Any ideas?
public static void GT_TextStyle(string sName, string sFont,double dFontSize, double dWidthFactor)
{
//Reference the current active drawing and database
Document acDWG = Application.DocumentManager.MdiActiveDocument;
Database acDB = acDWG.Database;
//Start a new transaction with the transaction manager
using (Transaction acTrans = acDB.TransactionManager.StartTransaction())
{
//Create an instance of the TextStyleTable for comparisons
TextStyleTable acTST = acTrans.GetObject(acDB.TextStyleTableId, OpenMode.ForWrite, false) as TextStyleTable;
//If the TextStyleTable does NOT have the specified name
if (!acTST.Has(sName))
{
//Create a new TextStyleTableRecord
TextStyleTableRecord acTSTR = new TextStyleTableRecord();
//Set the name for the new TextStyle
acTSTR.Name = sName;
//Set the TextStyle Font, Not Bold, Not Italic, Characters, Pitch&Family
acTSTR.Font = new FontDescriptor(sFont, false, false, 0, 0);
//Let the user set the WidthFactor
acTSTR.XScale = dWidthFactor;
acTSTR.Annotative = AnnotativeStates.False;
//Get the Font Size Based on the current Dimension Scale
acTSTR.TextSize = Convert.ToInt32(Application.GetSystemVariable("DIMSCALE")) * dFontSize;
acTST.Add(acTSTR);
acTrans.AddNewlyCreatedDBObject(acTSTR, true);
}
//If the TextStyle does exist
else
{
//Identify the ID of the Style Name
ObjectId TSid = acTST[sName];
//Make a reference of it for ediditng
TextStyleTableRecord acTSTR = acTrans.GetObject(TSid, OpenMode.ForWrite) as TextStyleTableRecord;
//We assume that the style was set up correctly, so we are going to just update the Text Size
acTSTR.TextSize = Convert.ToInt32(Application.GetSystemVariable("DIMSCALE")) * dFontSize;
//Add the altered style record
acTST.Add(acTSTR);
//Commit the transaction
acTrans.AddNewlyCreatedDBObject(acTSTR, true);
}
//Commit the Transaction
acTrans.Commit();
//Dispose of the Transaction
acTrans.Dispose();
}
}