Qt 4.8
Classes | Enumerations | Functions | Variables
qtextengine_mac.cpp File Reference
#include "qtextengine_p.h"
#include <private/qfontengine_coretext_p.h>
#include <private/qfontengine_mac_p.h>

Go to the source code of this file.

Classes

struct  JoiningPair
 
struct  QArabicProperties
 

Enumerations

enum  ArabicGroup {
  ArabicNone, ArabicSpace, Transparent, Center,
  Kashida, Beh, Noon, Meem = Noon,
  Heh = Noon, KnottedHeh = Noon, HehGoal = Noon, SwashKaf = Noon,
  Yeh, Hah, Seen, Sad = Seen,
  Tah, Kaf = Tah, Gaf = Tah, Lam = Tah,
  Ain, Feh = Ain, Qaf = Ain, Alef,
  Waw, Dal, TehMarbuta = Dal, Reh,
  HamzaOnHehGoal, YehWithTail = HamzaOnHehGoal, YehBarre = HamzaOnHehGoal, Beth = Beh,
  Gamal = Ain, Heth = Noon, Teth = Hah, Yudh = Noon,
  Kaph = Noon, Lamadh = Lam, Mim = Noon, Nun = Noon,
  Semakh = Noon, FinalSemakh = Noon, SyriacE = Ain, Pe = Ain,
  ReversedPe = Hah, Qaph = Noon, Shin = Noon, Fe = Ain,
  Alaph = Alef, Dalath = Dal, He = Dal, SyriacWaw = Waw,
  Zain = Alef, YudhHe = Waw, Sadhe = HamzaOnHehGoal, Taw = Dal,
  Dummy = HamzaOnHehGoal, ArabicGroupsEnd
}
 
enum  Joining {
  JNone, JCausing, JDual, JRight,
  JTransparent
}
 
enum  QArabicShape {
  XIsolated, XFinal, XInitial, XMedial,
  XCausing
}
 

Functions

static ArabicGroup arabicGroup (unsigned short uc)
 
static void heuristicSetGlyphAttributes (const QChar *uc, int length, QGlyphLayout *glyphs, unsigned short *logClusters, int num_glyphs)
 
 Q_DECLARE_TYPEINFO (QArabicProperties, Q_PRIMITIVE_TYPE)
 
void qt_getArabicProperties (const unsigned short *chars, int len, QArabicProperties *properties)
 

Variables

static const unsigned char arabic_group [0x150]
 
static const Joining joining_for_group [ArabicGroupsEnd]
 
static const JoiningPair joining_table [5][4]
 

Enumeration Type Documentation

◆ ArabicGroup

Enumerator
ArabicNone 
ArabicSpace 
Transparent 
Center 
Kashida 
Beh 
Noon 
Meem 
Heh 
KnottedHeh 
HehGoal 
SwashKaf 
Yeh 
Hah 
Seen 
Sad 
Tah 
Kaf 
Gaf 
Lam 
Ain 
Feh 
Qaf 
Alef 
Waw 
Dal 
TehMarbuta 
Reh 
HamzaOnHehGoal 
YehWithTail 
YehBarre 
Beth 
Gamal 
Heth 
Teth 
Yudh 
Kaph 
Lamadh 
Mim 
Nun 
Semakh 
FinalSemakh 
SyriacE 
Pe 
ReversedPe 
Qaph 
Shin 
Fe 
Alaph 
Dalath 
He 
SyriacWaw 
Zain 
YudhHe 
Sadhe 
Taw 
Dummy 
ArabicGroupsEnd 

Definition at line 122 of file qtextengine_mac.cpp.

122  {
123  // NonJoining
124  ArabicNone,
125  ArabicSpace,
126  // Transparent
127  Transparent,
128  // Causing
129  Center,
130  Kashida,
131 
132  // Arabic
133  // Dual
134  Beh,
135  Noon,
136  Meem = Noon,
137  Heh = Noon,
138  KnottedHeh = Noon,
139  HehGoal = Noon,
140  SwashKaf = Noon,
141  Yeh,
142  Hah,
143  Seen,
144  Sad = Seen,
145  Tah,
146  Kaf = Tah,
147  Gaf = Tah,
148  Lam = Tah,
149  Ain,
150  Feh = Ain,
151  Qaf = Ain,
152  // Right
153  Alef,
154  Waw,
155  Dal,
156  TehMarbuta = Dal,
157  Reh,
161 
162  // Syriac
163  // Dual
164  Beth = Beh,
165  Gamal = Ain,
166  Heth = Noon,
167  Teth = Hah,
168  Yudh = Noon,
169  Kaph = Noon,
170  Lamadh = Lam,
171  Mim = Noon,
172  Nun = Noon,
173  Semakh = Noon,
174  FinalSemakh = Noon,
175  SyriacE = Ain,
176  Pe = Ain,
177  ReversedPe = Hah,
178  Qaph = Noon,
179  Shin = Noon,
180  Fe = Ain,
181 
182  // Right
183  Alaph = Alef,
184  Dalath = Dal,
185  He = Dal,
186  SyriacWaw = Waw,
187  Zain = Alef,
188  YudhHe = Waw,
190  Taw = Dal,
191 
192  // Compiler bug? Otherwise ArabicGroupsEnd would be equal to Dal + 1.
195 };

