I use SDL_ttf and I render using the TTF_RenderText_Blended function. I use the HelveticaNeueLight font.
The rendered text in SDL looks ugly compared to the text in photoshop, even though it's the same font:
Clearly, the "M", the "t", the "y" and the "c" look wrong. How can I make my text look acceptable?
I think you should experiment with TTF_SetFontHinting. It can give pretty good results when accompanied by antialiasing. If you don't know what font hinting is, here's wikipedia for you.
Related
I am using Skia for one of my sample program. I have a canvas and inside this I am writing text with font_size 30, this is the code snippet.
string = "Test String";
SkString text(string);
SkPaint paint;
SkScalar textWidth;
paint.setTextSize(SkIntToScalar(font_size));
paint.getFontMetrics(&metrics);
textWidth = paint.measureText(text.c_str(), text.size());
textWidth will give the exact width of the text inside the canvas. My question is how can I get the height of the text ? Please help.
I once had to look into this myself in the past, this link here should help you, even though it is java, fonts all work on the same idea as far as I know.
I assume you will want from the ascender to the baseline, Which is just the ascent. Or you may want the whole thing from top to bottom which is the ascent and descent combined,
If you were writing on lined paper, the baseline is the same as the line you write on, anything above that is the ascent, anything below is the descent.
I dont know anything about skia, But A quick look into skia, at this link here, that there is a public member called fAscent in FontMetrics, and fDescent, Maybe you can use those.
the font size your have specified as "font_size" is the height of single line text
I am working on an embedded platform (STM32F407) with a TFT LCD as a display (480x800px) and would like to make my user interface somewhat customizable to the end user. I figured the best source of fonts would be windows compatible as their the most common.
My current implementation uses my own custom drawn font in a binary format and a descriptor table giving the character width and ascii value but having to draw my own font bit by bit is tedious.
I would like to read in a True Type Font file from an SD card and be able to use the different sized glyphs inside it but I have not seen a strait forward implementation on how to actually achieve this magic. Can somebody point me to a good c/c++ example of what I am looking for?
Even better as a way to iron out the kinks I would like to make a simple gcc command line program that will print out my input with a selected font using '#' as pixels. That way I can just worry about implementation and not any other random bugs that might pop up.
Can anybody help me out?
Perhaps you can use the Freetype library.
As duskwuff says: TTF is primarily a vector format, would need to write a renderer. Better off using an image file to define the font, or using a bitmap font format like FNT (Windows) or BDF (UNIX).
Here is my answer to my own question: AngelCode's BMFont & Useage. This makes choosing selective characters from the installed char set, mix in a font and exports an image with a map file to each character. Simple to use.
Does anyone have an idea of how to get a glow to show up on text? I thought it would be pretty easy to do so but nothing is rendering on the fiddle.
Fiddle
Thanks
It looks to me as though Raphael simply does not support text glow. Check out the first lines of the glow function:
if (this.type == "text") {
return null;
}
It might be worth your while to investigate the use of print with a Cufonized font -- it'll return a path representing the text you give it instead of a tspan, and glow can be applied to paths.
Or you could settle for creating a simple drop shadow.
I've staged both of these alternatives by way of demonstration here.
You could create a rectangle behind the text and make that glow. I think that should look just fine. Use getBBox() to find out the size of the rectangle you need.
Something like this: http://jsfiddle.net/7ZPtq/51/
Or maybe use some other primitive, e.g. line.
I'm rendering some text using pangomm, but the font that I am using doesn't have glyphs for parts of the text (in this case, there is some Japanese mixed in with English). Pango seems to render the text correctly using a fallback font.
How can I determine which font is being used as the fallback?
Actually the font selection is based on the selected Pango font backend. Mostly used (I think) is Fontconfig.
You fonts are basically always chosen by looking at the fonts Unicode coverage, meaning that Fontconfig tries to choose the font that covers the letters in the text you want to render best.
Not knowing if your problem applies to Fontconfig, I won't go into to much detail. But if so, have a look at http://www.freedesktop.org/software/fontconfig/fontconfig-user.html, especially the section on 'font matching'.
Feel free to ask again.
I'm wondering how to make a window transparent, not cutout holes or the same transparency overall.
Well, just say I want to slap a PNG image of a rose or something and have it blend nicely with stuff behind and allow stuff behind to redraw and have their changes shine through the transparent parts of the picture/window.
I could (or would like to) use something like wxWidgets or OpenGL. But rather not Qt or GTK.
I found out that it's actually pretty simple to throw up a transparent picture on the screen using wxW:
wxScreenDC dc;
wxBitmap bmp(wxT("test.png"), wxBITMAP_TYPE_PNG);
dc.DrawBitmap(bmp, 250, 100, true);
Now I has to find out how to handle updates and such, it has to be ( maybe partially redrawn ) when something beneath updates.
As it is right now it just redraws itself ontop of itself, making it become fully opacue in a while.
There was another version of wxScreenDC::DrawBitmap that took a window as an argument, maybe it's that one solves this?
How about using shaped frames?
wxBitmap m_bmp = wxBitmap(_T("redroseonwhite.png"), wxBITMAP_TYPE_PNG);
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
wxRegion region(m_bmp, *wxWHITE);
bool m_hasShape = SetShape(region);
Look *wxWidgets-2.9.0\samples\shaped* for the full example.
See wxTopLevelWindow::SetTransparent.
If the platform supports it will set the window to be translucent.
So I guess wxWidgets can do it.
If you are willing to do something other than C++, there may be other cross platform options like JavaFx and Adobe AIR.