DOMPDF does not change the font in the resulting PDF - laravel

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!

Related

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)

How to use different styles of local fonts in plots with Gadfly in Julia-lang on Mac?

I want to create plots with Gadfly in Julia programming language using a specific font style (e.g., Avenir Next Bold) of a local font (Avenir Next) on my Mac. It works for the standard font style in the case of an standard histogram example:
using Gadfly
plot(x=randn(2000), Geom.histogram(bincount=100),
Theme(minor_label_font="Avenir Next",
major_label_font="Avenir Next",
key_label_font="Avenir Next"))
Yet when a specific font style such as "Avenir Next Bold" is used the default font is applied instead of the provided one. The Avenir Next fonts are saved as a "container" in a ttc format. I tried to convert the ttc file into single ttf files for the font styles and to call the exact paths where the files are located. Both don't work.
I think this is a case of getting the font name exactly right.
(I used HeavyItalic because it's easier to tell if the correct font is chosen.)
It might be that you have to use the PostScript font name, although I'm not sure why that would be, unless deep down in Cairo that's how fonts are accessed... ?
You can get the PostScript names (if that's what they are) by looking at a font manager. For example, FontBook shows them on the info panel:

Magento - strange characters in invoice PDF

Getting a strange character appearing at the end of each custom option in a PDF invoice. See the image below. Any ideas what this character might be?
It might be the case that the current PDF's font library that is used, doesn't support certain characters.
By default it uses the following Font library for PDF Generation: LinLibertineC_Re-2.8.0.ttf
In order to change the default PDF Font:
Get the desired font library's TTF-file and place it in the lib folder of your Magento installation.
Edit the following files (better mirror it instead of editing core files directly) in order to switch the font:
/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php
/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

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.

Changing Font Size of Japanese (Unicode) characters

I have a NSPopUpButton which contains either English or Japanese Strings read from a plist file according to the System's Language. Now when the Language is English I am able to change the font size by using code such as -
[auxStatePopup setFont: [NSFont fontWithName:#"Helvetica-BoldOblique" size:10.0]];
but Using such technique I am not able to change Japanese font size even if I tried by setting some Japanese font name which I googled and found out.
I want to do that because Japanese characters move slightly up when used. I intend to manipulate that upward movement by decreasing font size.
Thanks for any help..
OR
any way to move text in NSPopupButton downwards?
My impression is that the two samples are not using the same font. Please try to put a text with characters from both sets and see what happens.
Also try not to customize the font size and even the font face.
I also suspect that the text rendering engine may had overridden some of your changes due to the text length. iOS text rendering may try to change the font size of letter spacing if the text does not fit the control. So make some tests with shorter texts.
BTW, I think that you were mean to say that you want bigger font size for Japanese not smaller. In the screenshots the Japanese text is already too small to be properly read by anyone.

Resources