[cairo] pango+cairo how to get position of each character?
Naveen M K
naveen at syrusdark.website
Sat May 8 16:39:08 UTC 2021
> For example, I have a text string "hello" and a truetype font file, and I want to apply different color to different character, currently I cannot find a way to implement it.
You can simple use `PangoAttribute` for coloring each character
differently or use you can also use PangoMarkup for achieving that.
For loading a font from truetype font file, I don't know whether Pango
would be able to do that. I think it usually requires you to install the
font before hand and reference by the name.
> then if no api to render one by one
There is an API for rendering a Layout character by character,
`pango_cairo_show_layout_line` where you can iterate a PangoLayout
using `pango_layout_get_line` to achieve that.
> I can use freetype library to render each glyph
No idea how it will work.
More information about the cairo