几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 12:29 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how do i recognize an overridden fon

how do i recognize an overridden font
how do i recognize an overridden font
hello,
does anybody know this:
in autocad, it is possible to write text using (completely or partially) a different font than the font of the style the text is based on. for example i may have the standard style defined using txt.shx but i can, if i want to, write text using arial tt font although my text would still be based on that standard style. i may even change the font more than once on different parts of one text block (mtext).
now, how may i know in odgsbaseview::text(...) method that the text i've received was actually written using a truetype and not the style's predefined font.
thanks
arno歵
the mtext in acad contains formatting characters.
for example if you have a mtext saying helloarialstringhello with style = standard (font "txt") and the "arialstring" string is set to font "arial", then the "real" string should be:
"hello{\farial|b0|i0|c0|p34;arialstring}hello"
which means that any string that is not between {} should be drawn in the style from the text style table. the exact format of the formatting characters should be somewhere in the specifications.
hope this helps...
regards
chudomir
thanks chudo,
problem is that gsbaseview (a descendant of gigeometry) does not get preformated strings in its text methods. it receives the final string, which would be stripped of even eventual %% codes.
so i wondered if i had to handle mtext on higher level (probably in draw) if i wanted to know about partial font formating.
arno歵
which version of text() method are you actually using?
as i see in the arx help:
"virtual adesk::boolean
text(
const acgepoint3d& position,
const acgevector3d& normal,
const acgevector3d& direction,
const char* pmsg,
const adesk::int32 length,
const adesk::boolean raw,
const acgitextstyle & ptextstyle) const = 0;
position input the start or insertion point for the text
normal input the normal for the plane to contain the text
direction input the direction the text will go
pmsg input the text string to display
length input length
raw input boolean informing autocad whether to interpret escape codes
ptextstyle input a acgitextstyle object describing the desired text characteristics
this method uses an acgitextstyle object to determine the font, size, etc. to use for the text.
the position, normal, and direction can be thought of as the foundation for a coordinate system that orients the text in 3d world space, where the position is the origin, the direction is the x axis, and the normal is the z axis.
a copy of the text string is used in pmsg, so the calling application is responsible for the memory of the string passed in.
a length value of -1 indicates that pmsg is null terminated. a value greater than 0 indicates the length in bytes of pmsg.
a raw value of adesk::ktrue indicates that the autocad escape codes {%%u, %%d, %%p, and %%nnn} should not be interpreted.
a return value of adesk::kfalse (that is, 0) indicates that the primitive has been successfully stored in the graphics database. a return value of adesk::ktrue indicates that the operation has been terminated and the application wants to get control back as soon as possible."
probably in this method the formatting characters will come?
i agree with you that the other way is the draw() method, in which you can check explicitly for oddbmtext and then parse its string.
regards
chudomir
chudomir:
yes, that is the function i've been using. the text comes formatted already into this function. the only information about fonts i can get is through the style. and if the style is based on an shx font it would appear like the entire text was written with the font.
so far it seems that i indeed have to handle text in draw() but i would like to avoid that. i do not know any details about what is happening between draw() and text() and hence what else i have to care about besides interpreting the formatting tags.
thanks
arno歵
use this for draw():
make a oddbobjectid member of your odgsbaseview-derived class.
then:
void yourview::draw(const odgidrawable* pdrawable)
{
if (pdrawable != 0 && !pdrawable->id().isnull()) {
m_id = pdrawable->id();
}
odgsbaseview::draw(pdrawable); // here text() will be called
}
then use the m_id in the text() function.
assert(m_id.safeopenobject()->iskindof(oddbmtext::desc()));
oddbmtextptr pmtext = m_id;
however, in such entities like oddbblockreference it is not safely to store only one member variable as the current object id;
in such cases you must manage a stack of object id-s, but in this case it should not be needed.
hope this helps.
regards
chudomir
it is a good idea. thanks for the tip. it still won't be easy to figure what text to draw as tt and what as shx (because if it is actually a bug, i am afraid i could get - in text() - a chunk of text that is supposed to be partially a tt and partially shx, so i would have to separate them and figure the exact position for each part of the string) but it might be the only way.
thanks
mtext formatting characters are parsed by dd.
if mtext contains characters of different color, size, font etc. it is rendered by several calls to text() appropriate gitext style is set for each text() call.
gitextstyle does not always have corresponding dbtext style object. it can be generated as needed for mtext rendering.
if all gitextstyles you get have the same font like simplex.shx probably the reason is that dd is unable to locate correct font files.
sergey slezkin
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】recognize feature yang686526 SolidWorks二次开发 0 2009-04-13 01:48 PM


所有的时间均为北京时间。 现在的时间是 06:36 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多