ReactOS 0.4.15-dev-7842-g558ab78
bidi.c File Reference
#include "ros_lpk.h"
Include dependency graph for bidi.c:

Go to the source code of this file.

Macros

#define odd(x)   ((x) & 1)
 

Enumerations

enum  directions {
  ON = 0 , L , R , AN ,
  EN , AL , NSM , CS ,
  ES , ET , BN , S ,
  WS , B , RLO , RLE ,
  LRO , LRE , PDF , LRI ,
  RLI , FSI , PDI , NI = ON ,
  ON = 0 , L , R , AN ,
  EN , AL , NSM , CS ,
  ES , ET , BN , S ,
  WS , B , RLO , RLE ,
  LRO , LRE , PDF , LRI ,
  RLI , FSI , PDI , NI = ON
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (bidi)
 
static unsigned short get_table_entry (const unsigned short *table, WCHAR ch)
 
static void classify (LPCWSTR lpString, WORD *chartype, DWORD uCount)
 
static void SetDeferredRun (BYTE *pval, int cval, int iStart, int nval)
 
static int resolveParagraphs (WORD *types, int cch)
 
static int resolveLines (LPCWSTR pszInput, const BOOL *pbrk, int cch)
 
static void resolveWhitespace (int baselevel, const WORD *pcls, BYTE *plevel, int cch)
 
static void BidiLines (int baselevel, LPWSTR pszOutLine, LPCWSTR pszLine, const WORD *pclsLine, BYTE *plevelLine, int cchPara, const BOOL *pbrk)
 
BOOL BIDI_Reorder (HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags, DWORD dwWineGCP_Flags, LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT *cGlyphs)
 

Variables

const unsigned short bidi_direction_table[] DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ odd

#define odd (   x)    ((x) & 1)

Definition at line 51 of file bidi.c.

Enumeration Type Documentation

◆ directions

Enumerator
ON 
AN 
EN 
AL 
NSM 
CS 
ES 
ET 
BN 
WS 
RLO 
RLE 
LRO 
LRE 
PDF 
LRI 
RLI 
FSI 
PDI 
NI 
ON 
AN 
EN 
AL 
NSM 
CS 
ES 
ET 
BN 
WS 
RLO 
RLE 
LRO 
LRE 
PDF 
LRI 
RLI 
FSI 
PDI 
NI 

Definition at line 66 of file bidi.c.

67{
68 /* input types */
69 /* ON MUST be zero, code relies on ON = N = 0 */
70 ON = 0, /* Other Neutral */
71 L, /* Left Letter */
72 R, /* Right Letter */
73 AN, /* Arabic Number */
74 EN, /* European Number */
75 AL, /* Arabic Letter (Right-to-left) */
76 NSM, /* Non-spacing Mark */
77 CS, /* Common Separator */
78 ES, /* European Separator */
79 ET, /* European Terminator (post/prefix e.g. $ and %) */
80
81 /* resolved types */
82 BN, /* Boundary neutral (type of RLE etc after explicit levels) */
83
84 /* input types, */
85 S, /* Segment Separator (TAB) // used only in L1 */
86 WS, /* White space // used only in L1 */
87 B, /* Paragraph Separator (aka as PS) */
88
89 /* types for explicit controls */
90 RLO, /* these are used only in X1-X9 */
91 RLE,
92 LRO,
93 LRE,
94 PDF,
95
96 LRI, /* Isolate formatting characters new with 6.3 */
97 RLI,
98 FSI,
99 PDI,
100
101 /* resolved types, also resolved directions */
102 NI = ON, /* alias, where ON, WS and S are treated the same */
103};
@ FSI
Definition: bidi.c:98
@ LRO
Definition: bidi.c:92
@ WS
Definition: bidi.c:86
@ EN
Definition: bidi.c:74
@ PDI
Definition: bidi.c:99
@ R
Definition: bidi.c:72
@ LRE
Definition: bidi.c:93
@ NI
Definition: bidi.c:102
@ RLE
Definition: bidi.c:91
@ B
Definition: bidi.c:87
@ ET
Definition: bidi.c:79
@ AN
Definition: bidi.c:73
@ RLI
Definition: bidi.c:97
@ ES
Definition: bidi.c:78
@ PDF
Definition: bidi.c:94
@ RLO
Definition: bidi.c:90
@ CS
Definition: bidi.c:77
@ ON
Definition: bidi.c:70
@ AL
Definition: bidi.c:75
@ LRI
Definition: bidi.c:96
@ BN
Definition: bidi.c:82
@ NSM
Definition: bidi.c:76
@ L
Definition: bidi.c:71
@ S
Definition: bidi.c:85

Function Documentation

◆ BIDI_Reorder()

BOOL BIDI_Reorder ( HDC  hDC,
LPCWSTR  lpString,
INT  uCount,
DWORD  dwFlags,
DWORD  dwWineGCP_Flags,
LPWSTR  lpOutString,
INT  uCountOut,
UINT lpOrder,
WORD **  lpGlyphs,
INT cGlyphs 
)

Definition at line 320 of file bidi.c.

332{
333 WORD *chartype;
334 BYTE *levels;
335 INT i, done;
336 unsigned glyph_i;
337 BOOL is_complex;
338
339 int maxItems;
340 int nItems;
344 HRESULT res;
346 WORD *run_glyphs = NULL;
348 SCRIPT_VISATTR *psva = NULL;
349 DWORD cMaxGlyphs = 0;
350 BOOL doGlyphs = TRUE;
351
352 TRACE("%s, %d, 0x%08x lpOutString=%p, lpOrder=%p\n",
353 debugstr_wn(lpString, uCount), uCount, dwFlags,
354 lpOutString, lpOrder);
355
356 memset(&Control, 0, sizeof(Control));
357 memset(&State, 0, sizeof(State));
358 if (lpGlyphs)
359 *lpGlyphs = NULL;
360
361 if (!(dwFlags & GCP_REORDER))
362 {
363 FIXME("Asked to reorder without reorder flag set\n");
364 return FALSE;
365 }
366
367 if (lpOutString && uCountOut < uCount)
368 {
369 FIXME("lpOutString too small\n");
370 return FALSE;
371 }
372
373 chartype = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WORD));
374 if (!chartype)
375 {
376 WARN("Out of memory\n");
377 return FALSE;
378 }
379
380 if (lpOutString)
381 memcpy(lpOutString, lpString, uCount * sizeof(WCHAR));
382
383 is_complex = FALSE;
384 for (i = 0; i < uCount && !is_complex; i++)
385 {
386 if ((lpString[i] >= 0x900 && lpString[i] <= 0xfff) ||
387 (lpString[i] >= 0x1cd0 && lpString[i] <= 0x1cff) ||
388 (lpString[i] >= 0xa840 && lpString[i] <= 0xa8ff))
389 is_complex = TRUE;
390 }
391
392 /* Verify reordering will be required */
393 if ((WINE_GCPW_FORCE_RTL == (dwWineGCP_Flags&WINE_GCPW_DIR_MASK)) ||
394 ((dwWineGCP_Flags&WINE_GCPW_DIR_MASK) == WINE_GCPW_LOOSE_RTL))
395 State.uBidiLevel = 1;
396 else if (!is_complex)
397 {
398 done = 1;
399 classify(lpString, chartype, uCount);
400 for (i = 0; i < uCount; i++)
401 switch (chartype[i])
402 {
403 case R:
404 case AL:
405 case RLE:
406 case RLO:
407 done = 0;
408 break;
409 }
410 if (done)
411 {
412 HeapFree(GetProcessHeap(), 0, chartype);
413 if (lpOrder)
414 {
415 for (i = 0; i < uCount; i++)
416 lpOrder[i] = i;
417 }
418 return TRUE;
419 }
420 }
421
422 levels = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(BYTE));
423 if (!levels)
424 {
425 WARN("Out of memory\n");
426 HeapFree(GetProcessHeap(), 0, chartype);
427 return FALSE;
428 }
429
430 maxItems = 5;
431 pItems = HeapAlloc(GetProcessHeap(),0, maxItems * sizeof(SCRIPT_ITEM));
432 if (!pItems)
433 {
434 WARN("Out of memory\n");
435 HeapFree(GetProcessHeap(), 0, chartype);
437 return FALSE;
438 }
439
440 if (lpGlyphs)
441 {
442#ifdef __REACTOS__
443 /* ReactOS r57677 and r57679 */
444 cMaxGlyphs = 3 * uCount / 2 + 16;
445#else
446 cMaxGlyphs = 1.5 * uCount + 16;
447#endif
448 run_glyphs = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * cMaxGlyphs);
449 if (!run_glyphs)
450 {
451 WARN("Out of memory\n");
452 HeapFree(GetProcessHeap(), 0, chartype);
455 return FALSE;
456 }
457 pwLogClust = HeapAlloc(GetProcessHeap(),0,sizeof(WORD) * uCount);
458 if (!pwLogClust)
459 {
460 WARN("Out of memory\n");
461 HeapFree(GetProcessHeap(), 0, chartype);
464 HeapFree(GetProcessHeap(), 0, run_glyphs);
465 return FALSE;
466 }
467 psva = HeapAlloc(GetProcessHeap(),0,sizeof(SCRIPT_VISATTR) * uCount);
468 if (!psva)
469 {
470 WARN("Out of memory\n");
471 HeapFree(GetProcessHeap(), 0, chartype);
474 HeapFree(GetProcessHeap(), 0, run_glyphs);
476 return FALSE;
477 }
478 }
479
480 done = 0;
481 glyph_i = 0;
482 while (done < uCount)
483 {
484 INT j;
485 classify(lpString + done, chartype, uCount - done);
486 /* limit text to first block */
487 i = resolveParagraphs(chartype, uCount - done);
488 for (j = 0; j < i; ++j)
489 switch(chartype[j])
490 {
491 case B:
492 case S:
493 case WS:
494 case ON: chartype[j] = NI;
495 default: continue;
496 }
497
498 if ((dwWineGCP_Flags&WINE_GCPW_DIR_MASK) == WINE_GCPW_LOOSE_RTL)
499 State.uBidiLevel = 1;
500 else if ((dwWineGCP_Flags&WINE_GCPW_DIR_MASK) == WINE_GCPW_LOOSE_LTR)
501 State.uBidiLevel = 0;
502
503 if (dwWineGCP_Flags & WINE_GCPW_LOOSE_MASK)
504 {
505 for (j = 0; j < i; ++j)
506 if (chartype[j] == L)
507 {
508 State.uBidiLevel = 0;
509 break;
510 }
511 else if (chartype[j] == R || chartype[j] == AL)
512 {
513 State.uBidiLevel = 1;
514 break;
515 }
516 }
517
518 res = ScriptItemize(lpString + done, i, maxItems, &Control, &State, pItems, &nItems);
519 while (res == E_OUTOFMEMORY)
520 {
521 maxItems = maxItems * 2;
522 pItems = HeapReAlloc(GetProcessHeap(), 0, pItems, sizeof(SCRIPT_ITEM) * maxItems);
523 if (!pItems)
524 {
525 WARN("Out of memory\n");
526 HeapFree(GetProcessHeap(), 0, chartype);
528 HeapFree(GetProcessHeap(), 0, run_glyphs);
530 HeapFree(GetProcessHeap(), 0, psva);
531 return FALSE;
532 }
533 res = ScriptItemize(lpString + done, i, maxItems, &Control, &State, pItems, &nItems);
534 }
535
536 if (lpOutString || lpOrder)
537 for (j = 0; j < nItems; j++)
538 {
539 int k;
540 for (k = pItems[j].iCharPos; k < pItems[j+1].iCharPos; k++)
541 levels[k] = pItems[j].a.s.uBidiLevel;
542 }
543
544 if (lpOutString)
545 {
546 /* assign directional types again, but for WS, S this time */
547 classify(lpString + done, chartype, i);
548
549 BidiLines(State.uBidiLevel, lpOutString + done, lpString + done,
550 chartype, levels, i, 0);
551 }
552
553 if (lpOrder)
554 {
555 int k, lastgood;
556 for (j = lastgood = 0; j < i; ++j)
557 if (levels[j] != levels[lastgood])
558 {
559 --j;
560 if (odd(levels[lastgood]))
561 for (k = j; k >= lastgood; --k)
562 lpOrder[done + k] = done + j - k;
563 else
564 for (k = lastgood; k <= j; ++k)
565 lpOrder[done + k] = done + k;
566 lastgood = ++j;
567 }
568 if (odd(levels[lastgood]))
569 for (k = j - 1; k >= lastgood; --k)
570 lpOrder[done + k] = done + j - 1 - k;
571 else
572 for (k = lastgood; k < j; ++k)
573 lpOrder[done + k] = done + k;
574 }
575
576 if (lpGlyphs && doGlyphs)
577 {
578 BYTE *runOrder;
579 int *visOrder;
580 SCRIPT_ITEM *curItem;
581
582 runOrder = HeapAlloc(GetProcessHeap(), 0, maxItems * sizeof(*runOrder));
583 visOrder = HeapAlloc(GetProcessHeap(), 0, maxItems * sizeof(*visOrder));
584 if (!runOrder || !visOrder)
585 {
586 WARN("Out of memory\n");
587 HeapFree(GetProcessHeap(), 0, runOrder);
588 HeapFree(GetProcessHeap(), 0, visOrder);
589 HeapFree(GetProcessHeap(), 0, chartype);
592 HeapFree(GetProcessHeap(), 0, psva);
594 return FALSE;
595 }
596
597 for (j = 0; j < nItems; j++)
598 runOrder[j] = pItems[j].a.s.uBidiLevel;
599
600 ScriptLayout(nItems, runOrder, visOrder, NULL);
601
602 for (j = 0; j < nItems; j++)
603 {
604 int k;
605 int cChars,cOutGlyphs;
606 curItem = &pItems[visOrder[j]];
607
608 cChars = pItems[visOrder[j]+1].iCharPos - curItem->iCharPos;
609
610 res = ScriptShape(hDC, &psc, lpString + done + curItem->iCharPos, cChars, cMaxGlyphs, &curItem->a, run_glyphs, pwLogClust, psva, &cOutGlyphs);
611 while (res == E_OUTOFMEMORY)
612 {
613 cMaxGlyphs *= 2;
614 run_glyphs = HeapReAlloc(GetProcessHeap(), 0, run_glyphs, sizeof(WORD) * cMaxGlyphs);
615 if (!run_glyphs)
616 {
617 WARN("Out of memory\n");
618 HeapFree(GetProcessHeap(), 0, runOrder);
619 HeapFree(GetProcessHeap(), 0, visOrder);
620 HeapFree(GetProcessHeap(), 0, chartype);
623 HeapFree(GetProcessHeap(), 0, psva);
625 HeapFree(GetProcessHeap(), 0, *lpGlyphs);
627 *lpGlyphs = NULL;
628 return FALSE;
629 }
630 res = ScriptShape(hDC, &psc, lpString + done + curItem->iCharPos, cChars, cMaxGlyphs, &curItem->a, run_glyphs, pwLogClust, psva, &cOutGlyphs);
631 }
632 if (res)
633 {
635 TRACE("Unable to shape with currently selected font\n");
636 else
637 FIXME("Unable to shape string (%x)\n",res);
638 j = nItems;
639 doGlyphs = FALSE;
640 HeapFree(GetProcessHeap(), 0, *lpGlyphs);
641 *lpGlyphs = NULL;
642 }
643 else
644 {
645 if (*lpGlyphs)
646 *lpGlyphs = HeapReAlloc(GetProcessHeap(), 0, *lpGlyphs, sizeof(WORD) * (glyph_i + cOutGlyphs));
647 else
648 *lpGlyphs = HeapAlloc(GetProcessHeap(), 0, sizeof(WORD) * (glyph_i + cOutGlyphs));
649 for (k = 0; k < cOutGlyphs; k++)
650 (*lpGlyphs)[glyph_i+k] = run_glyphs[k];
651 glyph_i += cOutGlyphs;
652 }
653 }
654 HeapFree(GetProcessHeap(), 0, runOrder);
655 HeapFree(GetProcessHeap(), 0, visOrder);
656 }
657
658 done += i;
659 }
660 if (cGlyphs)
661 *cGlyphs = glyph_i;
662
663 HeapFree(GetProcessHeap(), 0, chartype);
666 HeapFree(GetProcessHeap(), 0, run_glyphs);
668 HeapFree(GetProcessHeap(), 0, psva);
670 return TRUE;
671}
static HDC hDC
Definition: 3dtext.c:33
int nItems
Definition: appswitch.c:56
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
Definition: usp10.c:1080
HRESULT WINAPI ScriptItemize(const WCHAR *pwcInChars, int cInChars, int cMaxItems, const SCRIPT_CONTROL *psControl, const SCRIPT_STATE *psState, SCRIPT_ITEM *pItems, int *pcItems)
Definition: usp10.c:1853
HRESULT WINAPI ScriptShape(HDC hdc, SCRIPT_CACHE *psc, const WCHAR *pwcChars, int cChars, int cMaxGlyphs, SCRIPT_ANALYSIS *psa, WORD *pwOutGlyphs, WORD *pwLogClust, SCRIPT_VISATTR *psva, int *pcGlyphs)
Definition: usp10.c:3321
HRESULT WINAPI ScriptLayout(int runs, const BYTE *level, int *vistolog, int *logtovis)
Definition: usp10.c:3752
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint res
Definition: glext.h:9613
GLsizei levels
Definition: glext.h:7884
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define debugstr_wn
Definition: kernel32.h:33
static void BidiLines(int baselevel, LPWSTR pszOutLine, LPCWSTR pszLine, const WORD *pclsLine, BYTE *plevelLine, int cchPara, const BOOL *pbrk)
Definition: bidi.c:272
static int resolveParagraphs(WORD *types, int cch)
Definition: bidi.c:154
#define odd(x)
Definition: bidi.c:51
static void classify(LPCWSTR lpString, WORD *chartype, DWORD uCount)
Definition: bidi.c:113
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int cChars
Definition: usp10.c:64
static SCRIPT_CACHE * psc
Definition: usp10.c:64
static int int const SCRIPT_CONTROL const SCRIPT_STATE SCRIPT_ITEM * pItems
Definition: usp10.c:62
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int WORD * pwLogClust
Definition: usp10.c:64
static SCRIPT_CACHE SCRIPT_ANALYSIS OPENTYPE_TAG OPENTYPE_TAG int TEXTRANGE_PROPERTIES int const WCHAR int int cMaxGlyphs
Definition: usp10.c:64
int k
Definition: mpi.c:3369
#define WINE_GCPW_LOOSE_LTR
Definition: ros_lpk.h:90
#define WINE_GCPW_LOOSE_MASK
Definition: ros_lpk.h:93
#define WINE_GCPW_DIR_MASK
Definition: ros_lpk.h:92
#define WINE_GCPW_FORCE_RTL
Definition: ros_lpk.h:89
#define WINE_GCPW_LOOSE_RTL
Definition: ros_lpk.h:91
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
SCRIPT_ANALYSIS a
Definition: usp10.h:151
int iCharPos
Definition: usp10.h:150
int32_t INT
Definition: typedefs.h:58
#define USP_E_SCRIPT_NOT_IN_FONT
Definition: usp10.h:71
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ FONTOBJ _In_ ULONG _In_ ULONG cGlyphs
Definition: winddi.h:3799
#define GCP_REORDER
Definition: wingdi.h:843
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by LpkExtTextOut(), and LpkGetCharacterPlacement().

◆ BidiLines()

static void BidiLines ( int  baselevel,
LPWSTR  pszOutLine,
LPCWSTR  pszLine,
const WORD pclsLine,
BYTE plevelLine,
int  cchPara,
const BOOL pbrk 
)
static

Definition at line 272 of file bidi.c.

274{
275 int cchLine = 0;
276 int done = 0;
277 int *run;
278
279 run = HeapAlloc(GetProcessHeap(), 0, cchPara * sizeof(int));
280 if (!run)
281 {
282 WARN("Out of memory\n");
283 return;
284 }
285
286 do
287 {
288 /* break lines at LS */
289 cchLine = resolveLines(pszLine, pbrk, cchPara);
290
291 /* resolve whitespace */
292 resolveWhitespace(baselevel, pclsLine, plevelLine, cchLine);
293
294 if (pszOutLine)
295 {
296 int i;
297 /* reorder each line in place */
298 ScriptLayout(cchLine, plevelLine, NULL, run);
299 for (i = 0; i < cchLine; i++)
300 pszOutLine[done+run[i]] = pszLine[i];
301 }
302
303 pszLine += cchLine;
304 plevelLine += cchLine;
305 pbrk += pbrk ? cchLine : 0;
306 pclsLine += cchLine;
307 cchPara -= cchLine;
308 done += cchLine;
309
310 } while (cchPara);
311
312 HeapFree(GetProcessHeap(), 0, run);
313}
static void resolveWhitespace(int baselevel, const WORD *pcls, BYTE *plevel, int cch)
Definition: bidi.c:215
static int resolveLines(LPCWSTR pszInput, const BOOL *pbrk, int cch)
Definition: bidi.c:182

