Japanese characters not supported by rmagick - ruby

I'm tring to build a voucher from template by rmagick, (using utf8 encoding) Below is just a small code snippet
text.annotate(template, 0, 0, 23, 155, offer_label) {
self.pointsize = 16
self.font_weight = BoldWeight
}
When i provide offer_label as 安価な価格でホテルを予約 (japanese)
so in the voucher that is created, the offer_label is dispayed as ????????????.
The offer_label is stored correctly in the database
Template code snippet:
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= #from_name %></title>
<style type="text/css">
a:hover { color: #09F !important; text-decoration: underline !important; }
</style>
</head>
I looked around the suggested questions but no luck.Looking forward for suggestions.
UPDATE:
The label_name is displayed correctly in the browser web pages, this issue only comes in the voucher which is created using rmagick

1) you should install Japanese font(s) to your runtime environment(s).
you can check this via Magick.fonts whether you've installed it or not.
2) specify font related attributes.
use Draw#annotate and specify font name/font_family name that you'd like to use.
Hope this helps.

Related

OCR A Extended font puzzle

I have 'OCR A Extended' font installed in Windows and I created the following test.html file, but in Chrome only the OCR A gets rendered as OCR text (class p.b), OCR A Extended (class p.a) gets rendered (computed) as Times New Roman, what's going on? In IE both are rendered as OCR. Same behavior in Windows 7 and Windows 10. Looks like a bug to me.
<html>
<head>
<style>
p.a {
font-family: "OCR A Extended";
}
p.b {
font-family: "OCR A";
}
</style>
</head>
<body>
<p class="a">1234567890</p>
<p class="b">1234567890</p>
</body>
</html>

Bangla Font showing mismatch - Laravel Dompdf

I am using Laravel Dompdf to generate PDF. Use Kalpurush font for Bangla text. Everything working well but text showing mismatch into PDF view. Lets example:Text should be আমি comes out like আ ম ি .
I don't know how can solve this problem. Already used UTF-8 charset. Here is my code sample
$pdf = PDF::setOptions(['dpi' => 150, 'defaultFont' => 'Kalpurush'])->loadView('text.download', compact('data'));
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
#font-face {
font-family: "Kalpurush";
src: url({{ storage_path('fonts/Kalpurush.ttf') }}) format('truetype');
}
body { font-family: "Kalpurush", DejaVu Sans;}
</style>
Have anyone face this type of problem.
Please give me guideline or any solution to solve this Bangla font problem for Lavavel Dompdf.

Cannot type slash or single quote in firefox add-on input field

I'm learning to develop a Firefox add-on. I've made a simple dev-tools tab with an input box. I'm finding that I can type every character into the input box with the exception of "/" or "'". A forward slash or single quote will not populate. Nothing appears in the input box when I type these characters.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
body{
margin:0;
}
.warpath-search{
width:100%;
background-color:#fcfcfc;
border:1px solid #f0f1f2;
padding:.3em;
}
.warpath-search label{
width:100px;
display:inline-block;
}
.warpath-search input{
width:400px;
}
</style>
</head>
<body>
<div class="warpath-search">
<label>Xpath:</label><input type="text" name="warpath-xpath" id="warpath-xpath" />
</div>
<script src="devtools-panel.js"></script>
</body>
</html>
devtools-panel.js:
input = document.getElementById("warpath-xpath");
input.addEventListener("keyup", () => {
console.log(input.value);
});
Gif:
If I load the plugin's HTML file directly in the browser I can enter the characters but when it is loaded as a plugin it's blocked.
Using Firefox: 70.0.1 (64-bit)
The problem seems to have something to do with a Firefox type-ahead feature. The following steps resolved the issue for me:
Open about:config in the browser
Click "I accept the risk"
Search for "accessibility.typeaheadfind.manual"
Change the value of this key from "true" to "false"

Laravel 5.6 barryvdh dompdf version 0.8.4 show Indian Rupee symbol as "?"

In one of my Laravel 5 project, I have used barryvdh dompdf (version 0.8.4) to generate PDF files. I used the following for meta e.g. <meta charset="utf-8"> and in html code, I used to show the Indian Rupee symbol e.g. <div style="font-size: 16px;">Payment of ₹ 6000.</div>
(&#8377 ; = html unicode of INR)
The PDF generates well however, the INR symbol is showing as ?. From several sources, I see that they are using dejavu font. I have used the same
<style>
body { font-family: DejaVu Sans, sans-serif; }
</style>
However by using the dejaVu, the other text including INR sign in the PDF are showing garbage characters. Any help?
PS - Should I download the font and store it into the asests/ folder?
Add code inside of html tag
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
* { font-family: DejaVu Sans, sans-serif; }
</style>

When Outlook 2007 ignores css, how to specify font-size?

I have two Windows computers, both with Outlook 2007. I send both an HTML email with stuff like:
<div style='font-family:Times New Roman,Serif;font-size:11pt'> ...
I need it to be Times New Roman, 11pt font. In one Outlook it shows up correctly as Times 11pt, in the other, Arial 12pt. I can get the second one to display Times by using surrounding content with a tag like:
<font face='Times New Roman' size='3'>...
But the size is mapped to 12pt, and size=2 is 10pt. I see no way yet to specify the size in px or pt. This tag is disturbing because we're in the year 2013.
I understand that Outlook HTML email rendering is a disaster because it defers to Word instead of IE for rendering. But why the difference? And can I do something to get the second copy of Outlook to act like the first one? Or is there some other way to tell it: "11pt".
Here is my most recent attempt at the HTML sent to Exchange...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
body, div, p, table, td {
font-family:TimesNewRoman, "Times New Roman", Times, Serif;
}
</style>
</head>
<body style='font-family:TimesNewRoman, "Times New Roman", Times, Serif;font-size:11pt;'>
<font style="font-family: TimesNewRoman, "Times New Roman", Times, serif; font-size: 14px; color: #000000;">
<p>Blah blah.
</p>
</font>
</body></html>
I had a similar problem, but I only have Office 2010, so I can't verify that this would work for 2007. In case it helps, I've shared the basic structure of my HTML for Outlook messages below. The key differences I see from the original question are the style type "text/css" and the enclosing comment tags around the styles. Note that other elements, like td, th, table, etc., can be styled in this block as well.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My Title</title>
<style type="text/css">
<!--
body { font-size: 10pt font-family: sans-serif; }
-->
</style>
</head>
<body>
blah, blah
</body>
</html>
Times isn't a font in Windows (I believe that is the Mac name for Times New Roman).
Courtesy of cssfontstack, Try something like this:
font-family: TimesNewRoman, "Times New Roman", Times, Baskerville, Georgia, serif;
Beyond this try using the quotation marks fallback in the example above to see if that makes a difference. Also, apply your css styles to a <font> tag or a <td> directly. Div's are not really recommended for html email, so I'd avoid them wherever possible. I use font tags almost exclusively to style text and they always seem to come through for me.

Resources