Posts

Showing posts with the label otf

Faux Bold and Italic

Image
Faux bold and italic using Freetype API   Modern Outline fonts (Truetype and Opentype) have a separate file for each weight and style for better readability. They are usually suffixed as normal, Bold, Italic and Bold-Italic. This means that one cannot render these variants if the font files are missing. From the end user perspective this is annoying at times. Following APIs can be used to generate faux bold and italic variants.   Freetype API   cairo_ft_font_face_set_synthesize (font_face, CAIRO_FT_SYNTHESIZE_BOLD                      | CAIRO_FT_SYNTHESIZE_OBLIQUE);   Cairo transformation API Use x-stretch transformation for bold and skew transformation for italic. cairo_matrix_t font_matrix;   font_matrix.xx *= 1.5; // Bold - stretch font_matrix.xy = -5;     // Italic - skew   Harfbuzz API This didn't work for me.  hb_font_set_synthetic_slant(fon...

Text along a path (GNU Emacs)

Image
  SVG 2 specifications allows flowing text along a curve via textPath element. This opens up possibilities for cool text effects e.g. Formula Editor in GNU Emacs . GNU Emacs uses librsvg for SVG rendering on GNU/Linux. This fix for librsvg was  available in 2014 [4]. But this wasn't applied for some reason. Librsvg has moved to Rust since then. The code below is pre-Rust version of librsvg. sample.svg <?xml version="1.0" encoding="UTF-8"?> <svg height="300" width="800" xmlns="http://www.w3.org/2000/svg"      xmlns:xlink="http://www.w3.org/1999/xlink">     <path id="my_path1" d="M 50 100 Q 25 10 180 100 T 350 100 T 520 100 T 690 100" fill="transparent" />     <text>         <textPath xlink:href ="#my_path1" font-size="34"> Text along a path looks awesome!!         </textPath>     </text> </svg> ...