-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to change font? #1208
Comments
What have you tried? Some sample HTML/CSS would help determine the source of your problem. |
I had put this code in dompdf/lib/php-font-lib/www/font_info.php
this is enough for ref? |
|
Yes $fontfile is path of the ttf font file.. Thanks bsweeney. |
Something like this should work
|
Thanks .. Let me try this .. i will know you.. |
i try this but now working yet.. |
A few other things to check:
Might help to see your dompdf-related code. |
Hi, I have the same problem with fonts. Also,
|
@aleksandar-irvas perhaps your sample was just for demonstration, if that's the case maybe my comments are not on point. If so follow up with a bit more information. First, a few things I noticed about your sample code:
Second, since you're using a DejaVu font you don't need to use an |
@bsweeney Thanks for replay, this was just a sample. But I noticed that same code in my localhost bolds |
@aleksandar-irvas I would check that dompdf has read/write access to the temp directory, font directory, and font cache directory. |
Same problem over here trying to change Helvetica to Avenir:
Found some advice on StackOverflow, but could not get it to work: http://stackoverflow.com/questions/12581156/custom-fonts-for-dompdf 2013 is probably outdated? Or do I still need to create the .afm files as advised on stackoverflow? I want to go after file privileges in temp and font cache directory but dont know where to set these. DejaVu renders fine, I'm using dompdf 0.7.0 |
@cocomo just FYI instead of manually setting up the font you can use an That being said, You do need a font metrics file. AFM is for fonts that use Windows ANSI encoding, UFM is for fonts that use Unicode encoding. For all intents and purposes Dompdf uses only UFM. You can get the font metrics using php-font-lib or some other font processing tool, but probably the easiest way to get everything set up is to use one of the methods I mentioned above. |
@bsweeney Thank you for the clarification, i finally got Avenir showing up with help of the load_font command. Since Avenir has 6 different weights i'm wondering how to set these up für dompdf? Should I create 3 custom font names, each with custom b/i/bi relations, or is there a way to keep the family bundled and to target individual weights in a css style, like |
Unfortunately Dompdf doesn't currently support numeric weights (see #675). The work around would be, as you stated, to define each weight as a separate family in your stylesheet. |
Hey all, 'gosmick-sans' => array(
'normal' => DOMPDF_FONT_DIR . 'GosmickSans',
'bold' => DOMPDF_FONT_DIR . 'GosmickSansBold',
'italic' => DOMPDF_FONT_DIR . 'GosmickSansBoldOblique',
'bold_italic' => DOMPDF_FONT_DIR . 'GosmickSansOblique',
), While returning PDFs Content via an view as HTML, all Looks good, the Font is used. But as soon as I render PDF and open it, the font won't be used? It's an Laravel-based Project if that is an usefull Information. It's dompdf 0.6.* |
@lippoliv do you have a sample of the HTML? |
@bsweeney here's the HTML (not really pretty, I know) <!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
@page {
margin: 0;
padding: 0;
}
td {
padding: 0;
spacing: 0;
}
</style>
</head>
<body style="width: 100%;">
<table>
<tr>
<td>
<div style="
position: relative;
float: left;
width: 259px;
height: 156px;
margin: 1px;
padding: 0;
font-family: gosmick-sans;
">
<div style="
font-size: 7pt;
position: absolute;
top: 9px;
left: 15px;
heigth: 8pt;
border-bottom: 1px solid #000;
">abc</div>
<div style="
font-size: 11pt;
position: absolute;
top: 30px;
left: 15px;
margin: 0;
padding: 0;
">
xyz
</div>
<div style="
font-size: 6pt;
position: absolute;
right: 15px;
top: 30px;
color: #CCC;
">200</div>
</div> </td>
</tr>
</table>
</body>
</html> |
Not pretty is ok ... certainly better for tracking down possible issues ;) |
Here's the font if it helps you analysing (just normal font, not bold etc) GosmickSans.zip |
I don't see anything out of the ordinary, and a quick test seems to work. If you remove absolute positioning does that help? What if you set gosmick-sans globally in your stylesheet, e.g. |
Nice. I haven't used laravel-dompdf much but it seems to be quite popular. Glad to know it makes font installation easy. |
Non of them worked for me :-( |
@kasra-appscore we can discuss your issue over on the support forum. Remember to provide details on what you've tried and the results. |
This work for me.
try to put > !important |
@MauricioGO, you're a lifesaver. That did the trick. Thanks! |
ہزمح ہزمح ہزمح font get loaded but this is how it is showing every letter is separated in urdu Why every letter is separated? |
Dompdf does not currently perform any complext text layout (such as shaping). Follow #2619 for updates. For now you will need to pre-process your text in order for it to |
i want to filter pdf of filtered data fro my table so i used this query i watched all tutorials on dompdf but all used ::all() query . |
@asifrashid09 your question appears unrelated and not necessarily a bug. You should start a new discussion, though the doesn't really seem specific to Dompdf so it may be better to use a site like StackOverflow. |
i am trouble to change to font when i export data as a PDF.
please let me know as soon as possible how to fix this issues.
The text was updated successfully, but these errors were encountered: