⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui__arabic.c

📁 图像系统uc_GUI
💻 C
📖 第 1 页 / 共 2 页
字号:
    return _aKeyInfo[CharIndex].Isolated;
  } else if ((!PrevAffectsJoining) && (NextAffectsJoining)) {
    Initial = _aKeyInfo[CharIndex].Initial;
    if (Initial) {
      return Initial;
    } else {
      return _aKeyInfo[CharIndex].Isolated;
    }
  } else if ((PrevAffectsJoining) && (NextAffectsJoining)) {
    Medial = _aKeyInfo[CharIndex].Medial;
    if (Medial) {
      return Medial;
    } else {
      return _aKeyInfo[CharIndex].Isolated;
    }
  } else if ((PrevAffectsJoining) && (!NextAffectsJoining)) {
    Final = _aKeyInfo[CharIndex].Final;
    if (Final) {
      return Final;
    } else {
      return _aKeyInfo[CharIndex].Isolated;
    }
  }
  return Char;
}

/*********************************************************************
*
*       GUI__GetLineDistXArabic
*/
int GUI__GetLineDistXArabic(const char GUI_UNI_PTR *s, int MaxNumChars) {
  int Dist;
  Dist = 0;
  if (s) {
    U16 Glyph, Char, PrevChar = 0, NextChar;
    int CharIsArabic, IgnoreNextCharacter = 0;
    #if GUI_COMPILER_SUPPORTS_FP
      if (GUI_Context.pAFont->pafEncode) {
        return GUI_Context.pAFont->pafEncode->pfGetLineDistX(s, MaxNumChars);
      }
    #endif
    while (--MaxNumChars >= 0) {
      if (!PrevChar) {
        Char     = GUI_UC__GetCharCodeInc(&s);
        if (Char) {
          NextChar = GUI_UC__GetCharCodeInc(&s);
        }
      } else {
        Char     = NextChar;
        if (Char) {
          NextChar = GUI_UC__GetCharCodeInc(&s);
        }
      }
      if (IgnoreNextCharacter) {
        IgnoreNextCharacter = 0;
      } else {
        if (Char != 0x20) {
          CharIsArabic = GUI__IsArabicCharacter(Char);
        }
        if (CharIsArabic) {
          Glyph = GUI__GetPresentationForm(Char, NextChar, PrevChar, &IgnoreNextCharacter);
        } else {
          Glyph = Char;
        }
        Dist += GUI_GetCharDistX(Glyph);
      }
      PrevChar = Char;
    }
  }
  return Dist;
}

