[HarfBuzz] hb_shape, hb_feature_from_string and using hb_feature_t *features

Liam liam at fallenacorn.com
Wed Feb 3 18:33:23 UTC 2016


Hello again,

I have been reviewing the tutorial provided with the source code for 
harfbuzz and I am still uncertain on how to tell 'hb_shape' to use a 
different glyph for a character in a buffer.

I have a string 'Coffee Time' and when I add that value to the hb_buffer 
struct with the 'hb_buffer_add_utf*' if I call the hb_shape as done in 
the tutorial it only pulls the glyphs '*.calt', but this behavior is not 
exactly what I want.

The OTF font set I am using has '*.swsh" glyphs present for certain utf 
characters, and I want shape to use the 'C.swsh' for the start of this 
buffer when I call hb_shape.

I figure that the 'hb_features *' tells hb_shape how to treat the buffer 
since the hb_feature_t has fields for a tag, the start point and end 
point. Is this the correct way to instruct hb_shape on which glyphs to 
use an alternative glyph (in my case I want to use C.swsh and not C.calt'

How does one construct this hb_feature_t struct, reading the provided 
documentation  'hb_feature_from_string' looks like the call I wish to 
use, but it has an argument called "str" I am assuming this is the 
string value that will set the tag value in the struct, but I have not 
found a correct value that will actually return an initialized 
hb_feature struct.

I have tried the values from hb-shape --help-features from the command 
line including other various other guesses and wild stabs, and none of 
them seemed to work.

Is my reasoning correct, the array of features will tell hb_shape how to 
shape the UTF buffer the way I want (replace glyphs with swashed 
variants, granted from reading the documentation and code hb_shape will 
try it's best). And is there an example on how to set a feature struct 
and passing it to hb_shape, the tutorial for using harfbuzz just passes 
a NULL value to hb_shape for the hb_feature_t * argument.

Thanks


More information about the HarfBuzz mailing list