5

I suspect that this can't be done, but I'm asking just to be sure.

I'd like to force a single character in a <span> to have a specific width and height: 1em.

Ideally the character would be stretched to 1em if it is not already fixed-width.

This must support any character, including rare Unicode glyphs, so I cannot just set the font to Courier.

Finally, this should be accomplished with only CSS, and be simple and lightweight. E.g. a complex solution which includes a div within a table containing a one-pixel image (just to display this single character) is not OK.

I can't remember any property which does this, and attempts to Google have just returned a lot of "fixed width layouts" and nothing about single characters.

If there is no simple solution, but there is a complex one, I won't use it, but I'd be curious to hear it anyway.

4

2 回答 2

5

您可以使用@font-face包含具有良好 unicode 支持的固定宽度字体。DejaVu 系列具有出色的unicode 支持和单声道变体,应该可以很好地做到这一点。你可以使用FontSquirrel 的@font-face生成器来创建你需要的文件。

于 2011-03-10T15:37:44.660 回答
3

虽然我喜欢 Yijiang 的回答,但基于此页面上的简短讨论和 Wikipedia's list of typefaces with good Unicode support ,我认为 GNU Unifont 可能会更好地为您服务。值得注意的是,第一页指出 DejaVu Sans Mono 遗漏了一些字形,根据您的应用程序,这些字形可能相当常见。

于 2011-03-10T15:41:32.843 回答