1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/**
* Yudit Unicode Editor Source File
*
* GNU Copyright (C) 1997-2023 Gaspar Sinai <gaspar@yudit.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2,
* dated June 1991. See file COPYYING for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*!
* \file SRendClass.cpp
* \brief Convert Yudit Character Types to OTF.
* \author: Gaspar Sinai <gaspar@yudit.org>
* \version: 2000-04-23
*/
#include "stoolkit/SRendClass.h"
#include "stoolkit/SCluster.h"
/*
* \brief Get the inherent rendering class of the character.
*
* We use a somewhat different naming convention than
* specified in OpenType documents. Here is the Mapping:
*
* The types in square brackets are handlesd in a
* hard-coded switch in here.
*
* Cbase SD_INDIC_CONSONANT_BASE
* Cbellow SD_INDIC_CONSONANT_BELOW_BASE
* Cpost SD_INDIC_CONSONANT_POST_BASE
* Cdead SD_INDIC_CONSONANT_DEAD
* Mbelow[,VMbelow] SD_INDIC_BOTTOM_VOWEL
* Mabove SD_INDIC_TOP_VOWEL
* Mpost[,Mabove] SD_INDIC_RIGHT_VOWEL
* VMpost[,VMabove,SMabove] SD_INDIC_MODIFIER
* SMabove[,SMbelow] SD_INDIC_SIGN (only U+0952 is SMbelow)
* VO SD_INDIC_INDEP_VOWEL
* Mpre SD_INDIC_LEFT_VOWEL
* Halant SD_INDIC_HALANT
* Nukta SD_INDIC_NUKTA
*
* Vsplit SD_INDIC_LEFT_RIGHT_VOWEL - need to split
* None Extension
*
* The following types are not returned by this program:
*
* Cfirst First consonant
* Clast Last consonant
* Cpre Pre-base
* Chbase Cbase that can be in half form.
* Cra The first non-reph-ra.
* CMra The first non-reph-ra if there is post-base matra.
* Creph Repha
* CMreph Repha if there is post-base matra.
* ZWJ Zero-Width Joiner
* ZWNJ Zero-Width Non-Joiner
* Any Anything
*/
SRendClass::RType
SRendClass::get (SS_UCS4 u)
{
if (u >= 0x1100 && u <= 0x115f) return JamoL;
if (u >= 0x1160 && u <= 0x11a2) return JamoV;
if (u >= 0x11a8 && u <= 0x11f9) return JamoT;
switch (u)
{
// Jamo can use these.
case 0x302e:
case 0x302f:
return Mpre;
case 0x0901:
case 0x0902:
case 0x0981:
case 0x0A81:
case 0x0B01:
case 0x0A82:
case 0x0A02:
case 0x0A01:
case 0x0A03: // Not VMPost
return VMabove;
case 0x0A70:
case 0x0A71: // Not VMpost
return SMabove;
case 0x0952:
return SMbelow;
case 0x0C3E:
case 0x0C4A: // Not Mabove
return Mpost;
case 0x0962:
case 0x0963:
case 0x09E2:
case 0x09E3: // Not Mbelow
return VMbelow;
case 0x200D:
return ZWJ;
case 0x200C:
return ZWNJ;
case 0x0946:
case 0x0947:
case 0x0948:
case 0x06C5:
case 0x0AC5:
return Mpost; // Not above.
case 0x0CC3:
return LMpost; // It can be proven that OTF fonts treat this as LMpost.
}
int ct = getCharType (u);
switch (ct)
{
case SD_INDIC_CONSONANT_BASE: return Cbase;
case SD_INDIC_CONSONANT_BELOW_BASE: return Cbelow;
case SD_INDIC_CONSONANT_POST_BASE: return Cpost;
case SD_INDIC_CONSONANT_DEAD: return Cdead;
case SD_INDIC_BOTTOM_VOWEL: return Mbelow;
case SD_INDIC_TOP_VOWEL: return Mabove;
case SD_INDIC_RIGHT_VOWEL: return Mpost;
case SD_INDIC_MODIFIER: return VMpost;
case SD_INDIC_SIGN: return SMabove;
case SD_INDIC_INDEP_VOWEL: return VO;
case SD_INDIC_LEFT_VOWEL: return Mpre;
case SD_INDIC_HALANT: return Halant;
case SD_INDIC_NUKTA: return Nukta;
case SD_INDIC_LEFT_RIGHT_VOWEL: return Vsplit;
}
/* khmm */
return Any;
}
/*!
* \brief Split the vowel into two parts.
* \param u is the input character
* \param left is the left-vowel output character
* \param right is the right-vowel output character
* \return true if the split has been successful.
*/
bool
SRendClass::split (SS_UCS4 u, SS_UCS4* left, SS_UCS4* right)
{
// Unfortunately not everything is LR.
switch (u)
{
case 0x0B48: // LEFT-TOP 4,6
*left = 0x0B47; *right = 0x0B56;
return true;
case 0x0C48: // TOP-BOTTOM 6,7
*left = 0x0C46; *right = 0x0C56;
return true;
case 0x0CC0: // TOP-RIGHT 6,5
*left = 0x0CBF; *right = 0x0CD5;
return true;
case 0x0CC7: // TOP-RIGHT 6,5
*left = 0x0CC6; *right = 0x0CD5;
return true;
case 0x0CC8: // TOP-RIGHT 6,5
*left = 0x0CC6; *right = 0x0CD6;
return true;
case 0x0CCA: // TOP-RIGHT 6,5
*left = 0x0CC6; *right = 0x0CC2;
return true;
case 0x0CCB: // TOP-RIGHT 6,5
*left = 0x0CCA; *right = 0x0CD5;
return true;
case 0x0D4B: // LEFT-RIGHT 4,5 - why did I leave this out?
*left = 0x0D47; *right = 0x0D3E;
return true;
// Tibetan:
case 0x0F43: // Any, Below
*left = 0x0F42; *right = 0x0FB7;
return true;
case 0x0F4D: // Any, Below
*left = 0x0F4C; *right = 0x0FB7;
return true;
case 0x0F52: // Any, Below
*left = 0x0F51; *right = 0x0FB7;
return true;
case 0x0F57: // Any, Below
*left = 0x0F56; *right = 0x0FB7;
return true;
case 0x0F5C: // Any, Below
*left = 0x0F5B; *right = 0x0FB7;
return true;
case 0x0F69: // Any, Below
*left = 0x0F40; *right = 0x0FB5;
return true;
case 0x0F73: // Below, Top
*left = 0x0F71; *right = 0x0F72;
return true;
case 0x0F75: // Below, Below
*left = 0x0F71; *right = 0x0F74;
return true;
case 0x0F76: // Below, Top
*left = 0x0FB2; *right = 0x0F80;
return true;
case 0x0F77: // Below, Further split - usage is discouraged.
*left = 0x0FB2; *right = 0x0F81;
return true;
case 0x0F78: // Below, Top
*left = 0x0FB3; *right = 0x0F80;
return true;
case 0x0F79: // Below, Further split - usage is discouraged.
*left = 0x0FB3; *right = 0x0F81;
return true;
case 0x0F81: // Below, Top
*left = 0x0F71; *right = 0x0F80;
return true;
case 0x0F93: // Below, Below
*left = 0x0F92; *right = 0x0FB7;
return true;
case 0x0F9D: // Below, Below
*left = 0x0F9C; *right = 0x0FB7;
return true;
case 0x0FA2: // Below, Below
*left = 0x0FA1; *right = 0x0FB7;
return true;
case 0x0FA7: // Below, Below
*left = 0x0FA6; *right = 0x0FB7;
return true;
case 0x0FAC: // Below, Below
*left = 0x0FAB; *right = 0x0FB7;
return true;
}
if (get (u) != Vsplit) return false;
*left = getLRVowelLeft (u);
*right = getLRVowelRight (u);
return true;
}
/*!
* \brief Convert type to a string.
* \return a string representing type.
*/
const char*
SRendClass::string (RType type)
{
switch (type)
{
case Cfirst: return "Cfirst";
case Clast: return "Clast";
case Cpre: return "Cpre";
case Cbase: return "Cbase";
case Chbase: return "Chbase";
case Cbelow: return "Cbelow";
case Cpost: return "Cpost";
case Cdead: return "Cdead";
case Cra: return "Cra";
case CMra: return "CMra";
case Mpre: return "Mpre";
case Mabove: return "Mabove";
case Mbelow: return "Mbelow";
case Mpost: return "Mpost";
case VMbelow: return "VMbelow";
case VMabove: return "VMabove";
case VMpost: return "VMpost";
case LMpost: return "LMpost";
case SMabove: return "SMabove";
case SMbelow: return "SMbelow";
case VO: return "VO";
case Nukta: return "Nukta";
case Halant: return "Halant";
case Vsplit: return "Vsplit";
case Creph: return "Creph";
case CMreph: return "CMreph";
case ZWJ: return "ZWJ";
case ZWNJ: return "ZWNJ";
case Any: return "Any";
case JamoL: return "JamoL";
case JamoV: return "JamoV";
case JamoT: return "JamoT";
default: break;
}
return "Unknown";
}
|