NS_IMETHODIMP nsRenderingContextPh :: DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord* aSpacing) { #if 0  char buffer[aLength*3]; int i,x;  for(i=0,x=0; i<aLength*2; i++) { if (*(aString+i) != NULL) buffer[x++] = *(aString+i); }  buffer[x] = NULL; #endif  #if 0 nscoord X0 = aX; nscoord Y0 = aY;  mTMatrix->TransformCoord(&X0,&Y0);  PhPoint_t pos = { X0, Y0 };  PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawString2 aString=<%s> of %d at (%d,%d) aSpacing=<%p>\n", (char *) buffer, aLength, pos.x, pos.y, aSpacing));  PgDrawTextChars( (char *) aString, aLength, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP));  return NS_OK; #endif  #if 0 PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawString2 first aString=<%s> of %d at (%d,%d) aSpacing=<%p>.\n",aString, aLength, aX, aY, aSpacing));  nscoord x = aX; nscoord y = aY;  if (nsnull != aSpacing) {  const PRUnichar* end = aString + aLength; while (aString < end) { unsigned char ch[2]; memcpy(ch, aString++,2); unsigned char tmp; tmp=ch[0]; ch[0]=ch[1]; ch[1]=tmp; nscoord xx = x; nscoord yy = y; mTMatrix->TransformCoord(&xx, &yy); PhPoint_t pos = { xx, yy }; PgDrawText( (char *) ch, 1, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP)); x += *aSpacing++; } } else { mTMatrix->TransformCoord(&x,&y); PhPoint_t pos = { x, y };  PgDrawText( (char *) aString, aLength, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP)); }  return NS_OK;  #endif  #if 1 const int BUFFER_SIZE = (aLength * 3); char buffer[BUFFER_SIZE]; int len;  len = wcstombs(buffer, (wchar_t *) aString, BUFFER_SIZE); return DrawString( (char *) buffer, aLength, aX, aY, aSpacing); #endif }
NS_IMETHODIMP DrawString(const nsString& aString, nscoord aX, nscoord aY, PRInt32 aFontID, const nscoord* aSpacing) { NS_ConvertUCS2toUTF8 theUnicodeString( aString.get(), aString.Length() ); const char *p = theUnicodeString.get(); return DrawString( p, strlen( p ), aX, aY, aSpacing ); }
NS_IMETHODIMP nsRenderingContextPh :: DrawString(const PRUnichar *aString, PRUint32 aLength,                                                  nscoord aX, nscoord aY,                                                  PRInt32 aFontID,                                                  const nscoord* aSpacing){#if 0  /* DEBUG!! */  char buffer[aLength*3];  int i,x;  for(i=0,x=0; i<aLength*2; i++)  {    if (*(aString+i) != NULL)	  buffer[x++] = *(aString+i);  }    buffer[x] = NULL;#endif#if 0  nscoord X0 = aX;  nscoord Y0 = aY;  mTMatrix->TransformCoord(&X0,&Y0);   PhPoint_t pos = { X0, Y0 };  PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawString2 aString=<%s> of %d at (%d,%d) aSpacing=<%p>\n", (char *) buffer, aLength, pos.x, pos.y, aSpacing));  PgDrawTextChars( (char *) aString, aLength, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP));    return NS_OK;#endif#if 0  PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawString2 first aString=<%s> of %d at (%d,%d) aSpacing=<%p>.\n",aString, aLength, aX, aY, aSpacing));  nscoord x = aX;  nscoord y = aY;  if (nsnull != aSpacing)  {    // Render the string, one character at a time...    const PRUnichar* end = aString + aLength;	while (aString < end)	{      unsigned char ch[2];	  memcpy(ch, aString++,2);	  unsigned char tmp;	  tmp=ch[0];	  ch[0]=ch[1];	  ch[1]=tmp;	  nscoord xx = x;	  nscoord yy = y;	  mTMatrix->TransformCoord(&xx, &yy);      PhPoint_t pos = { xx, yy };      PgDrawText( (char *) ch, 1, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP));      x += *aSpacing++;    }  }  else  {    mTMatrix->TransformCoord(&x,&y);    PhPoint_t pos = { x, y };    PgDrawText( (char *) aString, aLength, &pos, (Pg_TEXT_WIDECHAR | Pg_TEXT_LEFT | Pg_TEXT_TOP));  }  return NS_OK;#endif#if 1  const int BUFFER_SIZE = (aLength * 3);  char buffer[BUFFER_SIZE];  int len;    len = wcstombs(buffer, (wchar_t *) aString, BUFFER_SIZE);  return DrawString( (char *) buffer, aLength, aX, aY, aSpacing);#endif}