.NET

Reply
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 1 of 7 (738 Views)

Regular Font Style vs Blank/No Font Style.

738 Views, 6 Replies
11-08-2012 07:48 AM

Hi,

 

The attached drawing has two bits of text that are identical except from the font style.

They look different.

Is someone able to explain the difference between 'Regular' and no font style.

 

How do I acheive the 'blank' font style instead of Regular?

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 7 (725 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-08-2012 10:36 AM in reply to: SRSDS

On the quick glance one textstyle is uses "romans.shx" font

and another one "romans__.ttf" but in the textstyle editor

you can see only "romans.shx" for both styles

I have also same problem with creating styles in lisp, where

I added fontname without extension like "romans",

better yet to use it with extension,

sorry I can't explain more at the moment

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Mentor
khoa.ho
Posts: 220
Registered: ‎09-15-2011
Message 3 of 7 (721 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-08-2012 11:11 AM in reply to: SRSDS

This problem is the ambiguous name between Windows True Type font RomanS (romans__.ttf) and AutoCAD SHX font romans.shx. I hope Autodesk will fix this text style name issue in next releases.

 

AutoCAD shows RomanS true type font as the same name romans.shx of SHX font in the Text Style dialog. So if there are two TTF and SHX fonts that have the same name, the SHX font name will show on AutoCAD, and TTF font name is invisible.

 

Both two fonts look similar, except RomanS is thicker than romans.shx. This has been confusing users for years why the same font name but have different thickness. In fact, they are two different fonts (in different text styles) but wearing the same name!

 

To archive the “blank” font style instead of Regular, you should change the true type font RomanS (it’s invisible in AutoCAD) to the real SHX font by code. Without writing code, on AutoCAD Text Style dialog, we can do a trick to change the font name romans.shx (of TTF thick font) to any font and then reverse it back. It will remove the TTF font and get the correct SHX font. We also need to run REGEN command for the drawing to display updated text styles.

 

-Khoa

 

Mentor
khoa.ho
Posts: 220
Registered: ‎09-15-2011
Message 4 of 7 (708 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-08-2012 12:10 PM in reply to: khoa.ho

Here is the code to fix the RomanS font, change Windows true type font to AutoCAD SHX font:

 

[CommandMethod("FixRomansShxFont")]
public static void FixRomansShxFont()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    FixRomansShxFont(db);
    doc.Editor.Regen();
}

public static void FixRomansShxFont(Database db)
{
    using (Transaction trans = db.TransactionManager.StartTransaction())
    {
        var textStyleTable = (TextStyleTable)trans.GetObject(db.TextStyleTableId, OpenMode.ForRead);
        foreach (ObjectId textStyleId in textStyleTable)
        {
            var textStyle = (TextStyleTableRecord)trans.GetObject(textStyleId, OpenMode.ForRead);
            if (textStyle.FileName.Equals("romans__.ttf", StringComparison.CurrentCultureIgnoreCase))
            {
                textStyle.UpgradeOpen();
                textStyle.FileName = "romans.shx";
                textStyle.DowngradeOpen();
            }
        }
        trans.Commit();
    }
}

 

-Khoa

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 7 (697 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-08-2012 01:40 PM in reply to: khoa.ho

Agreed, you're correct, the following sample just for dysplay this result

 

    <CommandMethod("atx")> _
        Public Shared Sub testAddTextStyle()
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("textfill", 1)
            Using trans As Transaction = db.TransactionManager.StartTransaction()
                Try
                    Dim txtb As TextStyleTable = DirectCast(trans.GetObject(db.TextStyleTableId, OpenMode.ForWrite, False), TextStyleTable)
                    Dim txtstrec As TextStyleTableRecord = New TextStyleTableRecord()
                    txtstrec.SetPaperOrientation(True)
                    txtstrec.Name = "style1-test"
                    txtstrec.FileName = "romans__.ttf" ''2 underscore characters

                    txtstrec.ObliquingAngle = 0.0
                    txtstrec.PriorSize = 0.18
                    txtstrec.TextSize = 225.0
                    txtstrec.XScale = 0.75

                    txtb.Add(txtstrec)
                    trans.AddNewlyCreatedDBObject(txtstrec, True)
                    db.Textstyle = txtstrec.ObjectId
                    trans.TransactionManager.QueueForGraphicsFlush()

                    Dim txtstrec2 As TextStyleTableRecord = New TextStyleTableRecord()
                    txtstrec.SetPaperOrientation(True)
                    txtstrec2.Name = "style2-test"
                    txtstrec2.FileName = "romans.shx"
                    txtstrec2.ObliquingAngle = 0.0
                    txtstrec2.PriorSize = 0.18
                    txtstrec2.TextSize = 225.0
                    txtstrec2.XScale = 0.75

                    txtb.Add(txtstrec2)
                    trans.AddNewlyCreatedDBObject(txtstrec2, True)
                    db.Textstyle = txtstrec2.ObjectId
                    txtb.DowngradeOpen()

                    doc.TransactionManager.FlushGraphics()

                    trans.Commit()

                Catch ex As System.Exception
                    MessageBox.Show(ex.StackTrace & vbLf & ex.StackTrace)            
                End Try
            End Using
            Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("textfill", 0)
        End Sub

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 6 of 7 (664 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-09-2012 06:27 AM in reply to: Hallex

Thanks all so much.
I had no idea what was going on there.

Mentor
khoa.ho
Posts: 220
Registered: ‎09-15-2011
Message 7 of 7 (654 Views)

Re: Regular Font Style vs Blank/No Font Style.

11-09-2012 08:46 AM in reply to: SRSDS

I think it is a very old bug (since early AutoCAD versions until now) that Autodesk should fix. AutoCAD does not show the name of TTF (Windows True Type) font that has the same present name with SHX font. Or the SHF font does suppress the name display of TTF font. Even they have different properties on the Text Style dialog but using the same SHX name.

 

The following snapshots will present more about this issue:

 

Correct romans.shx font name with its SHX properties:

Romans SHX font.png

 

Incorrect romans.shx font name with properties of RomanS TTF font (romans__.ttf). The name in the red ellipse markup should be RomanS with the icon of TTF font.

RomanS TTF font.png

 

From those above images, RomanS TTF has lineweight and thicker than romans.shx. They look almost similar that mislead users the same font name, but in fact they are different.

 

-Khoa

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.