Referenced by BIDI_Reorder().

◆ classify()

static void classify ( LPCWSTR  lpString,
WORD chartype,
DWORD  uCount 
)
static

Definition at line 113 of file bidi.c.

114{
115 unsigned i;
116
117 for (i = 0; i < uCount; ++i)
118 chartype[i] = get_table_entry( bidi_direction_table, lpString[i] );
119}
static unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
Definition: bidi.c:107
const unsigned short DECLSPEC_HIDDEN DECLSPEC_HIDDEN bidi_direction_table[4512]
Definition: direction.c:6

Referenced by BIDI_DetermineLevels(), BIDI_GetStrengths(), and BIDI_Reorder().

◆ get_table_entry()

static unsigned short get_table_entry ( const unsigned short table,
WCHAR  ch 
)
inlinestatic

Definition at line 107 of file bidi.c.

108{
109 return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
110}

Referenced by classify(), and computeBracketPairs().

◆ resolveLines()

static int resolveLines ( LPCWSTR  pszInput,
const BOOL pbrk,
int  cch 
)
static

Definition at line 182 of file bidi.c.

183{
184 /* skip characters not of type LS */
185 int ich = 0;
186 for(; ich < cch; ich++)
187 {
188 if (pszInput[ich] == (WCHAR)'\n' || (pbrk && pbrk[ich]))
189 {
190 ich++;
191 break;
192 }
193 }
194
195 return ich;
196}
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202

