How to get QML FontLoader to load UTF-8 on boot - utf-8

My setup:
Qt 5.9.4
buildroot Linux system
rockchip rk3288 processor
bootscript in /etc/init.d
I have some qml to display some utf8 characters
// roboto font
FontLoader {
id: roboto
source: "qrc:/fonts/Roboto-Regular.ttf"
}
Text {
text: "The temperature is: \u2103"
font.pixelSize: 24
font.family: roboto.name
}
When I run the application from the command line (UART) the font renders correctly.
When I reboot and have my application run from the boot script. The utf-8 characters are NOT rendered correctly.
I have tried all sorts of combinations:
The font is on the file system
The font is in different places on the filesystem
different fonts (montserrat, Avenir, etc).
display the font based on the loader status == FontLoader.Ready
All with the same results.
I happened to accidentally stumble upon this solution:
// japanese font
FontLoader {
id: jpFont
source: "qrc:/fonts/NotoSansJP-Regular.otf"
}
// roboto font
FontLoader {
id: roboto
source: "qrc:/fonts/Roboto-Regular.ttf"
}
Text {
text: "The temperature is: \u2103"
font.pixelSize: 24
font.family: roboto.name
}
This works. I'm not even using the japanese font, but it seems to make the Roboto start working correctly.
Why does my font load utf8 debugging, but not from bootup
why does this extra font magically fix it ?

Related

Printing Google Fonts using printJS

I've using printJS and jQuery together to print the contents of an HTML div.
The div contains text which is rendered with the 'Annie get your telescope' google font.
When I print, the text is printed using a more standard Web Font rather than the Google Font. If I download the font and host it locally, I get no text at all.
How do I print HTML via printJS and get text in a Google font to render correctly?
Make sure to pass the desired font to printJS. If you are not passing your stylesheet using the css property, you can just pass the font through the style property.
Another thing, currently, print.js is setting a default font for printing, which has been deprecated and will be removed on its next major version (v2). For now, you will also have to pass the font family with the font property.
printJS({
printable: "print-element",
type: "html",
style: `#import url('https://fonts.googleapis.com/css?family=Annie+Use+Your+Telescope');`,
font: 'Annie Use Your Telescope'
})
Here is a fiddle with the above example:
https://jsfiddle.net/crabbly/Lt2nvagc/

DOMPDF does not change the font in the resulting PDF

I have a problem when I try to change the default font.
The symbols in resulting PDF are changed by ??? symbols, so I tried to change the default font.
But when I try to change the default font in vendor/barryvdh/laravel-dompdf/config/dompdf.php "default_font" => "courier"
the font in the resulting PDF is not changed - Helvetica stays whatever I did.
I even tried to change the default font in the controller just before PDF generation:
PDF::setOptions(['dpi' => 150, 'defaultFont' => 'courier']);
but, it did not help also.
What could be the problem?
Thanks!

Text in QTextEdit is distorted

I have a QTextEdit in which I want to set some text (unicode) that has been generated by an ASCII Art text renderer. Everything works fine, except that the QTextEdit is distorting the text. The screenshot shows the same unicode text variable set in the QTextEdit via setText() and logged to the console, where it is displayed correctly.
It doesn't seem to matter if I use QTextEdit or QPlainTextEdit, or if I am setting the text via setText(ascii_art_text) or setPlainText(ascii_art_text). I'm using PySide here, however I suspect that isn't of too much interest in this case.
Any ideas how to fix that distortion?
From the looks of your example, it appears that your QTextEdit is not using a monospaced font which is what terminals and text editors typically use. Create a QFont using a monospaced font. E.g.,
# Specific Windows monospaced font.
font = QFont("Courier New")
According to Torsten Marek's answer in How to specify monospace fonts for cross platform Qt applications?, you can get a cross platform monospaced font with:
font = QFont("Monospace")
font.setStyleHint(QFont.TypeWriter)
Once you've determined your font, assign it to your QTextEdit:
text_edit.setCurrentFont(font)

do not embed custom font into Prawn generated PDF

I use Prawn to generate PDF.
When I use custom font (Arial CE with central/east european characters), the font is embedded into target PDF.
pdf.font_families.update(
"Arial" => {
:bold => "font/arialbd.ttf",
:italic => "font/ariali.ttf",
:bold_italic => "font/arialbi.ttf",
:normal => "font/arial.ttf"
}
)
pdf.font "Arial"
pdf.text "Účet", :size => 18
Problem is the size of PDF. Embedded font increases document size from 4kB to 80kB and I don't need to put font into every PDF because Arial CE is available on client machines.
Any suggestions how to use custom font without embedding it?
Unfortunately prawn has no way to turn off embedding of custom fonts.
You can use the build in fonts like Arial and Times New Roman, and they wont be embedded, but then you're not getting the look you're after.

