File: pangoMeasure.ml

package info (click to toggle)
ocamlgraph 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,624 kB
  • sloc: ml: 19,995; xml: 151; makefile: 14; sh: 1
file content (9 lines) | stat: -rw-r--r-- 375 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
let withContext ~context ~fontName ~fontSize text =
  let font_description = Pango.Font.from_string fontName in
  Pango.Font.modify font_description
    ~size:(fontSize * Pango.scale)
    ();
  Pango.Context.set_font_description context font_description;
  let layout = Pango.Layout.create context in
  Pango.Layout.set_text layout text;
  Pango.Layout.get_pixel_size layout