About true type font

Anonymous
Anonymous

Hello,everybody.

In microstation,I know that  the true type font number will change in different dgn files, but for the one dgn file, the true type font number also changes sometimes. Because in microstation mdl program, we can only use font number to change the font of text, not by font name. If the true type font number isn't unique, the font of text won't be fixed. It's not the result we want.  What should I do?  Thanks a lot!
  • zgLee:
    The TrueType font number also changes sometimes. Because in MicroStation MDL program, we can only use font number to change the font of text, not by font name. If the TrueType font number isn't unique, the font of text won't be fixed.

    I don't know how TrueType fonts are implemented internally, but it seems unlikely that the font no. would change after MicroStation has opened a file. What evidence do you have that the font no. changes within a single DGN file? Can you provide an example?

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Jon,

    I think zgLee means it can change number from one dgn to another.

    Roy

  • Jon Summers:

           In fact, it happens when I change the font of text in one dgn file to the one true type font, the font no of the one true type font will change after the one dgn file reopened. Of course, if  the font of text doesn't change, the font no of true type font will retain the same one. The code to change the font of text from one font to one true type font is pasted as follows:

    typedef struct tagfontinfo
    {
    char fontName[32];
    ULong fontNo;
    }FONTINFO,*LP_FONTINFO;

    int GetFontNumByFontNameFormDgn(MdlFontTraverseStruct *pFontData, LP_FONTINFO fontInfo)
    {
    if(0==strcmpi(mdlFontMgr_getFontNameFromTraverse(pFontData), fontInfo->fontName))
    {
    fontInfo->fontNo = mdlFontMgr_getFontNumberFromTraverse(pFontData);
    if(mdlFontMgr_isTrueTypeFont(fontInfo->fontNo))
    {
    g_fontNo = fontInfo->fontNo;
    return SUCCESS;
    }
    }
    return SUCCESS;
    }

    void ChangeTextFont()

    {

        FONTINFO fontInfo;
       memset (&fontInfo, 0x00, sizeof (fontInfo));
       strcpy (fontInfo.fontName, "SUN");
      mdlFontMgr_traverseAvailableFonts(GetFontNumByFontNameFormDgn,&fontInfo);
      txtParams.font = g_fontNo;

      。。。。。。。。

    }

  • Dynamically Allocated Resource IDs

    zgLee:
    It happens when I change the font of text in one dgn file to the one true type font, the font no of the one TrueType font will change after the one dgn file reopened.

    There are a number of resource IDs that are dynamic: that is to say they are reallocated when you open a new DGN file. If the 'new' DGN file happens to be the same as the DGN file you opened yesterday, there is no guarantee that the internal ID will be the same.

    The only ID that I know of in MicroStation that is guaranteed to be persistent is the Element ID.

    When you open a new DGN file and need a list of fonts, levels, materials, or whatever, you should assume that the IDs will be different. In other words:

    • Create OnNewDesignFile event handler
    • When your event handler is called, rebuild your list of font IDs, level IDs, material IDs

    If you want to interrogate objects having resource IDs in referenced files, you should also build a list of IDs for each reference attachment.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Jon Summers :

    It means that the font no of the true type font possibly changes sometimes, but I find the font no of true type font in most of dgn files doen't change after the same operation, why? what's the factor of changing the font no of true type font?  How to make the font no of true type font unchangeable in the same one dgn file at any time? Or is there other methods to make the font of some text annotations retain the same true type font at any time? Thanks a lot!

  • As far as we know, Bentley gets the list of installed true type fonts each time a dgn is opened from the Windows true type list.

    As long as there is no change to the (windows) table of those fonts you will mostly receive the same number, but only if you work at the same machine. So at least, if you ever choice to work with your drawing on another machine the true type number in the windows list WILL change. And so will the number at Bentleys side. On the same machine this might happen, if any (windows) app tries to register a true type font, even if the font exist, it might change the internal table of windows and so thoseBentley receives. Therefore you will never have the chance to get a true type font number unique over the lifetime of a drawing. I would even expect a reload of the font table whenever you open the textstile manager, and maybe whenever you have the chance to choose a font (never tried to install new fonts with a running MS, but doin' so should make things clearer).

    MIchael



  • Unfortunately I don't know how v8 dealt with fonts off-hand, but I'll chime in a little explaining how it should have been done, and how V8i does it so you have something to look forward to. With the exception of RSC fonts (which have a hard-coded number embedded in the font; this is obviously also debatable), SHX and TT fonts are only granted numbers the first time an element referencing them is written to the file. The number they are granted is typically just the next available index in their respective ranges (also pretty stupid, but we can't go back on that now). Generally speaking, an application should never deal with font numbers until it is actually concerned with generating an element; additionally, in-development text API's for post-V8i will not allow you to use font numbers, only font objects, which you get by-name. I'm sure v8 code is much less ideal and I know forces you to deal with font numbers.

    This said, you should never rely on font numbers representing any particular font (except for RSC, but even still...). It's hard for me to imagine, also, that once a font number is written to the file that it would change.

  • Jeff Marker:

          I have learned a lot from your words, thanks a lot! 

  • MichaelStark:

        Thank you! So far I have known about true type font in MicroStation a lot, and I think the font number in MS is unreliable, so I have decided to give up it.

        Best regards.