[HarfBuzz] hb-view

Behdad Esfahbod behdad at behdad.org
Wed Mar 16 13:42:33 PDT 2011


On 03/02/11 06:43, Martin Hosken wrote:
> Dear Behdad,
> 
>> A compromise would be a parsing string that handles the defined enum values,
>> and uses a tag for unknown values.  Something like:
>>
>> hb_script_t
>> hb_script_from_string (const char *s)
>> {
>>   if (strcmp (s, "Arab"))
>>     return HB_SCRIPT_ARABIC;
>>   if (strcmp (s, "Latn"))
>>     return HB_SCRIPT_LATIN;
>>   ...
>>
>>   return hb_tag_from_string (s);
>> }
> 
> +1
> 
> I like this approach. We need to get away from enums and into more open approaches, while maintaining backward compatibility. Perhaps your hb_tag_from_string could work on an uppercased version of the string, to allow the script tag to remain case independent. Hmm perhaps the whole function needs to be case independent.

I've done this now.  Check it out:

http://cgit.freedesktop.org/harfbuzz/commit/?id=5d91c3d547f78163b36aa7436d4388a836cca94a

I don't see much reason to keep the enum.  Sure, there are a couple of arrays
that we currently index by the script, but bsearching wouldn't be noticably
slower.

Jonathan, I'm particularly interested to hear your opinion.  What would you
think of removing the hb_script_t enum and replaching it by defines like:

#define HB_SCRIPT_LATIN ((hb_script_t) HB_TAG ('L','a','t','n'))

It's still switchable, which seems to be the most common way we use scripts.

behdad


> Yours,
> Martin



More information about the HarfBuzz mailing list