Bitmap Fonts for Retina Display - objective-c

Right now, I have a couple fonts: HoboStd20.fnt which points to HoboStd20.png and Teen40.fnt which points to Teen40.png
However, I need retina display fonts.
How do I go about inserting these bitmap fonts into the app?
Do I need to create a font that is twice the size of the original fonts?
How should I name the fonts? Do I rename both the png and fnt file like this: HoboStd20-hd.fnt?
Thank you!

The basic routine is to design your bitmap font at either SD or HD resolution. Then re-export the same font with double or half the font size.
For example, when I design fonts using Glyph Designer (highly recommended), I first create the Retina font and save it as font-hd.fnt. Let's say this has a font size of 40 points. Next I set the font size to 20, and re-export the file as font.fnt.
In cocos2d you reference only the font.fnt file. It will automatically load the font-hd.fnt file on Retina devices.

Sounds like you're using Angelcode's BMFont to generate the fonts (are you?).
Are you using alpha-tested edges for these fonts or using a distance-field based rendering scheme?
This paper called "Alpha-Tested Magnification for Vector Textures and Special Effects" might help you get acceptable quality without having to double the size of the font/texture.
That said, if you are using BMFont (and can write shaders to unpack pixel data) - it is also possible to pack multiple pages using one bit per page or one channel per page. This + alpha tested + distance field should give you pixel-perfect quality for text.

Related

How can I render text using font files on Direct3D 11?

I've read many questions about this, but they don't satisfy what I'm trying to do. I'm trying to use a TTF file for the text's font on my application, I thought of using Direct Draw, but the tutorial from Microsoft website only explains how to use it with Direct2D. How am I supposed to load data from this file and render text for my Direct3D application using this file's font? I've also read about the AddFontResourceExA() function, but I didn't find any content of how I could use this. I'm really lost here, so any help is appreciated.
There are basically two approaches for rendering text on a Direct3D 11 Render Target / Texture.
Rendering using a 'sprite sheet'. Here you capture the font at a particular resolution and generate a texture from it. Then you use the texture to render the glyphs as textured triangles. This is very fast and inexpensive to render, but does not scale to arbitrary resolutions (you can capture the 'sprite sheet' at multiple point sizes to get some scaling) and does not work well with "CKJ" languages due to the large size of the fonts. For an example of this, see SpriteFont in the DirectX Tool Kit. This is what legacy D3DX9/D3DX10 did as well.
Rendering using vector fonts directly. Here you have some kind of library that generates triangles 'on-the-fly' from the "TrueType" vector font data. This is what Direct2D+DirectWrite is designed to do. You can use interop with Direct3D 11 surfaces, but essentially you are using DirectWrite -> Direct2D -> shared texture. Then you draw the shared texture with Direct3D as a 'sprite'. This is more complicated to setup, but results in arbitrary resolutions scaling, support for large character set fonts, and handles complex writing systems.

Why the size of file with cropped image is the same as of initial one?

I have scanned my copybook and want to crop out extra white regions with Inkscape.
To achieve this, I import initial image (PDF) to Inkscape, draw appropriate rectangle, and use Object->Clip->Set to cut out needed region. Then I resize page to drawing and save obtained page as new PDF file through File->Save a Copy.
I expected that the size of the new PDF file (with cropped image) will be less than the size of the initial PDF (with image without crop), but they are the same.
What is the reason of this and may it be worked around?
I use Inkscape 0.91 at Linux Mint 18.2.
Thank you in advance.
Because the original image is still there, fully intact and with all its contents. The cropping rectangle are just instructions to the PDF viewer to crop out those regions when rendering the image.
However in Inkscape you can bake the crop rectangles and when exporting to PDF "apply raster effects" which should actually alter the contained image(s).

Windows Phone 8.1 Runtime Text Outline