◆ Joining

enum Joining
Enumerator
JNone 
JCausing 
JDual 
JRight 
JTransparent 

Definition at line 354 of file qtextengine_mac.cpp.

◆ QArabicShape

Enumerator
XIsolated 
XFinal 
XInitial 
XMedial 
XCausing 

Definition at line 106 of file qtextengine_mac.cpp.

106  {
107  XIsolated,
108  XFinal,
109  XInitial,
110  XMedial,
111  // intermediate state
112  XCausing
113 };

Function Documentation

◆ arabicGroup()

static ArabicGroup arabicGroup ( unsigned short  uc)
inlinestatic

Definition at line 308 of file qtextengine_mac.cpp.

Referenced by qt_getArabicProperties().

309 {
310  if (uc >= 0x0600 && uc < 0x750)
311  return (ArabicGroup) arabic_group[uc-0x600];
312  else if (uc == 0x200d)
313  return Center;
314  else if (QChar::category(uc) == QChar::Separator_Space)
315  return ArabicSpace;
316  else
317  return ArabicNone;
318 }
static const unsigned char arabic_group[0x150]
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
ArabicGroup

◆ heuristicSetGlyphAttributes()

static void heuristicSetGlyphAttributes ( const QChar uc,
int  length,
QGlyphLayout glyphs,
unsigned short *  logClusters,
int  num_glyphs 
)
static

Definition at line 52 of file qtextengine_mac.cpp.

Referenced by QTextEngine::shapeTextMac().

53 {
54  // ### zeroWidth and justification are missing here!!!!!
55 
56  Q_UNUSED(num_glyphs);
57 
58 // qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item->num_glyphs);
59 
60  const bool symbolFont = false; // ####
61  glyphs->attributes[0].mark = false;
62  glyphs->attributes[0].clusterStart = true;
63  glyphs->attributes[0].dontPrint = (!symbolFont && uc[0].unicode() == 0x00ad) || qIsControlChar(uc[0].unicode());
64 
65  int pos = 0;
66  int lastCat = QChar::category(uc[0].unicode());
67  for (int i = 1; i < length; ++i) {
68  if (logClusters[i] == pos)
69  // same glyph
70  continue;
71  ++pos;
72  while (pos < logClusters[i]) {
73  ++pos;
74  }
75  // hide soft-hyphens by default
76  if ((!symbolFont && uc[i].unicode() == 0x00ad) || qIsControlChar(uc[i].unicode()))
77  glyphs->attributes[pos].dontPrint = true;
78  const QUnicodeTables::Properties *prop = QUnicodeTables::properties(uc[i].unicode());
79  int cat = prop->category;
80 
81  // one gets an inter character justification point if the current char is not a non spacing mark.
82  // as then the current char belongs to the last one and one gets a space justification point
83  // after the space char.
84  if (lastCat == QChar::Separator_Space)
85  glyphs->attributes[pos-1].justification = HB_Space;
86  else if (cat != QChar::Mark_NonSpacing)
87  glyphs->attributes[pos-1].justification = HB_Character;
88  else
89  glyphs->attributes[pos-1].justification = HB_NoJustification;
90 
91  lastCat = cat;
92  }
93  pos = logClusters[length-1];
94  if (lastCat == QChar::Separator_Space)
95  glyphs->attributes[pos].justification = HB_Space;
96  else
97  glyphs->attributes[pos].justification = HB_Character;
98 }
bool qIsControlChar(ushort uc)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
HB_GlyphAttributes * attributes
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Q_CORE_EXPORT const Properties *QT_FASTCALL properties(uint ucs4)

◆ Q_DECLARE_TYPEINFO()

Q_DECLARE_TYPEINFO ( QArabicProperties  ,
Q_PRIMITIVE_TYPE   
)

◆ qt_getArabicProperties()

void qt_getArabicProperties ( const unsigned short *  chars,
int  len,
QArabicProperties properties 
)

