FreeTypeFontGenerator for GWT - gwt

I'm using Libgdx to write an Android and HTML5 app. I have found out that FreeTypeFontGenerator doesn't work for a GWT application and truetype is deprecated. What shall I use if I want to use fonts in a GWT application?

You use BitmapFont just like you do in any LibGDX application, it is the standard mechanism to support fonts in LibGDX. FreeTypeFontGenerator is an extension that doesn't work for GWT because it features native code. If you need to pre-generate some new font files of different sizes and types you can use Hiero or my favorite BMFont.

There might be some better way, but if you can't find any, you can prerender the font in a few sizes with the Hiero tool built into the gdx-tools project, and choose the most fitting one at runtime. Hiero generates a .png and a file describing the characters in that image which you can simply load, e.g.:
BitmapFont font = new BitmapFont(Gdx.files.internal("data/font/font"+sizeNum+".fnt"));

Related

What to download to use MDC Web offline in a PWA?

I want to use MDC Web (https://material-components.github.io/material-components-web-catalog/#/) in a PWA offline.
What am I supposed to download? Where is the official documentation for that?
You can either follow the getting started guide to generate your own javascript and css files (So you can customise colour, shape etc) here. (This is the recommended way)
Or you can just download and copy the CDN JS & CSS files here (JS) and here (CSS)
The CDN versions only use the default colour and shape and you cant change it that much.

Dynamic Version Numbering in a Default.png

I have a Default.png which includes a version number on it. Every time I update my app, I have to change it both in the lite and full version's default.png and default#2x.png. Hassle, no?
I'm pretty sure I've been going about this the wrong way. What should I do instead? (I would like to show a version number on launch, not just nix it altogether.)
Compile-Time Image Compositing
If your logo doesn't need to change other than the version number, then you can use your graphics library of choice at compile-time to refactor the png. Pseudo code below:
Pseudo-Code:
UpdateLogo(String logoName, String version)
{
WidgetImage MyLogo(logoName + ".png");
MyLogo.DrawText(800, 650, version);
MyLogo.Write(logoName + "Final.png");
}
UpdateLogo("Logo.png", "Version 1.0.0");
Compile that program and keep it around as a custom build tool. Then whenever you need to build your application you can compile Logo.png into LogoFinal.png. If you need help using XCode or other tools to generate image files I suggest you search for image manipulation tools separately from "dynamic versioning".
Ideally your version string will use constants defined in an easily-editable table or controlled by your build system. At the very least it will save you from opening up Photoshop every time you need to build your app.
For Display in a Running Application
You should be using a font to draw the version number on top of the logo. Then you can just include a resource file that is text-based and can be easily updated by automated tools for each build.
Sources
Can you create custom build rules for XCode based on file type?
Apple's Human Interface Guidelines say that the Default.png shouldn't be used as a splash screen; it should represent all of the UI controls the application will show, but without any localizable text or content. (Think of how the the built-in apps like iPod and Contacts behave.)
If you're doing it for a client and they demand it, you can always use the "But the app store might reject it for violating their terms!" argument.
Of course, this doesn't apply if you're not submitting to the Store or if you just don't care. :)
A technical add-on for the people posting above: make sure that any png compositing you're adding to the build process runs before pngcrush executes, so that you're not replacing an optimized image with a script-generated (and likely unoptimized) one. You may also run into weird issues if you try doing it after pngcrush runs (it not displaying), anyway.

Using Images In SWT Browser Component

Whats the best way of using images in SWT Browser component. Currently i stream the images to temp folder and use their location for displaying them. Is there any better way of using these images in the SWT Browser component, particulary images from the platform plugins.
Best Regards,
Keshav
Convert them to a DataURI and insert them into the HTML directly.
http://en.wikipedia.org/wiki/Data_URI_scheme
If your plug-in is directory-based - rather than jar-based - you can use the files in the plug-in directly. The are several ways to find the file name of an resource entry of a bundle - I prefer FileLocator.toFileURL(URL) which converts an URL on the format platform:/<plugin>/<path> to a file:<filename>... exactly what you need.

Is there a way to programmatically download a web page, for offline viewing, using WebKit?

What I'd like to be able to do is download any web page, and be able to view it offline.
It seems like html WebKit views cannot be converted to PDFs (on the Mac, you could 'print' a PDF, but that isn't possible on iPhone?).
So, the only way is to save the actual resources - save the html, the step thru each image, css, js file and save it locally. Then maybe alter the urls within the code so they point to the right place...etc ...etc...
Is there a standard way to do this?
Or, is there an open source project (in any programming lang) which does this kind of thing?
There's an excellent webkit html to pdf converter appropriately called wkhtmltopdf. Given the reources available on the iphone and its toolkits, I think it'd be easy to compile a version for the i-Phone ('think' being the operative word). We've managed to use the tool in a Windows, Linux and Solaris environment with absolutely no bugs. Here's the link:
http://code.google.com/p/wkhtmltopdf/

adding text to TIFF

I need to add text string to a TIFF image. I am planning to use libTIFF for editing the TIFF image. The plan is to convert text to image using freetype2 and then somehow render the text image on to TIFF. Is this the right approach?
Any pointers on how to convert text to image? I saw the sample code of ft2 - initialising the library, creating face and then setting character sizes. But not sure what to do next? any pointers appreaciated.
One way could be using ImageMagick. They have tools for image composition and text rendering. (and many more)
Although ImageMagick is primarily used from the command line (especially in web environments) several language interfaces are available, too. Java, C, C++, ...
ImgSource is a really nice library for C/C++ on Windows, and it can do this out of the box.
http://www.smalleranimals.com/isource.htm
It's not free, but it's pretty cheap ($59)
You don't tell us which language you need to use, should it be portable or for a given platform, etc.
Using a ready to use existing graphic library, like the (big!) ImageMagick or others like libGD or DevIL might be the easiest way, lot of them have binding for lot of languages.
if youre on windows and in c++ then it's pretty easy to use gdiplus for drawing fonts. you have access to any installed font and you can save the raster out as tiff or jpeg etc as well using the one api.
of course you could also use some combo of freetype and libtiff, but you'll have to build those libs for win32. not that its hard, just more fussing around you may not want to do.