¿Mostrar caracteres de ancho completo con exactamente el doble de longitud que los caracteres de ancho medio?

I am not certain whether this is the right place to ask this, but I do not know of any other sites that would fit better. And the question has something to do with programming, so:

I Am Writing a formatted txt-guide. Please take a look at this excerpt: http://mad-gaksha.homelinux.net/public/width.txt. I need to have full-width characters displayed so that they occupy exactly twice the space as half-width characters. While monospaced fonts seems to work fine with only half-width chars, most fullwidth "fixed-width" fonts I've tried didn't produce the desired result.

In firefox, this works when I set the monospace font (Edit>Preferences>Content>Advanced)to "monospace". But only for a font-size of 14. Same thing with gedit, the fixed-width font MS-Gothic, works only for font sizes 13/14.

As I find this behaviour quite strange and wouldn't want my readers to be troubled by technical details, does anyone have suggestions or give any resources or could explain what's going on here? Why does it seem so hard just to display each glyph with a fixed size?

Gracias de antemano por tomarse su tiempo.

preguntado el 27 de agosto de 11 a las 22:08

You might use HTML rather than text. That would remove the problem. And your users won't be troubled en absoluto. -

1 Respuestas

It looks like it's to do with rounding fractional pixels.

A font renderer may adjust horizontal positioning when the width of a glyph isn't a whole number of screen pixels. I believe the Cairo rendering used by gedit and Firefox on Linux doesn't do sub-pixel positioning for fonts so this may be necessary here.

In a true monospace font this doesn't matter because every glyph has the same width so receives the same treatment, but where there is a mixture of full- and half-width characters, the rounding won't be uniform unless the glyphs happen to be a whole number of pixels wide (which happens in your case at font size 14).

Note that on Windows for most small sizes, fonts like MS Gothic will be rendered using custom built-in bitmaps in the font file, instead of rendering the outlines and their metrics. This makes all glyphs necessarily a fixed number of pixels wide. However this does result in the typical old-school ‘jaggy’ rendering style.

If you are producing formatted-text files there is really nothing you can do about this. You can only hope that your target audience has Japanese monospaced fonts that are suitable and can switch to them at a particular font size.

I would agree with Clement's comment that using HTML to get the rendering you want would be more robust, modern and convenient. Using HTML for layout relieves you of having to worry about lining up characters, and allows you to get fonts that are less ugly than all that half-width-monospaced Latin.

Respondido 28 ago 11, 17:08

Is that why the fonts always look utterly atrocious on Microsoft compared to on Apple? I use Opera and often zoom to funny percentages. The fonts are smooth on Apple but horribly jaggy on Microsoft. - tchrist

@tchrist: certainly the CJK fonts on Windows have been historically horrible. Prior to ClearType, the font ‘smoothing’ algorithm was awful, and particularly broken for kanji. Even with ClearType in XP+ you had to have fonts like Meiryo that were specially designed to use rigidly horizontal strokes instead of the near-horizontal strokes which render horribly because ClearType prefers to anti-alias only along the X axis (something that typically works well for Latin letter shapes but is a disaster for CJK ideographs). - bobince

These days this is finally fija in WPF, but most apps aren't using that so we are stuck with using Meiryo or getting jagged horizontal strokes in the meantime. - bobince

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.