Definition at line 446 of file qtextengine_mac.cpp.

Referenced by QTextEngine::shapeTextMac().

447 {
448 // qDebug("arabicSyriacOpenTypeShape: properties:");
449  int lastPos = 0;
450  int lastGroup = ArabicNone;
451 
452  ArabicGroup group = arabicGroup(chars[0]);
453  Joining j = joining_for_group[group];
455  properties[0].justification = HB_NoJustification;
456 
457  for (int i = 1; i < len; ++i) {
458  // #### fix handling for spaces and punktuation
459  properties[i].justification = HB_NoJustification;
460 
461  group = arabicGroup(chars[i]);
462  j = joining_for_group[group];
463 
464  if (j == JTransparent) {
465  properties[i].shape = XIsolated;
466  continue;
467  }
468 
469  properties[lastPos].shape = joining_table[shape][j].form1;
470  shape = joining_table[shape][j].form2;
471 
472  switch(lastGroup) {
473  case Seen:
474  if (properties[lastPos].shape == XInitial || properties[lastPos].shape == XMedial)
475  properties[i-1].justification = HB_Arabic_Seen;
476  break;
477  case Hah:
478  if (properties[lastPos].shape == XFinal)
479  properties[lastPos-1].justification = HB_Arabic_HaaDal;
480  break;
481  case Alef:
482  if (properties[lastPos].shape == XFinal)
483  properties[lastPos-1].justification = HB_Arabic_Alef;
484  break;
485  case Ain:
486  if (properties[lastPos].shape == XFinal)
487  properties[lastPos-1].justification = HB_Arabic_Waw;
488  break;
489  case Noon:
490  if (properties[lastPos].shape == XFinal)
491  properties[lastPos-1].justification = HB_Arabic_Normal;
492  break;
493  case ArabicNone:
494  break;
495 
496  default:
497  Q_ASSERT(false);
498  }
499 
500  lastGroup = ArabicNone;
501 
502  switch(group) {
503  case ArabicNone:
504  case Transparent:
505  // ### Center should probably be treated as transparent when it comes to justification.
506  case Center:
507  break;
508  case ArabicSpace:
509  properties[i].justification = HB_Arabic_Space;
510  break;
511  case Kashida:
512  properties[i].justification = HB_Arabic_Kashida;
513  break;
514  case Seen:
515  lastGroup = Seen;
516  break;
517 
518  case Hah:
519  case Dal:
520  lastGroup = Hah;
521  break;
522 
523  case Alef:
524  case Tah:
525  lastGroup = Alef;
526  break;
527 
528  case Yeh:
529  case Reh:
530  if (properties[lastPos].shape == XMedial && arabicGroup(chars[lastPos]) == Beh)
531  properties[lastPos-1].justification = HB_Arabic_BaRa;
532  break;
533 
534  case Ain:
535  case Waw:
536  lastGroup = Ain;
537  break;
538 
539  case Noon:
540  case Beh:
541  case HamzaOnHehGoal:
542  lastGroup = Noon;
543  break;
544  case ArabicGroupsEnd:
545  Q_ASSERT(false);
546  }
547 
548  lastPos = i;
549  }
550  properties[lastPos].shape = joining_table[shape][JNone].form1;
551 
552 
553 // for (int i = 0; i < len; ++i)
554 // qDebug("arabic properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);
555 }
QArabicShape form2
unsigned char justification
static ArabicGroup arabicGroup(unsigned short uc)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static const JoiningPair joining_table[5][4]
static const Joining joining_for_group[ArabicGroupsEnd]
QArabicShape form1
QArabicShape
ArabicGroup

Variable Documentation

◆ arabic_group

const unsigned char arabic_group[0x150]
static

Definition at line 197 of file qtextengine_mac.cpp.

Referenced by arabicGroup().

◆ joining_for_group

const Joining joining_for_group[ArabicGroupsEnd]
static

◆ joining_table

const JoiningPair joining_table[5][4]
static
Initial value:
=
{
{ { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XInitial }, { XIsolated, XIsolated } },
{ { XFinal, XIsolated }, { XFinal, XCausing }, { XFinal, XInitial }, { XFinal, XIsolated } },
{ { XIsolated, XIsolated }, { XInitial, XCausing }, { XInitial, XMedial }, { XInitial, XFinal } },
{ { XFinal, XIsolated }, { XMedial, XCausing }, { XMedial, XMedial }, { XMedial, XFinal } },
{ { XIsolated, XIsolated }, { XIsolated, XCausing }, { XIsolated, XMedial }, { XIsolated, XFinal } },
}

Definition at line 393 of file qtextengine_mac.cpp.