Commit Graph

16 Commits

Author SHA1 Message Date
Behdad Esfahbod 3d9a0306eb 2.0.0 2018-10-18 05:58:17 -07:00
Behdad Esfahbod 8061664ad1 Add doc stubs for recently added API
Thanks to David Corbett who revamped our script and language processing
and implemented full BCP 47 support.

https://github.com/harfbuzz/harfbuzz/pull/730

New API:
+hb_ot_layout_table_select_script()
+hb_ot_layout_script_select_language()
+HB_OT_MAX_TAGS_PER_SCRIPT
+HB_OT_MAX_TAGS_PER_LANGUAGE
+hb_ot_tags_from_script_and_language()
+hb_ot_tags_to_script_and_language()

Deprecated API:
-hb_ot_layout_table_choose_script()
-hb_ot_layout_script_find_language()
-hb_ot_tags_from_script()
-hb_ot_tag_from_language()
2018-10-11 14:17:17 -04:00
David Corbett 66790d64c7 Increase HB_OT_MAX_TAGS_PER_SCRIPT to 3
No script has 3 tags yet, but the plan is for the Indic scripts to each
get a third tag someday.
2018-10-11 13:54:28 -04:00
David Corbett 7f1fbfe2e3 Add hb_ot_tags_to_script_and_language 2018-10-11 13:54:28 -04:00
David Corbett 2f1f961cc0 Autogenerate the BCP 47 to OpenType mappings
The new script, gen-tag-table.py, generates `ot_languages` automatically
from the [OpenType language system tag registry][ot] and the [IANA
Language Subtag Registry][bcp47] with some manual modifications. If an
OpenType tag maps to a BCP 47 macrolanguage, all the macrolanguage's
individual languages are mapped to the same OpenType tag, except for
individual languages with their own OpenType mappings. Deprecated
BCP 47 tags are canonicalized.

[ot]: https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
[bcp47]: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

Some OpenType tags correspond to multiple ISO 639 codes. The mapping
from ISO 639 codes lists OpenType tags in priority order, such that more
specific or more likely tags appear first.

Some OpenType tags have no corresponding ISO 639 code in the registry so
their mappings use BCP 47 subtags besides the language. For example, any
BCP 47 tag with a fonipa variant subtag is mapped to 'IPPH', and 'IPPH'
is mapped back to und-fonipa.

Other OpenType tags have no corresponding ISO 639 code because it is not
clear what they are for. HarfBuzz just ignores these tags.

One such ignored tag is 'ZHP ' (Chinese Phonetic). It probably means
zh-Latn. However, it is used in Microsoft JhengHei and Microsoft YaHei
with the script tag 'hani', implying that it is not a romanization
scheme after all. It would be simple enough to add this mapping to
gen-tag-table.py once a definitive mapping is determined.

The manual modifications are mainly either obvious mappings that the
OpenType registry omits or mappings for compatibility with previous
versions of HarfBuzz. Some of the old mappings were discarded, though,
for homophonous language names. For example, OpenType maps 'KUI ' to
kxu; previous versions of HarfBuzz also mapped it to kvd, because kvd
and kxu both happen to be called "Kui".

gen-tag-table.py also generates a function to convert multi-subtag tags
like el-polyton and zh-HK to OpenType tags, replacing `ot_languages_zh`
and the hard-coded list of special cases in `hb_ot_tags_from_language`.
It also generates a function to convert OpenType tags to BCP 47,
replacing the hard-coded list of special cases in
`hb_ot_tag_to_language`.
2018-10-11 13:54:28 -04:00
David Corbett 2c7d4db7af Deprecate obsolete functions
`hb_ot_tags` replaces `hb_ot_tags_from_script` and
`hb_ot_tag_from_language`.

`hb_ot_layout_table_select_script` replaces
`hb_ot_layout_table_choose_script`.

`hb_ot_layout_script_select_language` replaces
`hb_ot_layout_script_find_language`.
2018-10-11 13:54:28 -04:00
David Corbett 91067716f5 Refactor the selection of script and language tags
The old hb-ot-tag.cc functions, `hb_ot_tags_from_script` and
`hb_ot_tag_from_language`, are now wrappers around a new function:
`hb_ot_tags`. It converts a script and a language to arrays of script
tags and language tags. This will make it easier to add new script tags
to scripts, like 'dev3'. It also allows for language fallback chains;
nothing produces more than one language yet though.

Where the old functions return the default tags 'DFLT' and 'dflt',
`hb_ot_tags` returns an empty array. The caller is responsible for
using the default tag in that case.

The new function also adds a new private use subtag syntax for script
overrides: "x-hbscabcd" requests a script tag of 'abcd'.

The old hb-ot-layout.cc functions,`hb_ot_layout_table_choose_script` and
`hb_ot_layout_script_find_language` are now wrappers around the new
functions `hb_ot_layout_table_select_script` and
`hb_ot_layout_script_select_language`. They are essentially the same as
the old ones plus a tag count parameter.

Closes #495.
2018-10-11 13:54:28 -04:00
Chun-wei Fan 835bbdc7c9 Public headers: Decorate public symbols with HB_EXTERN
This prepares the headers for exporting symbols using visibility
attributes or __declspec(dllexport), so that we do not need to maintain
symbols listing files, as this is what was and is done in GLib and GTK+.
2015-11-23 11:03:11 +08:00
Behdad Esfahbod d1c9eb458c Make it an error to include non-top-level headers
Users should #include <hb.h> (or hb-ft.h, hb-glib.h, etc), but
never things like hb-shape.h directly.  This makes it easier to
refactor headers later on without breaking compatibility.
2012-04-12 13:17:44 -04:00
Behdad Esfahbod 2409d5f8d7 Update Copyright headers 2011-04-21 17:14:28 -04:00
Behdad Esfahbod 62879eebd9 [API] Use ISO 15924 tags for hb_script_t
This simplifies the code, reduces static data, and makes the design
more extensible to future additions of new scripts.
2011-04-18 23:40:21 -04:00
Behdad Esfahbod 8e4bb3cacc Fold hb-language.[ch] into hb-common.[ch] 2011-04-11 17:55:58 -04:00
Behdad Esfahbod acdba3f90b Prefer C linkage 2010-07-23 15:39:27 -04:00
Behdad Esfahbod b490fa3433 Add hb_ot_tag_to_script() 2010-05-21 11:15:07 +01:00
Behdad Esfahbod c755cb3e3a Change header comment 2010-04-22 00:11:43 -04:00
Behdad Esfahbod 8a3511ac6c Add hb_language_t as well as language/script conversion to OT tags 2009-11-04 19:45:39 -05:00