2

I am using hindi font on my CKeditor using font-face. So when I am typing on the textbox it is showing hindi fonts.

But it is because of font-face.So when I copy to another place it shows english font and thats not I want. I am trying to add the data in Hindi from a html "text field" to mysql database using the php script.

It is not inserting the hindi text, it is inserting the English fonts.

2 Answers2

1

I have no experience with hindi language, so I don't know how it is usually stored in databases. But font face affects only how the text is rendered. It will not affect the way how data is stored, so normal ASCII characters will be the output of the editor. If you want to display on your website text in the same way that it was visible inside the editor you need to apply the same fonts on the target website.

Reinmar
  • 21,729
  • 4
  • 67
  • 78
  • Ok that means it is not possible for someone to copy text from my website as it will be copying in English. So what can I do beside using font-face if I want to allow user to copy in its own language? – Naitik Desai May 14 '15 at 10:48
  • If the user copies and paste within editor, then it's not a problem. But indeed, if they copy to another place, where different font is applied, then the font will be lost, because most browsers do not copy inline styles together with the content (and that's actually good). I'm surprised though, because I've never heard about this issue. I'd thought that all hindi characters are represented by different unicode characters - not by a different font... This sounds very strange. – Reinmar May 14 '15 at 11:21
  • Ya i get that font-face is only for viewing purpose and will not store its original values to database.so I want to use conversion script to change each value to its unicode value? – Naitik Desai May 15 '15 at 09:34
1

Reinmar is right and you can also embed your font in your HTML with encoding it in base64:

<style type="text/css">
@font-face {
  font-family: 'hindi';
  src: url(data:application/x-font-woff;charset=utf-8;base64,d09GRgA...AAA==) format('woff'),
     url(data...) format('truetype');
  font-weight: normal;
  font-style: normal;
}
</style>
<p style="font-family: hindi;">Output of the editor</p>

Here you can copy it to another place but it is not optimized to render it on a webpage.

KyleK
  • 4,643
  • 17
  • 33
  • @font-face { font-family: "Hindi"; src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgA...AAA==") format('woff'), url("http://localhost/texteditor/ckeditor/k010.TTF") format("truetype"); /*non-IE*/ font-weight: normal; font-style: normal; } – Naitik Desai May 14 '15 at 11:17
  • This is an example, see the "...", I do not have your font, I can not guess the real code. You must get the base64 encoded of each format of your font to do it. And localhost/... is not base64 encoded, it will never works outside of your local machine. – KyleK May 14 '15 at 11:24