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?
Thanks in advance for taking your time.
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.
Related
I want to know how many characters I can fit in a single line, but the function window-width returns the same number regardless of the font size. Is there a workaround?
Thanks
In general there is no such thing as "how many characters I can fit in a single line" since a single line may contain characters using different fonts or different sizes, and also because of the fact that fonts can be proportional so even with a single font, the size of each char can change (and beyond that, there could be kerning issues, etc...).
I want a character that's nearly a vertical line and extends significantly below the baseline, and that's supported by (at least one of) the fonts installed by default on popular operating systems. I could use 'l' or '1' or '|', but it looks bad when all the other upside-down characters extend downwards, and this is the only one pointing up. I'd use #font-face (it's for a webpage), but it also shows up in tooltips and page titles so that's not good enough.
The ideal would of course be Latin Small Letter Turned L, but the font support is awful. Latin Small Letter Dotless J would also be acceptable, and the font support is not quite as bad, but I still don't see any of the default Windows fonts in the list.
What's my least-bad option?
(A fair suggestion would be, "Why do you need this? Maybe there are other solutions" -- and I'll figure out a plan B if I have to, but first I'd like to know if I have to. I also recognize that this is a niche question. If this is not the right place to ask it, where is?)
The best I was able to find is TURNED GREEK SMALL LETTER IOTA (U+2129) “℩”, which is present in Arial Unicode MS and Lucida Sans Unicode. The main problem with it is its small size—its height is just the x-height, roughly speaking.
Or maybe THAI CHARACTER LAKKHANGYAO (U+0E45) “ๅ”? Arial Unicode MS and MS Sans Serif.
(I suppose this is for an improved upside-down converter. Such converters can be fun, but they often suffer from the effects of mixing fonts.)
I'm looking for a font which contains a graphic character which is (essentially), the space character, inverted. I'm looking for a graphic character equivalent to the largest-possible solid-black box. The closest I have been able to find is Wingings 2 character 162, but that doesn't fill the entire available character space. When I insert two consecutive Wingdings 2 162 characters, there is still appreciable whitespace between them when displayed or printed. Does anyone know of a black-box font/character which would fill all available character space?
All characters are going to have whitespace between them, or they would be unreadable. This is called "kerning". You can adjust the kerning and line-height in whatever program you are using to send the malicious fax, if you want to be sure to use the maximum amount of toner per page.
Have you considered creating your own font using a software package like this or like this? You could edit the space character to be a solid black square. But as Chris McCall mentioned, you may still have space between characters of any size due to kerning applied by the layout engine that draws the fonts.
You other option is to owner draw your own text and programmatically replacing spaces with black boxes. You would have complete control over kerning and everything else.
I don't know if this is exactly what you were looking for, but...
I was looking for the same thing, since I wanted to create a "textbox" when I wanted to write text using the spritefont, but I never knew how long the total string was going to be, so I wanted something that I could "write" in the same location right before the string with a contrasting color which could be expected to be as long as the string it needed to encompass. That being the case, try:
Webdings - character 103.
I tried lining them up and there wasn't even any space in between. Perfect.
I'm using FreeType2 for font rendering, and I need to get a global bounding box for all fonts, so I can align them in a nice grid. I call FT_Set_Char_Size followed by extracting the global bounds using
int pixels_x = ::FT_MulFix((face->bbox.xMax - face->bbox.xMin), face->size->metrics.x_scale );
int pixels_y = ::FT_MulFix((face->bbox.yMax - face->bbOx.yMin), face->size->metrics.y_scale );
return Size (pixels_x / 64, pixels_y / 64);
which works, but it's quite a bit too large. I also tried to compute using doubles (as described in the FreeType2 tutorial), but the results are practically the same. Even using just face->bbox.xMax results in bounding boxes which are too wide. Am I doing the right thing, or is there simply some huge glyph in my font (Arial.ttf in this case?) Any way to check which glyph is supposedly that big?
Why not calculate the min/max from the characters that you are using in the string that you want to align? Just loop through the characters and store the maximum and minimum from the characters that you are using. You can store these values after you rendered them so you don't need to look it up every time you render the glyphs.
I have a similar problem using freetype to render a bunch of text elements that will appear in a grid. Not all of the text elements are the same size, and I need to prerender them before I know where they would be laid out. The different sizes were the biggest problem when the heights changed, such as for letters with descending portions (like "j" or "Q").
I ended up using the height that is on the face (kind of like you did with the bbox). But like you mentioned, that value was much to big. It's supposed to be the baseline to baseline distance, but it appeared to be about twice that distance. So, I took the easy way out and divided the reported height by 2 and used that as a general height value. Most likely, the height is too big because there are some characters in the font that go way high or way low.
I suppose a better way might be to loop through all the characters expected to be used, get their glyph metrics and store the largest height found. But that doesn't seem all that robust either.
Your code is right.
It's not too large.
Because there are so many special symbols that is vary large than ascii charater. . view special big symbol
it's easy to traverse all unicode charcode, to find those large symbol.
if you only need ascii, my hack method is
FT_MulFix(face_->units_per_EM, face_->size->metrics.x_scale ) >> 6
FT_MulFix(face_->units_per_EM, face_->size->metrics.y_scale ) >> 6
Sorry if this isn't the right overflow for this question. I need a unicode character that is as long as ⎢ (23A2, LEFT SQUARE BRACKET EXTENSION) but lines up horizontally with ⎮ (23AE, INTEGRAL EXTENSION). Is there such a character?
Take a look at shapecatcher. If you draw a straight line, it shows plenty of different codepoints resembling |.
As already pointed out, exact placement and size may depend on the font, but if you know that the font is going to be a specific one (because you supply it), you could still find the character you're looking for.
It turns out this does depend on the font. If I use DejaVu Sans Mono, INTEGRAL EXTENSION is as long as I want it to be. This font appears to be almost exactly the same as the font I was using, Menlo, except for some small differences with some characters (including this one).