How does hb.font_get_glyph & hb.font_funcs_set_glyph_h_advance_func work? Not sure i understand the concept here
On Tue, Jun 28, 2016 at 7:05 PM, Behdad Esfahbod <[email protected]> wrote: > HarfBuzz already takes care of spaces if the font does not support: > > > https://github.com/behdad/harfbuzz/blob/master/src/hb-unicode-private.hh#L204 > > On Sun, Jun 26, 2016 at 10:56 AM, Kelvin Ma <[email protected]> > wrote: > >> Knockout overwrites most whitespace characters to a hardcoded width and >> special codepoint since most fonts can’t be trusted to properly construct >> or even contain these characters. >> >> ## Codepoints ## >> >> nonbreaking_spaces = { >> '\u00A0': -30, # nbsp >> '\u2007': -36, # figure >> '\u202F': -40, # narrow nbsp >> } >> >> breaking_spaces = { >> '\u2003': -31, # em >> '\u2002': -32, # en >> '\u2004': -33, # 1/3 >> '\u2005': -34, # 1/4 >> '\u2006': -35, # 1/6 >> >> '\u2008': -37, # punctuation >> '\u2009': -38, # thin >> '\u200A': -39, # hair >> >> '\u205F': -41, # math med >> } >> >> >> ## Widths (as fraction of em) ## >> >> space = self.get_advance(self.character_index(' '), True)/UPM >> fig = self.get_advance(self.character_index('0'), True)/UPM >> punc = self.get_advance(self.character_index(','), True)/UPM >> >> self._widths = { >> None: 0, >> ' ': space, >> '\t': 0, >> '\u00A0': space, >> '\u2003': 1, # em >> '\u2002': 0.5, # en >> '\u2004': 1/3, # 1/3 >> '\u2005': 0.25, # 1/4 >> '\u2006': 1/6, # 1/6 >> '\u2007': fig, # figure >> '\u2008': punc, # punctuation >> '\u2009': 0.2, # thin >> '\u200A': 0.1, # hair >> '\u202F': 0.2, # narrow nbsp >> '\u205F': 4/18, # math med >> } >> >> >> ## character labels (for UI) ## >> >> self.spacenames = { >> -30: 'nb', # nbsp >> -31: 'em', # em >> -32: 'en', # en >> -33: '1/3', # 1/3 >> -34: '1/4', # 1/4 >> -35: '1/6', # 1/6 >> -36: 'fig', # figure >> -37: 'pn', # punctuation >> -38: '1/5', # thin >> -39: 'h', # hair >> -40: 'nnb', # narrow nbsp >> -41: 'mt', # math med >> } >> >> My old layout engine would simply output the special negative codepoint >> and advance like with any other character when it encountered those unicode >> whitespace characters. (The negative codepoints are so that Knockout’s >> renderer knows how to display them.) How do I do this in Harfbuzz? They are >> important for mathematical typesetting. >> >> [image: Inline image 1] >> >> _______________________________________________ >> HarfBuzz mailing list >> [email protected] >> https://lists.freedesktop.org/mailman/listinfo/harfbuzz >> >> > > > -- > behdad > http://behdad.org/ >
_______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
