os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ScriptAndLanguage.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ScriptAndLanguage.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,61 @@
1.4 +/*
1.5 + * %W% %E%
1.6 + *
1.7 + * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
1.8 + *
1.9 + */
1.10 +
1.11 +#include "LETypes.h"
1.12 +#include "OpenTypeTables.h"
1.13 +#include "OpenTypeUtilities.h"
1.14 +#include "ScriptAndLanguage.h"
1.15 +#include "LESwaps.h"
1.16 +
1.17 +U_NAMESPACE_BEGIN
1.18 +
1.19 +const LangSysTable *ScriptTable::findLanguage(LETag languageTag, le_bool exactMatch) const
1.20 +{
1.21 + le_uint16 count = SWAPW(langSysCount);
1.22 + Offset langSysTableOffset = exactMatch? 0 : SWAPW(defaultLangSysTableOffset);
1.23 +
1.24 + if (count > 0) {
1.25 + Offset foundOffset =
1.26 + OpenTypeUtilities::getTagOffset(languageTag, langSysRecordArray, count);
1.27 +
1.28 + if (foundOffset != 0) {
1.29 + langSysTableOffset = foundOffset;
1.30 + }
1.31 + }
1.32 +
1.33 + if (langSysTableOffset != 0) {
1.34 + return (const LangSysTable *) ((char *)this + langSysTableOffset);
1.35 + }
1.36 +
1.37 + return 0;
1.38 +}
1.39 +
1.40 +const ScriptTable *ScriptListTable::findScript(LETag scriptTag) const
1.41 +{
1.42 + le_uint16 count = SWAPW(scriptCount);
1.43 + Offset scriptTableOffset =
1.44 + OpenTypeUtilities::getTagOffset(scriptTag, scriptRecordArray, count);
1.45 +
1.46 + if (scriptTableOffset != 0) {
1.47 + return (const ScriptTable *) ((char *)this + scriptTableOffset);
1.48 + }
1.49 +
1.50 + return 0;
1.51 +}
1.52 +
1.53 +const LangSysTable *ScriptListTable::findLanguage(LETag scriptTag, LETag languageTag, le_bool exactMatch) const
1.54 +{
1.55 + const ScriptTable *scriptTable = findScript(scriptTag);
1.56 +
1.57 + if (scriptTable == 0) {
1.58 + return 0;
1.59 + }
1.60 +
1.61 + return scriptTable->findLanguage(languageTag, exactMatch);
1.62 +}
1.63 +
1.64 +U_NAMESPACE_END