Flex 4 embedding fonts for Spark components

I'm having a problem embedding fonts with the Open Source Flex 4.5 SDK (Hero), although am having the same issues with Flex 4 Open Source SDK. I've added some ttf files to the assets directory of my project structure and am trying to access the fonts in my CSS file as follows:
#font-face {
src: url("../assets/DroidSans.ttf");
fontFamily: DroidSans;
embedAsCFF: true;
}
This particular font is required to be used for a number of spark controls throughout the project (this is why embedAsCFF is set to true though I believe this parameter is optional anyway). However none of the spark components display this font when it's set in their fontFamily property. I get this error on compiling for every spark component I attempt to set the font on:
warning: incompatible embedded font
'DroidSans' specified for
(controlName) . This component
requires that the embedded font be
declared with embedAsCff=true.
Strangely enough the above font works with mx components even though embedAsCFF is set to true (from what I've looked up on this subject this should be set to false for mx components and true for spark).
The above code also works in Flash Builder, however, this project needs to be developed using the Open Source SDK, where it fails.
Any ideas? Surely someone else has had the same problem?
When running the following script, it shows that the fonts are "embedded", however, just not as "CFFEmbedded". The adobe documentation says these need to say "CFFEmbedded"
var fontArray:Array = Font.enumerateFonts(false);
trace("Fontarray length: " + fontArray.length);
for(var j:int = 0; j < fontArray.length; j++) {
var thisFont:Font = fontArray[j];
trace("FONT " + j + ":: name: " + thisFont.fontName + " embedded as type:" + thisFont.fontType + ".");
}
Thanks
Bob
[EDIT]
OK - I have finally managed to embed the font. I have tried SWC's from CS4, SWC's from Flash Builder 4, SWF's from both CS4 and Flash Builder....
Eventual fix
1) Package the font into a SWF in Flash Builder 4
2) Reference the compiled SWF using the following CSS
#font-face {
cff: false;
src: url('../bin/DroidSansFont.swf');
fontFamily: DroidSansMX;
}
#font-face {
cff: true;
src: url('../bin/DroidSansFont.swf');
fontFamily: DroidSans;
}
The crazy thing is - the use of the "cff: true" directive. All the documentation says to use "embedAsCFF". This throws an error, while using the "cff" attribute - it seems to work.
I have no idea - can anyone chime in with some ideas?
Probably you are using older SDK and compiler, "cff" was renamed to "embedAsCFF" in latest SDK builds, starting from build Flex SDK 4.0.7972 build, see this discussion http://forums.adobe.com/thread/36399 for the comment from Flex SDK engineer that proves that
I had a pretty similar issue, however I was unable to load any compiled SWF font file (Flex SDK 4.1). Finally, I was able to solve this issue using this code:
MXML:
<fx:Style>
#namespace s "library://ns.adobe.com/flex/spark";
#namespace mx "library://ns.adobe.com/flex/mx";
#font-face {
src: url("fonts/files/HelveticaNeueLTPro-Md.otf");
font-family: HelveticaNeueLTPro-Md;
embed-as-cff: true;
}
#font-face {
src: url("fonts/files/HelveticaNeueLTPro-Bd.otf");
font-family: HelveticaNeueLTPro-Bd;
embed-as-cff: true;
}
.helvetica {
font-family: HelveticaNeueLTPro-Md;
font-lookup: embeddedCFF;
}
.helveticaBold {
font-family: HelveticaNeueLTPro-Bd;
font-lookup: embeddedCFF;
}
</fx:Style>
As you see this is for the HelveticaNeue font (regular and bold) in OpenType format, but I had success with TrueType as well. The important CSS attribute was "font-lookup: embeddedCFF". Once I didn't set this, compiling worked but the embedded font was never displayed. Same goes for loading SWFs created by fontswf utility - never worked for me, too.
The problem described is probably caused by using a default set of font managers. You need to use CFFFontManager. Typically You define all four possible managers to allow some fallback. This is typically a problem of MX application trying to use spark components.
see also:http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7e09.html
and possibly: https://docs.sonatype.org/display/FLEXMOJOS/Using+Adobe+Font+Manager+to+embed+fonts
Configuration for Flexmojos follows (you can use similar for flex-config.xml files, viz link above):
<fonts>
<managers>
<manager-class>flash.fonts.JREFontManager</manager-class>
<manager-class>flash.fonts.BatikFontManager</manager-class>
<manager-class>flash.fonts.AFEFontManager</manager-class>
<manager-class>flash.fonts.CFFFontManager</manager-class>
</managers>
</fonts>
Notice the preferred manager is at the bottom.

Resources