Given the resource

<string name="squareRoot">&#x221A;x&#x0305;</string>

And the java code

System.out.println("unicode: " + getString(R.string.squareRoot));

The output is

enter image description here

Shouldn't the overline (x0305) be on top of the 'x'? When I try to use the same string resource as text for a textView the overline does not show at all (it occupies space, I know this becasue I tried to swap the 'x' and the overline and got a blank space before the 'x')

有帮助吗?

解决方案

Yes, U+0305 COMBINING OVERLINE should cause an overline placed above the preceding character. However, there are several reasons why this may fail more or less. First, placement of combining characters requires a good rendering engine (e.g., the overline must be placed higher if the preceding character is capital X). Second, the font being used may lack U+0305. This may or may not cause a fallback font to be used, possibly a font that is not stylistically similar to the basic font. Third, U+0305 was not really designed for use as a vinculum in conjunction with a square root sign, so it may look misplaced, depending on font.

In plain text, it is usually best to avoid trying to produce “smart” square root expressions with a vinculum. Using just √x or (is x is an expression with operators) √(x) is much safer and in full conformance to the mathematics standard ISO 80000-2.

其他提示

I don't think the Android font has the glyph for U+0305. To confirm (or not) this theory you can try embedding a fond you know it's ok with your application and try using that one.

But even if the font has the glyph, the text layout engine might not be smart enough to do the right thing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top