View Single Post
Old 04-22-2015, 05:45 PM   #17
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,825
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Hi Roger and Jbacelar;

Sorry but I'm affraid the the embedded font, as is implemented, it won't work on a .svg file. In fact, in the essai.epub that Jbacelar attached the font doesn't work. In order that an embedded font works on a svg file, you must add -in the svg statements, the following definition:

Code:
    <defs>
       <style type="text/css">
         <![CDATA[
           @font-face {
              font-family: "Charis";
              src: url("../Fonts/Charis-SIL2.ttf");
           }
         ]]>
       </style>
    </defs>
You should have in your .css file the following:

Code:
@font-face {
    font-family: "Charis";
    src: url("../Fonts/Charis-SIL2.ttf");
}

body {
    font-family: "Charis"; /* this only is neccesary if you want the embbed font for all the text in your ebook; if you only want the embedded font in your .svg, then don't include this declaration */
}
and in your .xhtml file:

Spoiler:

Code:
<body>
<div>
  <svg xmlns="http://www.w3.org/2000/svg" height="100%" preserveAspectRatio="xMidYMid meet" version="1.1" viewBox="0 0 578 740" width="100%" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
       <style type="text/css">
         <![CDATA[
           @font-face {
              font-family: "Charis";
              src: url("../Fonts/Charis-SIL2.ttf");
           }
         ]]>
       </style>
    </defs>

    <image height="670" width="578" x="25" xlink:href="../Images/arbre2.png"/>

    <text font-family="Charis" style="font-size: 24px">
      <tspan x="20" y="250">Ainsi il avançait toujours sans</tspan>

      <tspan x="20" y="285">rencontrer le moindre être vivant jusqu’à ce</tspan>

      <tspan x="20" y="320">que dans la grande cour d’honneur, il se</tspan>

      <tspan x="20" y="355">trouva en face d’un soldat appuyé sur sa</tspan>

      <tspan x="20" y="390">lance et la tête penchée la poitrine. Au</tspan>

      <tspan x="20" y="425">premier moment, le Prince pensa qu’il</tspan>

      <tspan x="20" y="460">ne vivait plus, il fut vite détrompé car</tspan>

      <tspan x="20" y="495">ses joues étaient fraîches et rouges;</tspan>

      <tspan x="20" y="530">il n'était qu'endormi.</tspan>

      <tspan x="20" y="565">Il y avait dans cette cour</tspan>

      <tspan x="20" y="600">d’autres sentinelles aussi</tspan>

      <tspan x="20" y="640">immobiles et muettes, une rangée de hallebardiers</tspan>

      <tspan x="20" y="675">s’appuyaient contre un mur, et, devant eux, étendu</tspan>

      <tspan x="20" y="710">sur le gazon, le sergent, qui les commandait</tspan>
    </text>
  </svg>
</div>
</body>


As you can see, the text should be written by using the tags <tspan></tspan> and in the <text> tag must be defined the styles of the font (font-size; font-family; font-color; font-weight; etc., etc.). The positioning of the text must be defined with <tspan> but font-styles must be defined once, at the beginning, with the <text> tag.

I attach a new essai.epub so you can study the code better.

Regards.
Rubén

UPDATE: if you want to convert the .epub in .azw3 you should replace:

Code:
<text font-family="Charis" style="font-size: 24px">
with

Code:
<text font-family="Charis" font-size="24">
In fact, this last form works for both, .epub and .azw3 so should be preferable to use this sintax. And I think that is better to use a font-size of 22 instead of 24 (to me, it looks better).
Attached Files
File Type: epub new essai with embedded font.epub (303.2 KB, 197 views)

Last edited by RbnJrg; 04-22-2015 at 06:03 PM.
RbnJrg is offline   Reply With Quote