Is there a way to show text outline on a TextBlock? I am showing some text on top of map control and would like to show the text in black with white outline so it's always readable. Something like this:
Thanks for any tips
This sort of font manipulation isn't supported in Windows.UI.Xaml, but you can interop to DirectWrite to draw text with effects into a bitmap and then composite the bitmap on top of your map.
For static text you can either pre-create a bitmap or convert the font to paths as Chris W says. The Windows.UI.Xaml.Shapes.Path's Data is essentially the same as SVG's, so you can use many vector graphics programs for the converstion by saving to SVG and then copying the path data from SVG Path's d= attribute to Xaml Path's Data= attribute.
Drop shadows aren't supported in Windows.UI.Xaml without interop to Direct2D, so the fake it link won't give any advantage over DirectWrite in this environment.
The simplest way to ensure contrast would be to place the text on a partially transparent box, but that will give a different look.

VB Application icon

My application icon does not show high density version while changing folder view settings that contains my application, however my icon contains 32, 48, 64, 96, 128 pixels.
Any help please?.
You need to provide a 256x256 pixel version in your icon file.
Windows doesn't use 96x96 or 128x128 pixel icons, and the 32x32 and 48x48 pixel versions are only used when those sizes are called for in the UI. They are not scaled upwards because the result would be pixellated and horrible-looking.
The minimum icon versions that must be provided in a Windows ICO file are:
256x256, 32-bit color (PNG compressed)
48x48, 32-bit color
32x32, 32-bit color
16x16, 32-bit color
48x48, 24-bit color
32x32, 24-bit color
16x16, 24-bit color
You can include the other sizes if you want. It won't hurt anything. And there might be components in the shell or elsewhere that use those sizes. I can't remember all the rules, they're too complicated. But larger versions of the icon will always be scaled down when the exact size is not provided.
If your application needs to be accessible in "Safe Mode" or somewhere where only the lowest common denominator of video drivers will be available, I also recommend including 8-bit or 4-bit color versions of your icons. Don't spend too much time on them, though; use an icon editor that can automatically generate them, and then clean them up if necessary just so that they're recognizable. And you only need these low-bit-depth icons for the small sizes.

How to get crisp image for search result suggestion in Windows 8?

I'm using a 40 x 40 sized image as a search result suggestion image in Windows 8 search. Only advice about the image format I can find is to have correct size for it (http://msdn.microsoft.com/en-us/library/windows/apps/Hh700542.aspx: "Windows will scale or crop smaller or larger images").
However, the correctly sized image blurs annoyingly. The same thing happens whether I use jpg or png. Original image looks fine, but the result suggestion in the search charm is very ugly, being still of same size! Is Windows converting the image somehow, and how could I get the image to stay crisp?
I haven't noticed blurring with photo-like images, but this image contains clear lines and areas which are vulnerable to any scaling etc.
Update Sep 24:
Here is the test image I used when trying to figure out the problem. I also created different scale versions, but in my case the 100% version was used (that's why the "100" marking) - as I supposed because the resulting image really is 40x40. As you can see, the resulting image (right) is of same size as original (left), but blurry.
it does not happen that often but it seems the right solution in this case was simply to wait ;) I haven't done anything new regarding result suggestion images in my solution and today I realized that the images became crisp. Probably fixed by any of the windows updates.
[Took a stab at answering what seems the related question mentioned in the comments, so I'm posting here as well.]
It sounds like this could be related to automatic scaling of the images. Windows will automatically scale up/down based on pixel density, and you can help things scale well by either using vector-based images or, for bitmap images, supplying scale-specific versions.
For example, to scale an image referenced in markup as "AppLogo.jpg", you'd include these images:
AppLogo.scale-100.jpg
AppLogo.scale-140.jpg
AppLogo.scale-180.jpg
You can also use folders, e.g. "\scale-140\AppLogo.jpg".
For search result images, the 100% image is the 40x40 pixel version, 140 is 56x56, and 180 is 72x72. Just reference the image as "AppLogo.jpg" and the appropriate version will be used automatically. (You can also detect scale with DisplayProperties.ResolutionScale and manually choose an image.)
Here's a couple of articles with more examples/details:
"Guidelines for scaling to pixel density"
"Quickstart: Using file or image resources"
There's also some scaling discussion in the forums (general, not specific to search) here and here.