I have a text box in my html page. I want to type in custom font (regional language) inside this textbox.
I add TTF file and changed the font family to this custom font. But still when I am entering into this text box, it is simply display it in English (default) only.
css code
#font-face
{
font-family:Anjali;
src: url ('AnjaliOldLipi.ttf');
}
.font-face
{
display:block;
font-family:Anjali;
}
HTML code
<input type="text" class="font-face"/>
How is it possible to type in English, and when entering space it is converting to custom font (regional language)? I am trying to implement same as in http://www.google.com/transliterate.
Google Transliterate is using the following font-family declaration:
html, input, textarea {
font-family: arial,sans-serif;
}
To have the characters translated to the specified alphabet, use a JavaScript Unicode mapping from English codepoints to Anjali codepoints, such as the following:
Unicode Entities for Malayalam
Mozhi - Detailed specification
Related
I am using 1st-time #font-face and facing some issue that my form label need two languages (1) English and (2) Hindi
I want the content of the text box in Hindi instead of the English alphabet.
For Hindi font I made below CSS added external CSS font but it's not coming on my form, then I called my class into my HTML but HTML is taking junk values, I don't know where I doing some mistakes please suggest me a solution.
#font-face {
font-family: hindi !important;
font-style: normal;
font-weight: 400;
src: url('file:///C:/Users/Tapas/Desktop/java%20script/es6/Kruti_Dev_010.ttf');
}
.lang-hindi {
font-family: hindi !important;
}
<p class="lang-hindi"> kaise ho</p>
I am expecting the Hindi alphabet as an output but it's showing only the English alphabet, can anyone please help me with the solution.
go to this site: https://www.web-font-generator.com/
upload your (Kruti_Dev_010.ttf) generate the web font
download generated font there will be CSS file in download files along with .woff, .svg, .eot and .ttf files as well
copy CSS style and correct file paths then use it into you web page
To use kruti dev font you cannot type the text like 'kaise ho' you need to use hindi keyboard layout to type -
so for example if you want to write
then you will in your html you will write - 'lkoZtfud izU;kl efUnj Jh egkdkys'oj '
You can better use Google Fonts, https://fonts.google.com/
Select your font over there, and add this to your web-page.
The answer you are looking for is a bit difficult but you can write whatever your desired text using google font and it will work on all browsers.
I want to add emojis in a html page, eg. 🇬🇧 but they do not render with the colorized icon.
I tried the follwing
<meta charset="utf-8" />
<body>
🇬🇧
🐑
</body>
</html>
And it does not show the colorized icons of the UK flag and sheep respectively. I as well tried wrapping the emoji characters in a span but it neither works. Maybe is something related to the fonts?
The rendering of the emojis is depending on the font you use to display them. Emojis are just normal characters like the letter "A" and need to be defined in the font you are using on your page. To display emojis correctly, you need to use a font which has these emojis defined and set the <span> (or your whole page) to use that font (with CSS).
Here is an explanation on Emojis. And here is an example on how to use the Google Noto Emoji Color font (free to use) on your website:
1- Download the font (here)
2- Embed it into your CSS:
#font-face {
font-family: "Noto Emoji Regular";
src: url('NotoEmoji-Regular.ttf') format('truetype');
}
Make sure the url has the right path to the local .tff file and add this to your page <style> definition or CSS file.
Note: They aren't new. Just "not supported", somehow.
I'm trying to make simple controls for a element on my website, along the lines of a simple "mute" or "not mute" control.
However, I haven't been able to find any fonts capable of handling the newer Unicode symbols, such as the speaker symbols (🔇 to 🔊, or 🔇 to 🔊) which are broken (🔇 🔈 🔉 🔊) even on Stack Overflow, yet still - They can be found in the Unicode character listings and are somehow able to be displayed in my PDF reader and Internet Explorer, but not Chrome.
This is the first paragraph (above), from my perspective, with the characters broken:
Anyway, here's my snippit of the code. (The video controls are in plain view for testing purposes). The actual element has a z-index: -1000 attached to it; used as a video background.
function mute() {
document.getElementById("jsControl").setAttribute ("href", "javascript:unmute()");
document.getElementById("jsControl").innerHTML = "🔈";
document.getElementById("videoPlayer").volume = 0.0
};
function unmute() {
document.getElementById("jsControl").setAttribute ("href", "javascript:mute()");
document.getElementById("jsControl").innerHTML = "🔊";
document.getElementById("videoPlayer").volume = 1.0
};
<html>
<head>
<style>
body {
font-family: [Insert font names and attempts];
}
</style>
</head>
<body>
<video id="videoPlayer" src="..."></video>
<a id="jsControl" href="javascript:unmute()">🔈</a>
</body>
</html>
I've tried different web-safe fonts, such as Arial, Times New Roman and Tahoma and Sergoe UI.
Question: Is there any font that can be used that supports those unicode characters that works on Chrome?
(Even a font that has these remapped onto regular letters like Wingdings will be accepted as they can be attached using #font-face { ... }.)
Also, please don't complain about the broken Javascript (if it is not written correctly) - I can fix that myself. It's the font; text (missing symbols) that I'm worried about.
Update: Viewing the icons in Internet Explorer works fine. Seems to be a chrome-and/or-other-browser sort of issue.
Since you would use just a few symbols in a special context, rather than as text characters, the practical choice is to use images.
However, if you really want to use characters, there is a very limited set of fonts to consider. According to fileformat.info, U+1F507 is supported only by Quivira, Symbola, Segoe UI Symbol, and Segoe UI Emoji. The latter two are proprietary fonts, available only in relative new versions of Windows, and as different variants (e.g., my Windows 7 lacks Segoe UI Emoji and has a variant of Segoe UI Symbol that lacks the character).
Thus, the only way that works reasonably is to use either Quivira or Symbola as a downloadable font, via #font-face. As they are rather large fonts, and you would need to serve them in different font formats for cross-browser functionality, this approach is hardly a practical option (unless you have many other special characters, possibly used in text, that also need such special fonts).
You shouldn't assume the person viewing your site has necessary fonts installed. Instead, you should add an external font. Find a font that has an appropriate licence and contains the required symbols (for example http://emojisymbols.com/), and add it to CSS as with #font-face declaration:
/*
EmojiSymbols Font (c)blockworks - Kenichi Kaneko
http://emojisymbols.com/
*/
#font-face {
font-family: "EmojiSymbols";
src: url('EmojiSymbols-Regular.woff') format('woff');
text-decoration: none;
font-style: normal;
}
.controlIcon {
font-family: "EmojiSymbols";
}
I have a .ttf icon-font for which I have lost the guide. I am able to view the complete character set in FontBook. Is there any way to figure out which CSS content-property I can use to access each character in the font-set?
To complete Diodeus' answer, you have to define a new font-face in your stylesheet :
#font-face {
font-family: 'MyIconsFont';
src: url("res/icons/MyTrueTypeFont.ttf") format("truetype");
font-weight: normal;
font-style: normal
}
.my-icons {
display: inline-block;
font-family: 'MyIconsFont';
}
.my-icons.some-symbol:before {
content: '\0061'; // Set the proper character index here
}
.my-icons.some-other-symbol:before {
content: '\0064'; // Set another proper character index here
}
Then use the defined styles in a dummy <span> or <i> tag:
<p>Here is some some symbol : <span class="my-icons some-symbol"></span>
and some other <i class="my-icons some-other-symbol"></i></p>
To find out about the characters indexes, you can inspect your font in Word's Insert > Symbol > Other
If you know the UTF-8 character code for the glyph in your font, you can specify it in the content: declaration in your CSS:
.example { content: "\203A" }
See also: Adding HTML entities using CSS content
You can use FontForge to inspect the font and view the various notations for that glyph.
Alternatively if you convert the .ttf file to an .svg file, you can see the Unicode notations of every glyph in the file.
You can then use e.g. an entity converter to find out the ASCII representation of the Unicode notation, which you can use for the CSS content: property.
I have problem with embedding Polish fonts into PDF converted from HTML.
My HTML code have style in body:
<BODY style="font-family: Tahoma, Arial, sans-serif;font-size : 8pt;">
I tried 2 ways of converting such HTML into PDF:
FOP with htmlcleaner
iText with flying-saucer
For FOP I can add all used fonts into its config file and then created PDF have those fonts embedded (if font is used in HTML). In resulting PDF I have Tahoma font in Identity-H encoding. It looks good -- all Polish letters are displayed as expected.
Then I tried such conversion with iText: seems simplier because I do not need to create transformation for every HTML. Unfortunately I don't know how to embed used fonts into resulting PDF. Most examples I found create PDF from scratch and I don't know how to apply those methods to the Flying Saucer ITextRenderer or other object used in conversion.
My current code tries to add fonts in PDFCreationListener.preOpen() by getting ITextFontResolver and adding font fs.addFont(path, true);. But all .pdf I create do not have fonts I want.
The second problem is that result PDF do not have Polish letters. Is it problem in Flying Saucer or in iText? Acrobat shows that created PDF document uses Helvetica with Ansi encoding and ArialMT as font. I think this Ansi encoding is not good. How can I set Polish encoding (Identity-H)?
You may try the -fs-pdf-font-embed, and -fs-pdf-font-encoding css rules.
From the User's Guide:
-fs-pdf-font-embed: use with the value embed inside a font-face rule
to have Flying Saucer embed a font file within a PDF document,
avoiding the need to call the addFont() method of the FontResolver
class
-fs-pdf-font-encoding: use inside a font-face rule to specify the
enconding for a custom font you are embedding inside a PDF; takes the
name of the encoding as value.
For example in your print css:
#font-face {
font-family: DejaVu Serif;
src: url(fonts/DejaVuSerif.ttf);
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
Working example:
Files in the root project directory:
Calibri.ttf
input.html
Code:
File inputFile = new File("input.html");
File outputFile = new File("example.pdf");
ITextRenderer renderer = new ITextRenderer();
String url = inputFile.toURI().toURL().toString();
FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
renderer.setDocument(url);
renderer.getFontResolver().addFont("Calibri.ttf", BaseFont.IDENTITY_H, true);
renderer.layout();
renderer.createPDF(fileOutputStream);
fileOutputStream.close();
HTML:
<style type="text/css">
body {
font-family: Calibri, sans-serif;
}
</style>
Surprisingly #font-face css is not needed
My mistake was to use FontResolver.addFont() in PDFCreationListener.preOpen(). I moved it just before renderer.layout(); and it works now!
If you've tried all the options and it still doesn't work, it's most likely a problem with with a font-family value that doesn't match the file name
You can find out the correct value using FontForge. Open font file in this program, then select the menu item Element -> Font Info. The correct value will be in the Family Name field
Minimum required html code:
<html>
<head>
<style>
body {
font-family: 'Calibri 123', sans-serif;
}
</style>
</head>
<body>
<p>
Hello, Calibri 123
</p>
</body>
</html>
Minimum required java code:
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("/path/to/font/Calibri.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(/*read html from file*/);
renderer.layout();
renderer.createPDF(/*stream here*/);