Commit e50b9ae7 authored by Keith Packard's avatar Keith Packard

Update iso639-2 language coverage info, fix Georgian orthography to

    eliminate Mingrelian and Svan glyphs, use coverage for inclusion and
    OS/2 for Han exclusion, restructure fclang.c to use fclang.h from
    fc-lang dir
parent d6dabf36
XCOMM $XFree86: xc/lib/fontconfig/fc-lang/Imakefile,v 1.3 2002/07/07 19:18:51 keithp Exp $
XCOMM $XFree86: xc/lib/fontconfig/fc-lang/Imakefile,v 1.4 2002/07/07 19:30:52 keithp Exp $
#ifdef UseInstalled
/* building outside the tree, use private defines */
......@@ -13,8 +13,8 @@ LOCAL_LIBRARIES=FontconfigClientLibs
SRCS=fc-lang.c
OBJS=fc-lang.o
TARG=fclang.c
TMPL=fclang.tmpl.c
TARG=fclang.h
TMPL=fclang.tmpl.h
#
# Basic ISO 639-1 two letter language names
......@@ -26,7 +26,7 @@ ORTH1=ab.orth ar.orth az.orth ba.orth be.orth bg.orth bn.orth bo.orth br.orth\
mk.orth ml.orth mn.orth mo.orth mt.orth nl.orth no.orth oc.orth or.orth\
pl.orth pt.orth rm.orth ro.orth ru.orth sh.orth si.orth sk.orth sl.orth\
sq.orth sr.orth sv.orth ta.orth te.orth th.orth tl.orth tr.orth uk.orth\
vo.orth wa.orth yi.orth zh_cn.orth zh_tw.orth
vo.orth wa.orth yi.orth zh_cn.orth zh_mo.orth zh_sg.orth zh_tw.orth
#
# ISO 639-2 adds many more three letter language names
......
This diff is collapsed.
/*
* $XFree86$
* $XFree86: xc/lib/fontconfig/fc-lang/fclang.tmpl.h,v 1.1 2002/07/06 23:21:36 keithp Exp $
*
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -22,109 +22,4 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "fcint.h"
typedef struct {
FcChar8 *lang;
FcCharSet charset;
} FcLangCharSet;
@@@
#define NUM_LANG_CHAR_SET (sizeof (fcLangCharSets) / sizeof (fcLangCharSets[0]))
FcBool
FcFreeTypeSetLang (FcPattern *pattern, FcCharSet *charset)
{
int i;
FcChar32 missing;
for (i = 0; i < NUM_LANG_CHAR_SET; i++)
{
missing = FcCharSetSubtractCount (&fcLangCharSets[i].charset, charset);
if (FcDebug() & FC_DBG_SCANV)
printf ("%s(%d) ", fcLangCharSets[i].lang, missing);
if (!missing && !FcFreeTypeHasLang (pattern, fcLangCharSets[i].lang))
if (!FcPatternAddString (pattern, FC_LANG, fcLangCharSets[i].lang))
return FcFalse;
}
if (FcDebug() & FC_DBG_SCANV)
printf ("\n");
return FcTrue;
}
FcLangResult
FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
{
const FcChar8 *orig_s1 = s1;
FcChar8 c1, c2;
FcLangResult result;
/*
* Compare ISO 639 language codes
*/
for (;;)
{
c1 = *s1++;
c2 = *s2++;
if (c1 == '\0' || c1 == '-')
break;
if (c2 == '\0' || c2 == '-')
break;
c1 = FcToLower (c1);
c2 = FcToLower (c2);
if (c1 != c2)
return FcLangDifferentLang; /* mismatching lang code */
}
if (!c1 && !c2)
return FcLangEqual;
/*
* Make x-* mismatch as if the lang part didn't match
*/
result = FcLangDifferentCountry;
if (orig_s1[0] == 'x' && (orig_s1[1] == '\0' || orig_s1[1] == '-'))
result = FcLangDifferentLang;
if (c1 == '\0' || c2 == '\0')
return result;
/*
* Compare ISO 3166 country codes
*/
for (;;)
{
c1 = *s1++;
c2 = *s2++;
if (!c1 || !c2)
break;
c1 = FcToLower (c1);
c2 = FcToLower (c2);
if (c1 != c2)
break;
}
if (c1 == c2)
return FcLangEqual;
else
return result;
}
const FcCharSet *
FcCharSetForLang (const FcChar8 *lang)
{
int i;
int country = -1;
for (i = 0; i < NUM_LANG_CHAR_SET; i++)
{
switch (FcLangCompare (lang, fcLangCharSets[i].lang)) {
case FcLangEqual:
return &fcLangCharSets[i].charset;
case FcLangDifferentCountry:
if (country == -1)
country = i;
default:
break;
}
}
if (country == -1)
return 0;
return &fcLangCharSets[i].charset;
}
......@@ -14,7 +14,7 @@ built.
afr af Afrikaans afrikaans
aka Akan akan
akk Akkadian akkadien
alb/sqi* sq Albanian albanais
* alb/sqi* sq Albanian albanais
ale Aleut aloute
alg Algonquian languages algonquines, langues
amh am Amharic amharique
......@@ -22,7 +22,7 @@ built.
apa Apache languages apache
* ara ar Arabic arabe
arc Aramaic aramen
arm/hye* hy Armenian armnien
* arm/hye* hy Armenian armnien
arn Araucanian araucan
arp Arapaho arapaho
art Artificial (Other) artificielles, autres langues
......@@ -42,7 +42,7 @@ built.
bal Baluchi baloutchi
bam Bambara bambara
ban Balinese balinais
baq/eus* eu Basque basque
* baq/eus* eu Basque basque
bas Basa basa
bat Baltic (Other) baltiques, autres langues
bej Beja bedja
......@@ -57,7 +57,7 @@ built.
bis bi Bislama bichlamar
bla Siksika blackfoot
bnt Bantu (Other) bantoues, autres langues
tib/bod* bo Tibetan tibtain
* tib/bod* bo Tibetan tibtain
bos bs Bosnian bosniaque
bra Braj braj
* bre br Breton breton
......@@ -73,12 +73,12 @@ built.
cau Caucasian (Other) caucasiennes, autres langues
ceb Cebuano cebuano
cel Celtic (Other) celtiques, autres langues
cze/ces* cs Czech tchque
* cze/ces* cs Czech tchque
cha ch Chamorro chamorro
chb Chibcha chibcha
che ce Chechen tchtchne
chg Chagatai djaghata
chi/zho* zh Chinese chinois
* chi/zho* zh Chinese chinois
chk Chuukese chuuk
chm Mari mari
chn Chinook jargon chinook, jargon
......@@ -113,7 +113,7 @@ built.
dra Dravidian (Other) dravidiennes, autres langues
dua Duala douala
dum Dutch, Middle (ca.1050-1350) nerlandais moyen (ca. 1050-1350)
dut/nld* nl Dutch nerlandais
* dut/nld* nl Dutch nerlandais
dyu Dyula dioula
dzo dz Dzongkha dzongkha
efi Efik efik
......@@ -146,8 +146,8 @@ built.
gay Gayo gayo
gba Gbaya gbaya
gem Germanic (Other) germaniques, autres langues
geo/kat* ka Georgian gorgien
ger/deu* de German allemand
* geo/kat* ka Georgian gorgien
* ger/deu* de German allemand
gez Geez guze
gil Gilbertese kiribati
* gla gd Gaelic; Scottish Gaelic galique; galique cossais
......@@ -161,7 +161,7 @@ built.
got Gothic gothique
grb Grebo grebo
grc Greek, Ancient (to 1453) grec ancien (jusqu' 1453)
gre/ell* el Greek, Modern (1453-) grec moderne (aprs 1453)
* gre/ell* el Greek, Modern (1453-) grec moderne (aprs 1453)
grn gn Guarani guarani
* guj gu Gujarati goudjrati
gwi Gwichin gwichin
......@@ -195,7 +195,7 @@ built.
ipk ik Inupiaq inupiaq
ira Iranian (Other) iraniennes, autres langues
iro Iroquoian languages iroquoises, langues (famille)
ice/isl* is Icelandic islandais
* ice/isl* is Icelandic islandais
* ita it Italian italien
jav jv Javanese javanais
* jpn ja Japanese japonais
......@@ -271,7 +271,7 @@ built.
mic Micmac micmac
min Minangkabau minangkabau
mis Miscellaneous languages diverses, langues
mac/mkd* mk Macedonian macdonien
* mac/mkd* mk Macedonian macdonien
mkh Mon-Khmer (Other) mn-khmer, autres langues
mlg mg Malagasy malgache
* mlt mt Maltese maltais
......@@ -361,9 +361,9 @@ built.
san sa Sanskrit sanskrit
sas Sasak sasak
sat Santali santal
scc/srp* sr Serbian serbe
* scc/srp* sr Serbian serbe
sco Scots cossais
scr/hrv* hr Croatian croate
* scr/hrv* hr Croatian croate
sel Selkup selkoupe
sem Semitic (Other) smitiques, autres langues
sga Irish, Old (to 900) irlandais ancien (jusqu' 900)
......@@ -455,7 +455,7 @@ built.
was Washo washo
wel/cym* cy Welsh gallois
wen Sorbian languages sorabes, langues
wln wa Walloon wallon
* wln wa Walloon wallon
wol wo Wolof wolof
xho xh Xhosa xhosa
yao Yao yao
......
#
# $XFree86$
# $XFree86: xc/lib/fontconfig/fc-lang/ka.orth,v 1.2 2002/07/06 23:59:16 keithp Exp $
#
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
#
......@@ -24,7 +24,8 @@
# Georgian (KA)
0589 # Armenian full stop (vertsaket)
10a0-10c5
10d0-10f8
10d0-10f6
#10f7-10f8 # additional letters for Mingrelian and Svan
10fb
#2018 # single quote
#201a # single quote
......
#
# $XFree86$
#
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Keith Packard not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Keith Packard makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# Chinese in Macau (ZH-MO)
#
# Just use Big5 as for ZH-TW
include zh_tw.orth
#
# $XFree86$
#
# Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Keith Packard not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission. Keith Packard makes no
# representations about the suitability of this software for any purpose. It
# is provided "as is" without express or implied warranty.
#
# KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# Chinese in Singapore (ZH-SG)
#
# Just use GB2312 as for ZH-CH
include zh_cn.orth
/*
* $XFree86: xc/lib/fontconfig/src/fcfreetype.c,v 1.5 2002/06/29 20:31:02 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcfreetype.c,v 1.6 2002/07/06 23:47:43 keithp Exp $
*
* Copyright 2001 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -30,198 +30,33 @@
#include <freetype/internal/ftobjs.h>
#include <freetype/tttables.h>
static const FcChar8 *fcLangLatin1[] = {
(FcChar8 *) "br", /* Breton */
(FcChar8 *) "ca", /* Catalan */
(FcChar8 *) "da", /* Danish */
(FcChar8 *) "de", /* German */
(FcChar8 *) "en", /* English */
(FcChar8 *) "es", /* Spanish */
(FcChar8 *) "eu", /* Basque */
(FcChar8 *) "fi", /* Finnish */
(FcChar8 *) "fo", /* Faroese */
(FcChar8 *) "fr", /* French */
(FcChar8 *) "ga", /* Irish */
(FcChar8 *) "gd", /* Scottish */
(FcChar8 *) "gl", /* Galician */
(FcChar8 *) "is", /* Islandic */
(FcChar8 *) "it", /* Italian */
(FcChar8 *) "kl", /* Greenlandic */
(FcChar8 *) "la", /* Latin */
(FcChar8 *) "nl", /* Dutch */
(FcChar8 *) "no", /* Norwegian */
(FcChar8 *) "pt", /* Portuguese */
(FcChar8 *) "rm", /* Rhaeto-Romanic */
(FcChar8 *) "sq", /* Albanian */
(FcChar8 *) "sv", /* Swedish */
0
};
static const FcChar8 *fcLangLatin2[] = {
(FcChar8 *) "cs", /* Czech */
(FcChar8 *) "de", /* German */
(FcChar8 *) "en", /* English */
(FcChar8 *) "fi", /* Finnish */
(FcChar8 *) "hr", /* Croatian */
(FcChar8 *) "hu", /* Hungarian */
(FcChar8 *) "la", /* Latin */
(FcChar8 *) "pl", /* Polish */
(FcChar8 *) "ro", /* Romanian */
(FcChar8 *) "sk", /* Slovak */
(FcChar8 *) "sl", /* Slovenian */
(FcChar8 *) "sq", /* Albanian */
0
};
static const FcChar8 *fcLangCyrillic[] = {
(FcChar8 *) "az", /* Azerbaijani */
(FcChar8 *) "ba", /* Bashkir */
(FcChar8 *) "bg", /* Bulgarian */
(FcChar8 *) "be", /* Byelorussian */
(FcChar8 *) "kk", /* Kazakh */
(FcChar8 *) "ky", /* Kirghiz */
(FcChar8 *) "mk", /* Macedonian */
(FcChar8 *) "mo", /* Moldavian */
(FcChar8 *) "mn", /* Mongolian */
(FcChar8 *) "ru", /* Russian */
(FcChar8 *) "sr", /* Serbian */
(FcChar8 *) "tg", /* Tadzhik */
(FcChar8 *) "tt", /* Tatar */
(FcChar8 *) "tk", /* Turkmen */
(FcChar8 *) "uz", /* Uzbek */
(FcChar8 *) "uk", /* Ukrainian */
0,
};
static const FcChar8 *fcLangGreek[] = {
(FcChar8 *) "el", /* Greek */
0
};
static const FcChar8 *fcLangTurkish[] = {
(FcChar8 *) "tr", /* Turkish */
0
};
static const FcChar8 *fcLangHebrew[] = {
(FcChar8 *) "he", /* Hebrew */
(FcChar8 *) "yi", /* Yiddish */
0
};
static const FcChar8 *fcLangArabic[] = {
(FcChar8 *) "ar", /* arabic */
0
};
static const FcChar8 *fcLangWindowsBaltic[] = {
(FcChar8 *) "da", /* Danish */
(FcChar8 *) "de", /* German */
(FcChar8 *) "en", /* English */
(FcChar8 *) "et", /* Estonian */
(FcChar8 *) "fi", /* Finnish */
(FcChar8 *) "la", /* Latin */
(FcChar8 *) "lt", /* Lithuanian */
(FcChar8 *) "lv", /* Latvian */
(FcChar8 *) "no", /* Norwegian */
(FcChar8 *) "pl", /* Polish */
(FcChar8 *) "sl", /* Slovenian */
(FcChar8 *) "sv", /* Swedish */
0
};
static const FcChar8 *fcLangVietnamese[] = {
(FcChar8 *) "vi", /* Vietnamese */
0,
};
static const FcChar8 *fcLangThai[] = {
(FcChar8 *) "th", /* Thai */
0,
};
static const FcChar8 *fcLangJapanese[] = {
(FcChar8 *) "ja", /* Japanese */
0,
};
static const FcChar8 *fcLangSimplifiedChinese[] = {
(FcChar8 *) "zh-cn", /* Chinese-China */
0,
};
static const FcChar8 *fcLangKorean[] = {
(FcChar8 *) "ko", /* Korean */
0,
};
static const FcChar8 *fcLangTraditionalChinese[] = {
(FcChar8 *) "zh-tw", /* Chinese-Taiwan */
0,
};
static const FcChar8 *fcLangEnglish[] = {
(FcChar8 *) "en", /* English */
0,
};
/*
* Elide some of the less useful bits
* Keep Han languages separated by eliminating languages
* that the codePageRange bits says aren't supported
*/
static const struct {
int bit;
const FcChar8 **lang;
const FcChar8 *lang;
} FcCodePageRange[] = {
{ 0, fcLangLatin1 },
{ 1, fcLangLatin2 },
{ 2, fcLangCyrillic },
{ 3, fcLangGreek },
{ 4, fcLangTurkish },
{ 5, fcLangHebrew },
{ 6, fcLangArabic },
{ 7, fcLangWindowsBaltic },
{ 8, fcLangVietnamese },
/* 9-15 reserved for Alternate ANSI */
{ 16, fcLangThai },
{ 17, fcLangJapanese },
{ 18, fcLangSimplifiedChinese },
{ 19, fcLangKorean },
{ 20, fcLangTraditionalChinese },
{ 21, fcLangKorean },
/* 22-28 reserved for Alternate ANSI & OEM */
/* { 29, fcLangMacintosh }, */
/* { 30, fcLangOem }, */
/* { 31, fcLangSymbol },*/
/* 32-47 reserved for OEM */
{ 48, fcLangGreek },
{ 49, fcLangCyrillic },
/* { 50, fcLangMsdosNordic }, */
{ 51, fcLangArabic },
/* { 52, fcLangMSDOS_CANADIAN_FRENCH }, */
{ 53, fcLangHebrew },
/* { 54, fcLangMSDOS_ICELANDIC }, */
/* { 55, fcLangMSDOS_PORTUGUESE }, */
{ 56, fcLangTurkish },
{ 57, fcLangCyrillic },
{ 58, fcLangLatin2 },
{ 59, fcLangWindowsBaltic },
{ 60, fcLangGreek },
{ 61, fcLangArabic },
{ 62, fcLangLatin1 },
{ 63, fcLangEnglish },
{ 17, (const FcChar8 *) "ja" },
{ 18, (const FcChar8 *) "zh-tw" },
{ 19, (const FcChar8 *) "ko" },
{ 20, (const FcChar8 *) "zh-cn" },
};
#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0])
FcBool
FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang)
FcFreeTypeIsExclusiveLang (const FcChar8 *lang)
{
FcChar8 *old;
int i;
int i;
for (i = 0; FcPatternGetString (pattern, FC_LANG, i, &old) == FcResultMatch; i++)
if (!FcStrCmp (lang, old))
for (i = 0; i < NUM_CODE_PAGE_RANGE; i++)
{
if (FcLangCompare (lang, FcCodePageRange[i].lang) != FcLangDifferentLang)
return FcTrue;
}
return FcFalse;
}
......@@ -240,10 +75,7 @@ FcFreeTypeQuery (const FcChar8 *file,
FT_Library ftLibrary;
const FcChar8 *family;
TT_OS2 *os2;
FcChar32 codepoints;
FcChar8 *lang;
FcBool hasLang = FcFalse;
const FcChar8 *exclusiveLang = 0;
if (FT_Init_FreeType (&ftLibrary))
return 0;
......@@ -335,16 +167,17 @@ FcFreeTypeQuery (const FcChar8 *file,
}
if (bits & (1 << bit))
{
int j;
const FcChar8 *lang;
for (j = 0; (lang = FcCodePageRange[i].lang[j]); j++)
if (!FcFreeTypeHasLang (pat, lang))
{
if (!FcPatternAddString (pat, FC_LANG, lang))
goto bail1;
hasLang = FcTrue;
}
/*
* If the font advertises support for multiple
* "exclusive" languages, then include support
* for any language found to have coverage
*/
if (exclusiveLang)
{
exclusiveLang = 0;
break;
}
exclusiveLang = FcCodePageRange[i].lang;
}
}
}
......@@ -356,12 +189,11 @@ FcFreeTypeQuery (const FcChar8 *file,
if (!cs)
goto bail1;
codepoints = FcCharSetCount (cs);
/*
* Skip over PCF fonts that have no encoded characters; they're
* usually just Unicode fonts transcoded to some legacy encoding
*/
if (codepoints == 0)
if (FcCharSetCount (cs) == 0)
{
if (!strcmp(FT_MODULE_CLASS(&face->driver->root)->module_name, "pcf"))
goto bail2;
......@@ -370,18 +202,8 @@ FcFreeTypeQuery (const FcChar8 *file,
if (!FcPatternAddCharSet (pat, FC_CHARSET, cs))
goto bail2;
if (!hasLang)
{
if (!FcFreeTypeSetLang (pat, cs))
goto bail2;
/*
* Make sure it has a lang entry
*/
if (FcPatternGetString (pat, FC_LANG, 0, &lang) != FcResultMatch)
if (!FcPatternAddString (pat, FC_LANG, (FcChar8 *) "x-unknown"))
goto bail2;
}
if (!FcFreeTypeSetLang (pat, cs, exclusiveLang))
goto bail2;
/*
* Drop our reference to the charset
......
/*
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.13 2002/06/03 08:31:15 keithp Exp $
* $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.16 2002/07/06 23:47:44 keithp Exp $
*
* Copyright 2000 Keith Packard, member of The XFree86 Project, Inc.
*
......@@ -398,6 +398,9 @@ int
FcFontDebug (void);
/* fcfreetype.c */
FcBool
FcFreeTypeIsExclusiveLang (const FcChar8 *lang);
FcBool
FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
......@@ -470,7 +473,9 @@ FcMemFree (int kind, int size);
/* fclang.c */
FcBool
FcFreeTypeSetLang (FcPattern *pattern, FcCharSet *charset);
FcFreeTypeSetLang (FcPattern *pattern,
FcCharSet *charset,
const FcChar8 *exclusiveLang);
FcLangResult
FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment