高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】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
|