[HarfBuzz] Overwrite certain font characters

Ebrahim Byagowi ebraminio at gmail.com
Wed Jun 29 00:00:42 UTC 2016


I don't know about the python binding but I hope this
<https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzFace.cpp?sq=package:chromium&dr=C&rcl=1467126994&l=281>
help
(you can click on each parameter and also function name there in order to
find references of each function). General concept (AFAIK) is to override
inner functions of shaping process with ones suitable with rest of project,
so you can write your own logic for them or just customize and wrap
original ones with bits you need, and I guessed these are the things you
need.

On Wed, Jun 29, 2016 at 3:50 AM, Kelvin Ma <kelvinsthirteen at gmail.com>
wrote:

> 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 <behdad at behdad.org>
> 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 <kelvinsthirteen at gmail.com>
>> 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
>>> HarfBuzz at lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/harfbuzz
>>>
>>>
>>
>>
>> --
>> behdad
>> http://behdad.org/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20160629/39697266/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Selection_050.png
Type: image/png
Size: 9373 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20160629/39697266/attachment-0001.png>


More information about the HarfBuzz mailing list