I need to use some custom font for numbers in my Qt app, but company ask me to use image as font, font file is not allowed(For example: ttf).
the font image like this:
So i wonder is possible to converting the font image to QFont?
like a Qt font generator.
Or any other solution?
There is nothing out of the box that supports what you are looking for. You would need to get around this company rule by building your own TrueTypeFont data programmatically from your image, keeping it in memory only and load that into your application with addApplicationFontFromData(const QByteArray & fontData).
Unfortunately I cannot find a single library that does this, and the TTF format appears dauntingly complex. I would suggest looking into this open source project for font creation. Perhaps you can use this as a starting point? http://fontforge.github.io/en-US/
You may want to find out the reason your company is telling you that you cannot use a custom font. (I just remembered reading that QT has difficulties storing a font as a "resource". If it's not due to copyright issues, then you could suggest not using an image, but storing the entire file in the source code in a text format like base-64. Then convert it back into binary at startup, then load it up as a new font from a QByteArray.
I guess it's about copyright issues ? There are lots of ttf fonts available for completely free commercial use. E.G. have a look at Droid Sans Mono : https://www.google.com/fonts/specimen/Droid+Sans+Mono
Otherwise it would be good to know the reason why ttf is not allowed.
It is possible to create a font from a vector graphic.
If you have resonable high resolution images of every letter (if not already vector graphics) you can try to convert them to vector graphics (SVG).
Afterwards you can use tools to convert SVG to a font. This would be most likely a ttf font which can be used with QFont.
Related
I've downloaded mbtiles from openmaptiles and Also displayed them in web page. I used this to translate labels from english to other languages. but it doesn't work. Does anybody know how to change languages?
(Should mention that i display it with mapbox gl)
In a similar situation, the styles I got from running the docker setup of tileserver-gl contained many layers such as: "poi_label-en". These label are preventing the new label created by klokantech/openmaptiles-language to display properly (the library will create layers such as "poi_label-de" based on the definition of "poi_label" for German for instance).
I'd suggest the following steps to make openmaptiles-language works properly:
Take the latest style you want, such as: https://github.com/openmaptiles/klokantech-basic-gl-style
Update the style to point to your source, glyphs and sprites. (use your current style as a basis)
Potentially change the name of the fonts if they do not match the ones served by your server (I had to update from "Noto Sans Regular" to "Klokantech Noto Sans Regular")
Then if you follow klokantech/openmaptiles-language instructions and example it should work properly.
A quick way to check your javascript implementation would be to use the cloud solution of openmaptiles for the tiles and the style. If it works properly, the javascript part is OK and the problem is in how your style is defined.
I have a software running on an embedded Linux written in Qt/QML. I am using a font family, let's call it SomeFontFamily.otf. This font family doesn't support Chinese characters, therefore when I want to display a Chinese text I am getting empty squares instead. If I run the same software on my desktop Linux I get the same result with Chinese text, but if I add a .font directory in my home folder with a font family that supports Chinese then it displays the characters. So I thought I can do the same on the embedded device and added a .font folder in my home directory with the right font, but unfortunately it didn't work. Then I have found this doc about Qt fonts on embedded devices. It says that I should put my font under lib/fonts directory because Qt will search there for it on embedded devices. I tried it, but unfortunately with no success. Anybody had a similar issue? Just for the record this is not translation related. I just want to be able to display Chinese characters in an english text.
Embedded QT versions often lack features, disabled by people who want to cut on dependencies without checking what the dependencies are there for in the first place.
To get font substitution to work you need a build with fontconfig enabled. To get complex text support (anything that exercises more than latin glyphs) you need harfbuzz, the newer version (harfbuzz-ng) the better.
I have fixed the problem with Arabic language by using my own FontConfig. You have to enable it using FontConfig & Font Qt Embedded
My final solution was actually creating a wrapper class for QFont and adding QFont::insertSubstitution(...) in the constructor for my set font. Then expose it to QML and use it as a default font. It works like a charm.
As a side note: if you have bundled your fonts with a resource file (.qrc) you have to add those fonts with QFontDatabase::addApplicationFont.
I have a css font family like below(I have shorten it because of displaying limit otherwise it is much much bigger than what I have present here)
now can you please let me know that if there is a way to convert the url()content inti .ttf font formats or other standard font formatS ?
#font-face{font-family:'web_font';
src:url('data:font/opentype;base64,d09GRk9UVE8AAHUkAA0AAAAAvnQAAhOIAAAAAAAAAAAAAAAAAAAAAAAAAABDRkYgAAABMAAAXwMAAIcHbRkIAEZGVE0AAGA0AAAAGgAAABxoptAkR0RFRgAAYFAAAACWAAAA3hpVGOlHUE9TAABg6AAABf8AABkwdgAPiEdTVUIAAGboAAAGngAADSIYX0AXT1MvMgAAbYgAAABXAAAAYI8WBFNjbWFwAABt4AAAAZYAAAKquYd/vWhlYWQAAG94AAAAMwAAADYIcsC0aGhlYQAAb6wAAAAhAAAAJAuVB6xobXR4AABv0AAAA0cAAAaQAUI5cG1heHAAAHMYAAAABgAAAAYBpFAAbmFtZQAAcyAAAAHuAAAFH7QO6sRwb3N0AAB1EAAAABMAAAAg/h4AHnictLoHXFRH1zjMvbC7V9S1cRcFXVDBggTpxRbFrigWpCq997pUkY4w9N5BepMuoGI3WGNsURMTY0wsURITU2Zx8Hm+uQsui/F58/zf9/eBF2fOOXPanDnnzN0lpGRkpAiCmBLq4mjl4uXga+HiKEWQUoTUGuF0qeHTxPAZcvgpQ+');}
1) First of all you need to save the base64 string as a file.
Some of the online service is restricted to how much you can enter, so simple do this locally by just opening the base64 string in your browser and you will be promoted with save as dialog, choose any name you want
Alternative (if the browser don't allow you to enter such a long url) create a download link open the page in any supported browser that supports download attribute (chrome, firefox, opera)
download web_font
2) Then you need to figure out what file extension it's
With just the small amount of base64 string you provided me i was able to recognize it as a woff file, by looking at it with a hex/text editor. I uploaded the saved file to https://hexed.it and could read in the beginning that it said woff
So now you have your web_font.woff file!
3) Convert it to TTF with the right tool for the woff - format
I can google that for you and found for example fontforge that dose this and some free online service as well.
onlinefontconverter.com makes a good job at converting unknown formats by looking at the magic number instead of the file extension so you can have your ttf file directly. And you don't have to install any program either. But it doesn't tell you what the original file extension is.
Don't do this? If you have an actual font file, like a .ttf file, just use that in your CSS.
#font-face {
font-family: WhateverNameYouNeed;
src: url('location/to/your/file.ttf') format('truetype')
}
aaaaaand we're done. For universal acceptance, wrap it as a WOFF and then use that instead of the ttf OpenType font file, so that every modern browser supports it.
NOTE: you can't just blatantly convert your fonts, though. If you do not own the rights to the font, or the font does not come with a license that says derivatives are allowed, you are not allowed to convert this font.
Is there a way to embed a font to the xls and use it with PHPExcel?
I want custom font because I want to use barcode font in the excel.
I tried to embed a barcode image but random dot appears when printing and the barcode scanner cannot read it.
There isn't. Excel relies on the range of fonts that exist on the client PC where the Excel document is opened. Where a font doesn't exist, it will fall back to members of the font family that exist on that client PC. In the case of a font referenced in an xls file where no member of that font family exists on the client PC, it simply cannot be rendered. This is standard MS Excel behaviour, not specific to PHPExcel-generated files.
The only alternative I can suggest is generating an image file of the barcode, and embedding that image in the xls file.
I really want to use this free font for embedding with #font-face: http://www.theleagueofmoveabletype.com/fonts/3-flaminia-type-system
However, it only comes in .vbf format. Has anyone ever dealt with this format before, or know how to convert it to a usable format? I can't find anything that will open it.
As the page you linked states, it's the "Multiple Master" format. It seems there's free software available to convert Multiple Master fonts to PostScript fonts: http://en.wikipedia.org/wiki/Multiple_master_fonts#Free_software.
FontLab Studio saves font files as .vbf
This is not an installable font - this is font creation software. They need to be exported in the normal .otf and .ttf formats to be useable.