|
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
|
|
|
|
|
Well, depends on whether you want the truth or the answer you want.
But your question reminded me of this[^]
A small warning though, it's politically incorrect on several levels. So if you're sensitive, don't click.
|
|
|
|
|
In answer to your question, yes I can solve this.
|
|
|
|