Example #1
0
static void bidi_reverse_buf(unsigned int *str, int len)
{
    int i, len2 = len / 2;

    for (i = 0; i < len2; i++) {
        unsigned int tmp = str[i];
        str[i] = fribidi_get_mirror_char(str[len - 1 - i]);
        str[len - 1 - i] = fribidi_get_mirror_char(tmp);
    }
    /* do not forget central char! */
    if (len & 1) {
        str[len2] = fribidi_get_mirror_char(str[len2]);
    }
}
Example #2
0
FRIBIDI_ENTRY void
fribidi_shape_mirroring (
  /* input */
  const FriBidiLevel *embedding_levels,
  const FriBidiStrIndex len,
  /* input and output */
  FriBidiChar *str
)
{
  register FriBidiStrIndex i;

  DBG ("in fribidi_shape_mirroring");

  if UNLIKELY
    (len == 0 || !str) return;

  fribidi_assert (embedding_levels);

  /* L4. Mirror all characters that are in odd levels and have mirrors. */
  for (i = len - 1; i >= 0; i--)
    if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i]))
      {
	FriBidiChar mirrored_ch;

	if (fribidi_get_mirror_char (str[i], &mirrored_ch))
	  str[i] = mirrored_ch;
      }
}
fribidi_boolean
fribidi_char_set_enter_cap_rtl (void)
{
  if (!caprtl_to_unicode)
    {
      int request[FRIBIDI_TYPES_COUNT + 1];
      int i, count;

      caprtl_to_unicode =
	(FriBidiChar *) fribidi_malloc (NULL,
					CAPRTL_CHARS *
					sizeof caprtl_to_unicode[0]);
      for (i = 0; i < FRIBIDI_TYPES_COUNT; i++)
	request[i] = 0;
      for (i = 0; i < CAPRTL_CHARS; i++)
	if (fribidi_get_mirror_char (NULL, i, NULL))
	  caprtl_to_unicode[i] = i;
      for (count = 0, i = 0; i < CAPRTL_CHARS; i++)
	if (caprtl_to_unicode[i] == 0)
	  {
	    request[(unsigned char) CapRTLCharTypes[i]]++;
	    count++;
	  }
      for (i = 1; i < 0x10000 && count; i++)	/* Assign BMP chars to CapRTL entries */
	if (!fribidi_get_mirror_char (NULL, i, NULL))
	  {
	    int j, k;
	    for (j = 0; j < FRIBIDI_TYPES_COUNT; j++)
	      if (fribidi_prop_to_type[j] == fribidi_get_type_internal (i))
		break;
	    if (!request[j])	/* Do not need this type */
	      continue;
	    for (k = 0; k < CAPRTL_CHARS; k++)
	      if (!caprtl_to_unicode[k] && j == CapRTLCharTypes[k])
		break;
	    if (k < CAPRTL_CHARS)
	      {
		request[j]--;
		count--;
		caprtl_to_unicode[k] = i;
	      }
	  }
    }

  return FRIBIDI_TRUE;
}
Example #4
0
void ZLQtPaintContext::drawString(int x, int y, const char *str, int len, bool rtl) {
	if (rtl) {
		static ZLUnicodeUtil::Ucs2String ucs2Str;
		ucs2Str.clear();
		ZLUnicodeUtil::utf8ToUcs2(ucs2Str, str, len);
		QString qStr;
		FriBidiChar ch;
		for (int i = ucs2Str.size() - 1; i >= 0; --i) {
			fribidi_get_mirror_char(ucs2Str[i], &ch);
			qStr.append(QChar(ch));
		}
		myPainter->drawText(x, y, qStr);
	} else {
		QString qStr = QString::fromUtf8(str, len);
		myPainter->drawText(x, y, qStr);
	}
}
gboolean 
pangolite_get_mirror_char (gunichar ch, gunichar *mirrored_ch)
{
  return fribidi_get_mirror_char (ch, mirrored_ch); 
}
Example #6
0
static void
init_cap_rtl (
  void
)
{
  int request[_FRIBIDI_NUM_TYPES];
  FriBidiCharType to_type[_FRIBIDI_NUM_TYPES];
  int num_types = 0, count = 0;
  FriBidiCharType i;
  char mark[CAPRTL_CHARS];

  caprtl_to_unicode =
    (FriBidiChar *) fribidi_malloc (CAPRTL_CHARS *
				    sizeof caprtl_to_unicode[0]);
  for (i = 0; i < CAPRTL_CHARS; i++)
    if (CapRTLCharTypes[i] == fribidi_get_bidi_type (i))
      {
	caprtl_to_unicode[i] = i;
	mark[i] = 1;
      }
    else
      {
	int j;

	caprtl_to_unicode[i] = FRIBIDI_UNICODE_CHARS;
	mark[i] = 0;
	if (fribidi_get_mirror_char (i, NULL))
	  {
	    DBG ("warning: I could not map mirroring character map to itself in CapRTL");
	  }

	for (j = 0; j < num_types; j++)
	  if (to_type[j] == CapRTLCharTypes[i])
	    break;
	if (j == num_types)
	  {
	    num_types++;
	    to_type[j] = CapRTLCharTypes[i];
	    request[j] = 0;
	  }
	request[j]++;
	count++;
      }
  for (i = 0; i < 0x10000 && count; i++)	/* Assign BMP chars to CapRTL entries */
    if (!fribidi_get_mirror_char (i, NULL) && !(i < CAPRTL_CHARS && mark[i]))
      {
	int j, k;
	FriBidiCharType t = fribidi_get_bidi_type (i);
	for (j = 0; j < num_types; j++)
	  if (to_type[j] == t)
	    break;
	if (!request[j])	/* Do not need this type */
	  continue;
	for (k = 0; k < CAPRTL_CHARS; k++)
	  if (caprtl_to_unicode[k] == FRIBIDI_UNICODE_CHARS
	      && to_type[j] == CapRTLCharTypes[k])
	    {
	      request[j]--;
	      count--;
	      caprtl_to_unicode[k] = i;
	      break;
	    }
      }
  if (count)
    {
      int j;

      DBG ("warning: could not find a mapping for CapRTL to Unicode:");
      for (j = 0; j < num_types; j++)
	if (request[j])
	  {
	    DBG2 ("  need this type: %s", fribidi_get_bidi_type_name (to_type[j]));
	  }
    }
}