Can I use otf font in codename 1? - codenameone

Most of the fonts are OTF format, especially in Asia. Can I use the OTF format font in the cn1 theme? And the size of most OTF font files is more than 20MB. If I use 2 Asian OTF files in my project, the compiled file will be more than 50MB(codename1 limitation).
I have tried to convert OTF to TTF with online tools, but all of them failed to convert.
How do I use OTF font with codename1?
Thank you.

At the moment we don't have support for OTF fonts. The main challenge is passing this support through the full chain and all the supporting tools. As you indicated the size of a full unicode font is indeed a problem as well. For the case of TTF you can download the font after install and load it dynamically, although I understand this isn't an ideal situation and will severely hinder the development process.

Related

Protect TTF Font files by making them unopenable, but still work on as webfonts

I'm a font maker and I want to protect my web-fonts.
I know about the HTACCESS way to protect font files, but I found that there is another way to protect web-fonts: making the TTF font files intentionaly corrupted when you try to open them with Windows Font Viewer so they won't be installable, while the the same exact file will still work as webfont in the browser.
Here's a working example I have found (how they did it is the mystery):
http://fontface.co.il/fonts/demo_s.asp?id=131
As you can see, you are able to access the font files if they are cached in your browser, but when you download the TTF file and open it via "Windows Font Viewer" in order to install it, it will give you this error: "The requested file _____.ttf is not a valid font file".
You can test it yourself in your computer and you'll see that the web font will still work only with the TTF. (without including the woff / eot files in #font-face)
That's exactly what I want to do to my own fonts.
That way they would still work as web fonts, and will not work as desktop fonts, making it harder for untrained people to install them without a license.
However, I can't figure out how they did it.
Any ideas?
The OS has different requirements for what constitutes as a valid font than a web browser. A web browser is more lenient when the font misses certain pieces of data. The trick is to figure out how much you can "mangle" a font so that it's not installable, but still passes OTS and is usable in a browser.
On the webpage indicated as an example, the font is served in Embedded OpenType format.
Embedded OpenType (EOT) fonts are a compact form of OpenType fonts designed by Microsoft for use as embedded fonts on web pages. [...] These font files can be created from existing TrueType font files using Microsoft's Web Embedding Fonts Tool (WEFT), and other proprietary and open source software. [...] The font files are made small in size by use of subsetting (only including the needed characters), and by data compression (LZ compression, part of Agfa's MicroType Express). (Wikipedia)

What system fonts are available to PIL on Google App Engine?

What fonts are available to use with PIL on App Engine?
I know I can upload a font as part of the application but what I basically want is a system provided sans-serif that will work with unicode characters that is a good looking Helvetica (or alternative). Google servers may already have some fonts installed and this is what I would like some insight into.
I would like to find a font to use that is unicode capable so Japanese and other characters will render properly using PIL.
I have a web page that renders unicode characters properly using font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
When I use PIL to render the same unicode characters they do not render properly. The font I uploaded as part of the app does not have the necessary unicode characters in the font.
Here are the relevant python lines of code from what I am using now.
import Image, ImageDraw, ImageFont
draw = ImageDraw.Draw(my_output)
font = ImageFont.truetype("FontIAmUsing.otf", font_size, encoding="utf-8")
draw.text((5, 51), 'abc', fill='#2A2A2A', font=font)
Considering that PIL only ships with a default bitmap font (ugly and probably not containing a very wide range of unicode characters) and since you have to provide the full path to your font file AND you cannot get outside of your sandboxed environment in GAE, you are better just uploading your fonts along with your application. If you don't specify a path, it will look at the root of your web application. I am using the GoogleAppEngineLauncher for OSX and when deploying it uploads all the files found (including the .ttf I am using with ImageDraw).
The documentation at http://effbot.org/imagingbook/imagefont.htm states: (New in 1.1.4) Load a "better than nothing" default font. I just confirmed that the default font is available on GAE.

How to install fonts on Windows & MAC using Silverlight?

I am creating a silver light 4 application which shows Hindi text using my custom Unicode font, its working fine when I embedded it in silver light application.
Custom font size is approximately 15 MB after compress in xap, it's too big. So is there any possible way to installed font on client machine using Silverlight.
I do not belive there is a way to actually install it, unless it is possible in a trusted SL4 Out Of browser app.
What you may want to do is package the font in a separate resource assembly and enable application library caching on the silverlight application.
You can do what was done over here to create a sub-set of your font using Blend SDK to make it much smaller: How to Create Subset Fonts in .NET?

Create a bmp of a string using a TTF file using C?

I have a new project assigned to me today. I need to load a TTF file and then write the specified string to a bitmap using that font. However, I do not have much information about the TTF structure. Is there any library specifically for this job?
I suggest you have a look at the SDL_ttf project. SDL is also a good start to build a small gfx app.
Here is also a useful tutorial aboud using SDL_ttf in OpenGL and rendering text as textures.

How do you map mac fonts to Windows fonts

I need to display a file that comes from a mac on a Windows machine.
The font name in the mac file is "Helvetica".
Windows does not have Helvetica but it has "Arial" which is the close. However, if I pass "Helvetica" to a WPF control the font family is ignored.
How can I get programmatically the closest font from "Helvetica" on Windows?
They are actually different fonts, though the difference is subtle. Talk to any obsessed graphic designer and he or she will probably start ranting about Arial's inferiority. Hell, they even made a movie out of it.
http://www.helveticafilm.com/
So that's why there's no "mapping". Because they're just plain different. You'll have to come up with your own way of choosing which font you want to use (that is, you'll have to detect what you have and then use what you get from the OS).
Some fonts contain an embedded PANOSE number, which classifies fonts visually and can be used to match similar fonts. It's what Windows' Fonts folder uses to list fonts by similarity. However, I'm not sure how widely supported it is.
Presumably, you'd need to know a particular Helvetica font's PANOSE number in order to find the near matches from the fonts you have installed.
See PANOSE on Wikipedia and MSDN Library page on Using PANOSE Numbers.
it may be possible to convert Helvetica into a windows something like transtype
you could then embed the font into your wpf app.
You may be on very sketchy ground in terms of licensing though!
There's a very good font stack generator over at codestyle.org, I've blogged about how to use it here http://devsigner.co.uk/creating-a-good-css-font-stack/
hope this helps!
There's some information about some Helvetica look-alikes here, maybe you could install these on your Windows machine. If you're worried about compatibility with other machines, you can't use this though, as it won't display the font on their machines (I believe it will default to some specific font, perhaps Arial or Times).

Resources