How to determine tab width(in pixels) for non-monospace font? - text-rendering

I'm developing a text renderer library which is similar to FreeType for my game. I don't know how to determine the tab width.
When I'm handling control characters, I found a problem, that is my text renderer is not only for monospace fonts but also for non-monospace fonts. I know that for monospace fonts, the width of the tab aligning can be 4 or 8 spaces, depending on the usage of the text renderer (AFAIK, most of the programming IDEs intend tabs to 4 spaces; and for creating tables, the software often intend tabs to 8 spaces). But for non-monospace fonts, which value should I use?

After watching lots of IDE's behavior of handling non-monospace fonts, I found the answer:
Use the width of space character ('\x20') as the unit of the tab width, and the tab width should be 4 spaces by default.
Also I gave a choice for the users to determine how to align characters for non-monospace fonts, one is to align characters normally as we see how other programs (such as Microsoft Word, Chrome, etc.) align non-monospace font text, the other one is to force aligning characters as monospace style by fix the width value of each characters, and the fixed width value were determined by scan all of the alphabets, digits and punctuations, and find a maximum value for it. And for full-width characters, I just let the width value x 2.

Related

Getting a dotted font from a regular font

I have a need to take a regular font and obtain a dotted version of it. By "dotted", I mean that the lines and curves that make up the letterforms are composed of dots or dashes MyFonts has some examples of what I mean.
Is there any way to convert an existing non-dotted font into a dotted font without having to use a font editor myself?

Vertical tmux borders dashed only when using iTerm

At my new job I'll need to use a mac, and I'm trying to use tmux with iTerm version 2.
While horizontal borders appear to be displayed with the proper ACS box-drawing characters[1], the vertical borders are dashed. This is not a problem in Terminal.app, the borders are displayed correctly. The problem appears to occur regardless of the font I select.
In all the screen shots I can find of iTerm and tmux this seems to be the case as well. Is this simply a limitation of iTerm, or is there a problem with my terminfo or locale?
[1] Tmux borders displayed as x q instead of lines?
Old post but anyway for people looking into this still. I find it best to set a different font for Non-Ascii characters and my actual font used for ASCII characters.
For reference I use Menlo for Powerline for Non-ASCII and Droid Sans Mono for my ASCII font and this sorts out the vertical line spacing without faffing around with vertical spacing etc.
The gap you see between the vertical bar characters is a combined effect the current font's design and vertical spacing. For me, I saw a marked decrease in the gaps when I switched to Courier New, but I also don't observe a difference between iTerm2 and Terminal for the same font. Decreasing the vertical spacing from the font selector can help, but may also crowd the lines together too much.
In iTerm2 I was able to get things looking near-perfect by using a larger font for non-ascii characters:
Settings:
Update: This worked for me! https://github.com/Determinant/inconsolata_for_powerline_mod
I don't think that's the solution. I have noticed the same issue. What I see is that if I make my font huge, the alphanumerics scale accordingly, but the box drawing characters dont. Not sure where the issue lies. Notice in the attached image how the alphanumerics have scaled proportionally but the line drawing characters have not. Font is Inconsolata at 14pt.
http://i.stack.imgur.com/KOipL.png

Default font size issue with Firefox

I noticed a strange behavior with the default font size option (I'm NOT speaking about the minimum font size under the advanced tab) under Firefox :
go to this page http://fr-region.xb83studio.ch/2012/lachen/ and put a default font size of 44px or higher. Can somebody explain why the second list drops under the first one ?
The texts inside have a font size specified, hence they aren't modified by the default font size feature.
At first the problem occurred with a default font size of 17 pixels and higher. I reduced the width by 3px and it now works up to 40px. But I still don't understand why this problem arises. I would really appreciate an explanation.
BTW, I'm running Firefox 12.0 under Windows 7 Professional SP1
Thanks for your ideas
René
You have two inline-block elements with width 207px and left-margin 32px each. They're in a container with width 488px (573px width div containing a section with auto width, a 55px left margin, and a 30px right margin). In your markup, there is whitespace between the </ul> for the first inline-block and the <ul> for the second one, so in the rendering there is a space between them, just like between any two characters separated by whitespace. The width of that space is the width of a space character in the container's font.
So the second list will wrap under the first one once 488px-2*(207px+32px) = 10px is smaller than the width of a space character in the container's font.
If you earlier had your inline-blocks at 210px width, then the wrapping would happen once the width of a space is more than 6px; somewhere around a 17px font size sounds about right for that for typical variable-width Western fonts.

How to draw images among rich-text with CoreText? (iOS)

I can draw rich-text with Core Text, the problem is placing images flowing with the text.
(iOS SDK 4.1)
I'm try to drawing some kind of rich-text. Problem is designer placed many icons among text. So the text what I have to draw is something like this:
Here is a word <an icon image>, and another words.
The image(<another icon>) should be placed like a glyph.
It's part of text, not an example.
<icon> are images. (This is not a code. Just an illustration.)
I can draw this by laying out all of them manually, but it's too hard keeping complex text layout behaviors. So I'm finding a way to draw this with Core Text.
I got solution.
The key of laying out non-text content is CTRunDelegate.
Core Text does not support non-text content, so you have to make blank spaces for them, and draw or place them yourself later.
A part of NSAttributedString attributed with kCTRunDelegateAttributeName will call registered callback to determine width of each glyph. This will let you make blank space for each non-text object.
However, after drawing the text with Core Text, the layout information stored with frame/line/run will invalidated. So you have to draw/place non-text contents after layout with framesetter/typesetter, but before drawing.
This link describes basic usage of CTRunDelegate:
How to use CTRunDelegate in iPad?
There is a problem with Core Text. Originally, CTRunDelegate designed to support variable width and vertical alignment via CTRunDelegateCallbacks.getAscent and CTRunDelegateCallbacks.getDescent. But vertical alignment feature doesn't work currently. This might be a bug.
I described this problem here:
Aligning multiple sized text vertical center instead of baseline with Core Text in iOS
If you have informations about this problem, please see my question at the link.
You simply set a delegate for a given CTRun and the delegate object is responsible to let know Core Text what is the CTRun ascent space, descent space and width.
When Core Text "reaches" a CTRun which has a CTRunDelegate it asks the delegate - how much width should I leave for this chunk of data, how high should it be? This way you build a hole in the text - then you draw your image in that very spot.
Here is a blog about Core Text.It has the answer for you .
How To Create a Simple Magazine App with Core Text

BIRT -line spacing in report design

I wonder how to define the line spacing in a multi-line lable or text item for pdf output. While increasing the line height within a style works fine, decreasing the height to reduce line spacing doesn't seem to work.
Any suggestions on how to reduce the line pitch?
Thanks
Try removing top and bottom padding. I don't know about labels and text items, and maybe it's not the same, but I had a similar problem in a table with 8pt font in the details. It would look fine in HTML, but in PDF the space between the lines would be huge.
A good trick is to set background colors on the item and the surrounding cell and whatever other elements you have and you'll be able to see which element steals the space.
Then tweak the paddings, line height and font size to reduce the extra space as much as possible. Use the 'Advanced' properties panel (or preferably stylesheets), as line height is not available in 'General' for some elements.
I managed to get my table looking great doing this if I removed ALL top and bottom padding (from row, cell and data element), used a row line height of 10pt and a font size of 8pt.
There seems to be a bug that causes the actual text inside the data element to be somehow padded at the top no matter what in PDF. If you color the data element background and then select the text in the report, you'll see that the text is set too low on the element, overflowing a little at the bottom. Thats the reason 8pt font and 8pt line height wouldn't work for me, it would cut off the bottom of the text.

Resources