高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】error pdb-settextstyle90 with shx fon
error pdb->settextstyle() with shx font
error pdb->settextstyle() with shx font
i create text styles as per dwgdirect dbfiller.cpp example.
some styles use ttf, some use shx.
however, pdb->settextstyle() gives assert if i try to set current text style as a style that uses shx font.
pdb->settextstyle() works if i try to set current text style as a style that uses ttf font.
in other words: setting shx style as current causes exception in dwgdirect (style validator fails with style not found in the style table).
please advise if this is a bug or if i am doing something wrong.
relevant code:
code:
oddbtextstyletablerecordptr pdesttextstyle; //= null;
oddbobjectid desttextstyleid = pdesttextstyles->getat(textdef->getname().getstring());
if(desttextstyleid)
{
pdesttextstyle = desttextstyleid.safeopenobject(oddb::kforwrite);
}
else
{
pdesttextstyle = oddbtextstyletablerecord::createobject();
// from dbfiller.cpp: "name must be set before a table object is added to a table. the
// isshapefile flag must also be set (if true) before adding the object
// to the database."
pdesttextstyle->setname(textdef->getname().getstring());
if (textdef->getfontname().right(4) == _t(".shx"))
{
pdesttextstyle->setisshapefile(true);
}
// add the object to the table.
desttextstyleid = pdesttextstyles->add(pdesttextstyle);
}
assert(!pdesttextstyle.isnull());
// set the remaining properties.
if (!pdesttextstyle.isnull())
{
pdesttextstyle->settextsize(pdoc->modelunitstoworldunits(modelspace_index, textdef->getheight()));
pdesttextstyle->setxscale(textdef->getwidthfactor());
pdesttextstyle->setpriorsize(pdoc->getcurrenttextheight());
pdesttextstyle->setobliquingangle(textdef->getescapement());
pdesttextstyle->setisbackwards(textdef->getbackwards());
pdesttextstyle->setisupsidedown(textdef->getupsidedown());
pdesttextstyle->setfilename(textdef->getfontname().getstring());
if (!pdesttextstyle->isshapefile())
pdesttextstyle->setfont(textdef->getfontname().getstring(), textdef->getbold(), textdef->getitalic(), 0, 0);
// set current text style
// jh 3/4/2008 - setting shx style as current causes exception in dwgdirect (style validator fails with style not foudn in the style table)!!!
if (textdef->gethandle() == pdoc->getcurrenttextstylehandle() && !pdesttextstyle->isshapefile())
pdb->settextstyle(desttextstyleid);
hello james,
i think you needn't set this "pdesttextstyle->setisshapefile(true);". this property is used for indicate that file in style contain shapes and this style not may be set as default. shape is not usual font file and symbols may be used for example in linetype.
best regards,
sergey z.
thanks sergey
i remove pdesttextstyle->setisshapefile(true) for shx styles that are not ltypeshp.shx, gdt.shx etc.
however i have another related problem. if i save/write text styles using the code above, i get these messages when i load the drawing in autocad 2002:
substituting [simplex.shx] for [romans.shx].
substituting [simplex.shx] for [symusic.shx].
and the text using these styles is drawn using simplex.shx font.
however if i look in autocad 2002 "text styles" dialog, the styles still say they are using romans.shx and symusic.shx.
any idea why autocad is not "recognising" the text styles as using shx font?
thanks
- james
hell james,
could you attach your drawing?
best regards,
sergey z.
here are attached drawings:
f34_126.dwg is the "original" input drawing.
f34_126a.dwg and f34_126a.dxf are the drawings i save/write using dwgdirect.
they should all be dwg 2000 format.
attached files (32.9 kb, 3 views)
(6.6 kb, 1 views)
(21.1 kb, 1 views)
hello james,
use pdesttextstyle->setname() for setting sxh font to text style and use pdesttextstyle->setfont() for setting ttf font to text style.
i think you remove pdesttextstyle->setisshapefile(true); but doen't change code below
if (!pdesttextstyle->isshapefile())
pdesttextstyle->setfont(textdef->getfontname().getstring(), textdef->getbold(), textdef->getitalic(), 0, 0);
quote:
originally posted by james higgs;
however if i look in autocad 2002 "text styles" dialog, the styles still say they are using romans.shx and symusic.shx.
see more carefully "font style:" popup list is accessible ( for shx font acad make it dissable).
best regards,
sergey z.
|