/*********************************************************************
*
*       GUI__DispLineArabic
*/
void GUI__DispLineArabic(const char GUI_UNI_PTR * s, int MaxNumChars, const GUI_RECT * pRect) {
  if (GUI_Context.pClipRect_HL) {
    if (GUI_RectsIntersect(GUI_Context.pClipRect_HL, pRect) == 0) {
      return;
    }
  }
  #if GUI_COMPILER_SUPPORTS_FP
  if (GUI_Context.pAFont->pafEncode) {
    GUI_Context.pAFont->pafEncode->pfDispLine(s, MaxNumChars);
  } else {
  #else
  {
  #endif
    U16 Glyph, Char, PrevChar = 0, NextChar;
    int CharIsArabic, xPosArabicStart, IgnoreNextCharacter = 0, xSizeArabic;
    const char GUI_UNI_PTR * p;
    const char GUI_UNI_PTR * pNext;
    while (--MaxNumChars >= 0) {
      if (!PrevChar) {
        p        = s;
        Char     = GUI_UC__GetCharCodeInc(&s);
        if (Char) {
          pNext    = s;
          NextChar = GUI_UC__GetCharCodeInc(&s);
        }
      } else {
        p        = pNext;
        Char     = NextChar;
        if (Char) {
          pNext    = s;
          NextChar = GUI_UC__GetCharCodeInc(&s);
        }
      }
      if (IgnoreNextCharacter) {
        IgnoreNextCharacter = 0;
      } else {
        if (Char != 0x20) {
          CharIsArabic = GUI__IsArabicCharacter(Char);
        }
        if (CharIsArabic) {
          Glyph = GUI__GetPresentationForm(Char, NextChar, PrevChar, &IgnoreNextCharacter);
        } else {
          Glyph = Char;
        }
        if ((!GUI_MoveRTL) && (CharIsArabic)) {
          /* Set GUI_MoveRTL to 1 and adjust cursor to the right position */
          xSizeArabic = _GetStringDistXArabic(p, MaxNumChars + 1);
          xPosArabicStart = GUI_GetDispPosX() + xSizeArabic;
          GUI_GotoX(xPosArabicStart);
          GUI_MoveRTL = 1;
        } else if ((GUI_MoveRTL) && (!CharIsArabic)) {
          /* Set GUI_MoveRTL to 0 and adjust cursor to the right position */
          GUI_GotoX(xPosArabicStart);
          GUI_MoveRTL  = 0;
        }
        /* Please leave the following lines for test purpose */
        #if 0
          GUI_SetBkColorIndex(GUI_GetBkColorIndex() + 3);
          GUI_SetTextMode(GUI_TM_NORMAL);
        #endif
        GUI_Context.pAFont->pfDispChar(Glyph);
        if (GUI_pfDispCharStyle) {
          GUI_pfDispCharStyle(Glyph);
        }
      }
      PrevChar = Char;
    }
    GUI_MoveRTL = 0;
  }
}

/*********************************************************************
*
*       GUI__GetCursorPosXArabic
*/
int GUI__GetCursorPosXArabic(const char GUI_UNI_PTR * s, int Index, int MaxNumChars) {
  U16 Glyph, Char, PrevChar = 0, NextChar, Cnt = 0;
  int CharIsArabic, ArabicMode = 0, IgnoreNextCharacter = 0, xSizeArabic, CursorPosXArabic = 0, LigaturPosition;
  const char GUI_UNI_PTR * p;
  const char GUI_UNI_PTR * pNext;
  while (--MaxNumChars >= 0) {
    if (!PrevChar) {
      p        = s;
      Char     = GUI_UC__GetCharCodeInc(&s);
      if (Char) {
        pNext    = s;
        NextChar = GUI_UC__GetCharCodeInc(&s);
      }
    } else {
      p        = pNext;
      Char     = NextChar;
      if (Char) {
        pNext    = s;
        NextChar = GUI_UC__GetCharCodeInc(&s);
      }
    }
    if (IgnoreNextCharacter) {
      IgnoreNextCharacter = 0;
      if (Cnt == Index) {
        return LigaturPosition;
      }
    } else {
      if (Char != 0x20) {
        CharIsArabic = GUI__IsArabicCharacter(Char);
      }
      if (CharIsArabic) {
        Glyph = GUI__GetPresentationForm(Char, NextChar, PrevChar, &IgnoreNextCharacter);
      } else {
        Glyph = Char;
      }
      if ((!ArabicMode) && (CharIsArabic)) {
        /* Set GUI_MoveRTL to 1 and adjust cursor to the right position */
        xSizeArabic = _GetStringDistXArabic(p, MaxNumChars + 1);
        CursorPosXArabic += xSizeArabic;
        ArabicMode = 1;
      } else if ((ArabicMode) && (!CharIsArabic)) {
        /* Set GUI_MoveRTL to 0 and adjust cursor to the right position */
        CursorPosXArabic += xSizeArabic;
        ArabicMode  = 0;
      }
      if (Cnt >= Index) {
        break;
      }
      if (IgnoreNextCharacter) {
        LigaturPosition = CursorPosXArabic;
      }
      if (CharIsArabic) {
        CursorPosXArabic -= GUI_GetCharDistX(Glyph);
      } else {
        CursorPosXArabic += GUI_GetCharDistX(Glyph);
      }
    }
    Cnt++;
    PrevChar = Char;
  }
  return CursorPosXArabic;
}

/*********************************************************************
*
*       GUI__GetCursorPosCharArabic
*/
int GUI__GetCursorPosCharArabic(const char GUI_UNI_PTR * s, int x, int MaxNumChars) {
  U16 Glyph, Char, PrevChar = 0, NextChar, Cnt = 0, NumChars;
  int CharIsArabic, ArabicMode = 0, IgnoreNextCharacter = 0, xSizeArabic, CursorPosXArabic = 0, CharWidth, NewPosX;
  const char GUI_UNI_PTR * p;
  const char GUI_UNI_PTR * pNext;
  NumChars = MaxNumChars;
  while (--MaxNumChars >= 0) {
    if (!PrevChar) {
      p        = s;
      Char     = GUI_UC__GetCharCodeInc(&s);
      if (Char) {
        pNext    = s;
        NextChar = GUI_UC__GetCharCodeInc(&s);
      }
    } else {
      p        = pNext;
      Char     = NextChar;
      if (Char) {
        pNext    = s;
        NextChar = GUI_UC__GetCharCodeInc(&s);
      }
    }
    if (IgnoreNextCharacter) {
      IgnoreNextCharacter = 0;
    } else {
      if (Char != 0x20) {
        CharIsArabic = GUI__IsArabicCharacter(Char);
      }
      if (CharIsArabic) {
        Glyph = GUI__GetPresentationForm(Char, NextChar, PrevChar, &IgnoreNextCharacter);
      } else {
        Glyph = Char;
      }
      if ((!ArabicMode) && (CharIsArabic)) {
        /* Set GUI_MoveRTL to 1 and adjust cursor to the right position */
        xSizeArabic = _GetStringDistXArabic(p, MaxNumChars + 1);
        CursorPosXArabic += xSizeArabic;
        ArabicMode = 1;
      } else if ((ArabicMode) && (!CharIsArabic)) {
        /* Set GUI_MoveRTL to 0 and adjust cursor to the right position */
        CursorPosXArabic += xSizeArabic;
        ArabicMode  = 0;
      }
      CharWidth = GUI_GetCharDistX(Glyph);
      if (CharIsArabic) {
        NewPosX = CursorPosXArabic - CharWidth;
        if ((NewPosX <= x) && (CursorPosXArabic >= x)) {
          break;
        }
        CursorPosXArabic = NewPosX;
      } else {
        NewPosX = CursorPosXArabic + CharWidth;
        if ((NewPosX >= x) && (CursorPosXArabic <= x)) {
          break;
        }
        CursorPosXArabic = NewPosX;
      }
    }
    Cnt++;
    PrevChar = Char;
  }
  if (Cnt >= NumChars) {
    Cnt = NumChars - 1;
  }
  return Cnt;
}

#else

void GUI__Arabic_c(void);
void GUI__Arabic_c(void) { } /* avoid empty object files */

#endif

/*************************** End of file ****************************/
	 	 			 		    	 				 	  			   	 	 	 	 	 	  	  	      	   		 	 	 		  		  	 		 	  	  			     			       	   	 			  		    	 	     	 				  	 					 	 			   	  	  			 				 		 	 	 			     			 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -