|
Thanks! I'll give it a look. Right now I'm trying to figure out why my vertical spacing isn't working right. meh
Real programmers use butterflies
|
|
|
|
|
Memories of type setting. you make me feel seriously old here.
The first problem is that there really is no bounding rectangle in old fashioned type setting. Well there is of sorts, but I don't know anything about True Type so you need to fill in the gaps for me.
Anyway, there are plenty of lines.
First you have the base line which is what it sounds like, all letters without descenders stand on the baseline.
Above that you have the mean line. A small 'x' with serifs stand between the baseline and the mean line and the distance between them is the x-height.
Above the mean line is the cap line. A capital 'X' with serifs stand between the baseline and the cap line and the distance between those is the cap-height.
The problem here is that not all letters end with serifs at the top, many letters are pointy and ends in an 'Apex' instead, which is slightly above the cap line. This is called the ascender line.
Ascender is the name for that bar that's pointing upwards from letters like 'b' and 'd' for example
But this isn't all of course, capital letters with diacritics such as 'É' reaches the Ascent line. This is probably the top of the "box".
Below the base line you have the descender line and the descent line following the same principles as cap and ascender lines (there are no diacritics below the letters that I'm aware of). The descent line should be the bottom of the "box".
Ok, enough of boring technicalities. Now comes speculation.
If I were to design a "true type" printing system I would put the Y=0 at the base line, since it makes most sense from a typographical point.
But computers didn't start with true type fonts, they started out with monospaced fixed fonts that didn't scale, built from a box with 8*12 pixels. With the coordinates starting at the lower left corner of that box.
Fixed fonts don't fiddle around with as many lines. There are the base, mean, and cap lines and a descender line at the bottom at most.
I suppose that when they created the true type fonts they had to keep Y=0 at roughly the same place as on fixed fonts for backwards compatibility reasons. Which would be the descender line, so when they added the descent line to the system it had to get negative coordinates to make sense.
|
|
|
|
|
In TTF, you can render to the baseline by adding the value of the font's vertical ascent property to the y value on your screen.
The bounding box thing is the trouble. I've found that non-commercial fonts vary widely in what they report as their ascents and total heights or scales and there's little I can do about that. I have provided a way to offset the rendering so that the overhangs will render to margins. That solves the issue except you need to fiddle to get things pixel perfect - just like you would with CSS. It's unfortunate but I suppose it's just par for the course due to the polarity mismatch between rendering on a screen and printing on paper.
Real programmers use butterflies
|
|
|
|
|
Do you have a reference for what properties there are on true type?
|
|
|
|
|
Sort of. More like I have some grotty public domain code for reference.
It's fine, because I figured it out. I had it right. It was the font file's metrics that were wrong. That's what you get with free fonts I guess.
Real programmers use butterflies
|
|
|
|
|
|
I know but it reads like stereo instructions.
Real programmers use butterflies
|
|
|
|
|
I know right, it assumes you already know all about it.
|
|
|
|
|
My eyes kind of glaze over at documentation anyway. A line of code is worth its weight in words.
Real programmers use butterflies
|
|
|
|
|
|
Donald Knuth enters the chat.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
I love that he used to issue reward checks for $2.56 when you found errors in his works. He seems like a neat guy. I'd love to have dinner with him and pick his brain, you know?
Real programmers use butterflies
|
|
|
|
|
Text layout, especially when rendering a font technology like TrueType, can be as complicated as you like. As you've discovered, you can have overhangs and underhangs in all four cardinal directions. Kerning (character spacing) can range from a single constant value to a function of the identity of the two characters and the font size. Some of the font technologies even include pre-rendered bitmaps for small sizes that have a better appearance than rendering the outline.
Since you are rendering text on small displays, a simple model to start would be best. You can then smarten it up as needed. From experience, I can tell you that typographical correctness doesn't work well with displays unless they are fairly large and high resolution. Lower resolution, smaller displays look nicer with simpler constant spacing, as the calculation rounding isn't nearly as apparent.
Software Zen: delete this;
|
|
|
|
|
|
|
Four people meet and make the following statements.
Person 1: One or more of us are lying.
Person 2: Two or more of us are lying.
Person 3: Three or more of us are lying.
Person 4: All of us are lying.
Which ones are lying?
|
|
|
|
|
3 & 4
"Time flies like an arrow. Fruit flies like a banana."
|
|
|
|
|
Person 4's statement is a contradiction.
This makes Person 1's statement true.
Which means Person 3 must be lying because the statement can no longer be true (two people would be telling the truth).
Which makes Person 2's statement true.
|
|
|
|
|
How many beds are in the room?
Are any of the people uncomfortable with sharing a bed with any of the others?
Are any OK with lying on the floor? Or on another type of surface?
|
|
|
|
|
4 is lying, because he if he was telling the truth, that would be a paradox.
Therefore, 1 is telling the truth - at least one is lying.
If 3 is telling the truth and so is 1 that's two telling teh truth, so 3 is lying as well.
Since 3 & 4 are lying, 2 is telling the truth.
So 1 & 2 are truthful, 3 & 4 are lying.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
The classics are the ones we remember best!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That is the answer I came up with also.
|
|
|
|
|
They all have Alzheimers so everyone and no one?
Nobody told me these people were sane anyway...
|
|
|
|
|
Are we allowed to waterboard the participants to find out
Hogan
|
|
|
|