2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
* %W% %E%
|
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "OpenTypeUtilities.h"
|
|
|
|
#include "ScriptAndLanguage.h"
|
|
|
|
#include "LESwaps.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2003-04-12 00:37:12 +00:00
|
|
|
const LangSysTable *ScriptTable::findLanguage(LETag languageTag, le_bool exactMatch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
le_uint16 count = SWAPW(langSysCount);
|
2003-04-12 00:37:12 +00:00
|
|
|
Offset langSysTableOffset = exactMatch? 0 : SWAPW(defaultLangSysTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
Offset foundOffset =
|
|
|
|
OpenTypeUtilities::getTagOffset(languageTag, langSysRecordArray, count);
|
|
|
|
|
|
|
|
if (foundOffset != 0) {
|
|
|
|
langSysTableOffset = foundOffset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
if (langSysTableOffset != 0) {
|
2003-04-12 00:37:12 +00:00
|
|
|
return (const LangSysTable *) ((char *)this + langSysTableOffset);
|
2002-04-02 03:33:42 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2002-04-02 03:33:42 +00:00
|
|
|
return 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
const ScriptTable *ScriptListTable::findScript(LETag scriptTag) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
le_uint16 count = SWAPW(scriptCount);
|
|
|
|
Offset scriptTableOffset =
|
|
|
|
OpenTypeUtilities::getTagOffset(scriptTag, scriptRecordArray, count);
|
|
|
|
|
|
|
|
if (scriptTableOffset != 0) {
|
2001-01-19 00:30:17 +00:00
|
|
|
return (const ScriptTable *) ((char *)this + scriptTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-04-12 00:37:12 +00:00
|
|
|
const LangSysTable *ScriptListTable::findLanguage(LETag scriptTag, LETag languageTag, le_bool exactMatch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const ScriptTable *scriptTable = findScript(scriptTag);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
if (scriptTable == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-04-12 00:37:12 +00:00
|
|
|
return scriptTable->findLanguage(languageTag, exactMatch);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2001-10-16 00:39:01 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|