3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # This tool is used to prepare a list of valid language subtags from the
8 # IANA registry (http://www.iana.org/assignments/language-subtag-registry).
12 # perl genLanguageTagList.pl language-subtag-registry > gfxLanguageTagList.cpp
14 # where language-subtag-registry is a copy of the IANA registry file.
18 my $timestamp = gmtime();
20 /* This Source Code Form is subject to the terms of the Mozilla Public
21 * License
, v
. 2.0. If a copy of the MPL was
not distributed with this
22 * file
, You can obtain one at http
://mozilla
.org
/MPL/2.0/. */
25 * Derived from the IANA language subtag registry by genLanguageTagList
.pl
.
27 * Created on
$timestamp.
29 * * * * * This file contains MACHINE
-GENERATED DATA
, do not edit
! * * * * *
37 # strip leading/trailing whitespace, if any
42 # assume File-Date precedes the actual list;
43 # record the date, and begin assignment to an array of valid tags
44 if (m/^File-Date:\s*(.+)$/) {
45 print "// Based on IANA registry dated $1\n\n";
46 print "static const uint32_t sLanguageTagList[] = {";
55 # we only care about records of type 'language'
56 if (m/^Type:\s*(.+)$/) {
57 $isLanguage = ($1 eq 'language');
61 # append the tag to our string, with ";" as a delimiter
62 if ($isLanguage && m/^Subtag:\s*([a-z]{2,3})\s*$/) {
64 print "\n TRUETYPE_TAG(",
65 join(",", map { $_ eq " " ?
" 0 " : "'" . $_ . "'" } split(//, substr($tagstr . " ", 0, 4))),
70 if ($isLanguage && m/^Description:\s*(.+)$/) {
72 $isLanguage = 0; # only print first Description field
77 # at end of file, terminate our assignment to the array of tags
80 0x0 // end of language code list
84 * * * * * This file contains MACHINE
-GENERATED DATA
, do not edit
! * * * * *