TextAttribute.CHAR_REPLACEMENT question

T

Ted Hopp

I've used TextAttribute.CHAR_REPLACEMENT to insert in-line graphics into
text by applying it to the Unicode character U+FFFC
(OBJECT_REPLACEMENT_CHARACTER). But all the layout, measurement, bidi
analysis, etc. seems to work the same if the underlying character is
anything else.

So my question is: when I apply the CHAR_REPLACEMENT attribute to a
character, does it matter at all what character it is? Do all JVMs behave
the same in this area?

The Java documentation isn't exactly clear. The description of
TextAttribute.CHAR_REPLACEMENT ends with the following strange sentence:
"Follows the Microsoft model: the character that this is applied to should
be ?." That seems to say that I should have been using a question mark all
along instead of U+FFFC. But isn't that contrary to the Unicode standard?

Thanks,

Ted Hopp
(e-mail address removed)
 
S

Steven Coco

Ted said:
The Java documentation isn't exactly clear. The description of
TextAttribute.CHAR_REPLACEMENT ends with the following strange sentence:
"Follows the Microsoft model: the character that this is applied to should
be ?." That seems to say that I should have been using a question mark all
along instead of U+FFFC.

Though I'm not at all familiar with TextAttribute nor performing
replacements; (!); you will see the ? character used as a replacement
for characters that can't be found in any of your installed fonts. It
may also be substituted in other instances when a character is not found
though I'm not accurate on when. Indulge me for a moment:

The question mark you're seeing could have been a substitution your web
browser had made for a character it didn't find in your fonts; but it is
also possible that it was substituted at some previous time for similar
reasons.

The documentation could be referring to some other character.

.. Steven Coco .
.........................................................................
When you're not sure; "Confess your heart" says the Lord, "and you'll be
freed."
 
T

Ted Hopp

Steven Coco said:
Though I'm not at all familiar with TextAttribute nor performing
replacements; (!); you will see the ? character used as a replacement
for characters that can't be found in any of your installed fonts. It
may also be substituted in other instances when a character is not found
though I'm not accurate on when. Indulge me for a moment:

The question mark you're seeing could have been a substitution your web
browser had made for a character it didn't find in your fonts; but it is
also possible that it was substituted at some previous time for similar
reasons.

The documentation could be referring to some other character.

You're right, but it's not a browser font issue. The source HTML for the
documentation page contains a question mark. But the comments in the Java
source contain "...\uFFFC.</TD></TR>". Maybe this is a javadoc issue, where
it generates a question mark for out-of-range characters?

In any event, it seems I've been doing it correctly all along, just by
accident. But I'd still like to know why it apparently works for any (base)
character at all.

Ted Hopp
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top