Referenced by BidiLines().

◆ resolveParagraphs()

static int resolveParagraphs ( WORD types,
int  cch 
)
static

Definition at line 154 of file bidi.c.

155{
156 /* skip characters not of type B */
157 int ich = 0;
158 for(; ich < cch && types[ich] != B; ich++);
159 /* stop after first B, make it a BN for use in the next steps */
160 if (ich < cch && types[ich] == B)
161 types[ich++] = BN;
162 return ich;
163}
Definition: ehthrow.cxx:54
Definition: cmds.c:130

Referenced by BIDI_Reorder().

◆ resolveWhitespace()

static void resolveWhitespace ( int  baselevel,
const WORD pcls,
BYTE plevel,
int  cch 
)
static

Definition at line 215 of file bidi.c.

216{
217 int cchrun = 0;
218 BYTE oldlevel = baselevel;
219
220 int ich = 0;
221 for (; ich < cch; ich++)
222 {
223 switch(pcls[ich])
224 {
225 default:
226 cchrun = 0; /* any other character breaks the run */
227 break;
228 case WS:
229 cchrun++;
230 break;
231
232 case RLE:
233 case LRE:
234 case LRO:
235 case RLO:
236 case PDF:
237 case LRI:
238 case RLI:
239 case FSI:
240 case PDI:
241 case BN:
242 plevel[ich] = oldlevel;
243 cchrun++;
244 break;
245
246 case S:
247 case B:
248 /* reset levels for WS before eot */
249 SetDeferredRun(plevel, cchrun, ich, baselevel);
250 cchrun = 0;
251 plevel[ich] = baselevel;
252 break;
253 }
254 oldlevel = plevel[ich];
255 }
256 /* reset level before eot */
257 SetDeferredRun(plevel, cchrun, ich, baselevel);
258}
static void SetDeferredRun(BYTE *pval, int cval, int iStart, int nval)
Definition: bidi.c:123

Referenced by BidiLines().

◆ SetDeferredRun()

static void SetDeferredRun ( BYTE pval,
int  cval,
int  iStart,
int  nval 
)
static

Definition at line 123 of file bidi.c.

124{
125 int i = iStart - 1;
126 for (; i >= iStart - cval; i--)
127 {
128 pval[i] = nval;
129 }
130}
#define cval
Definition: fillbytes.c:26
_In_ UINT iStart
Definition: wingdi.h:3620

Referenced by resolveWhitespace().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( bidi  )

Variable Documentation

◆ DECLSPEC_HIDDEN

const unsigned short bidi_direction_table [] DECLSPEC_HIDDEN
extern

Definition at line 289 of file d3dcompiler_private.h.