📄 string.c
字号:
//
break;
}
}
}
//
// Otherwise, the font is compressed with a pixel RLE scheme.
//
else
{
//
// See if this is a byte that encodes some on and off pixels.
//
if(pucData[lIdx])
{
//
// Extract the number of off pixels.
//
lOff = (pucData[lIdx] >> 4) & 15;
//
// Extract the number of on pixels.
//
lOn = pucData[lIdx] & 15;
//
// Skip past this encoded byte.
//
lIdx++;
}
//
// Otherwise, see if this is a repeated on pixel byte.
//
else if(pucData[lIdx + 1] & 0x80)
{
//
// There are no off pixels in this encoding.
//
lOff = 0;
//
// Extract the number of on pixels.
//
lOn = (pucData[lIdx + 1] & 0x7f) * 8;
//
// Skip past these two encoded bytes.
//
lIdx += 2;
}
//
// Otherwise, this is a repeated off pixel byte.
//
else
{
//
// Extract the number of off pixels.
//
lOff = pucData[lIdx + 1] * 8;
//
// There are no on pixels in this encoding.
//
lOn = 0;
//
// Skip past these two encoded bytes.
//
lIdx += 2;
}
}
//
// Loop while there are any off pixels.
//
while(lOff)
{
//
// See if the bottom of the clipping region has been exceeded.
//
if((lY + lY0) > sCon.sClipRegion.sYMax)
{
//
// Ignore the remainder of the on pixels.
//
break;
}
//
// See if there is more than one on pixel that will fit onto
// the current row.
//
if((lOff > 1) && ((lX0 + 1) < pucData[1]))
{
//
// Determine the number of on pixels that will fit on this
// row.
//
lCount = (((lX0 + lOff) > pucData[1]) ? pucData[1] - lX0 :
lOff);
//
// If this row is within the clipping region, draw a
// horizontal line that corresponds to the sequence of on
// pixels.
//
if(((lY + lY0) >= sCon.sClipRegion.sYMin) && bOpaque)
{
sCon.ulForeground = pContext->ulBackground;
GrLineDrawH(&sCon, lX + lX0, lX + lX0 + lCount - 1,
lY + lY0);
}
//
// Decrement the count of on pixels by the number on this
// row.
//
lOff -= lCount;
//
// Increment the X offset by the number of on pixels.
//
lX0 += lCount;
}
//
// Otherwise, there is only a single on pixel that can be
// drawn.
//
else
{
//
// If this pixel is within the clipping region, then draw
// it.
//
if(((lX + lX0) >= sCon.sClipRegion.sXMin) &&
((lX + lX0) <= sCon.sClipRegion.sXMax) &&
((lY + lY0) >= sCon.sClipRegion.sYMin) && bOpaque)
{
DpyPixelDraw(pContext->pDisplay, lX + lX0, lY + lY0,
pContext->ulBackground);
}
//
// Decrement the count of on pixels.
//
lOff--;
//
// Increment the X offset.
//
lX0++;
}
//
// See if the X offset has reached the right side of the
// character glyph.
//
if(lX0 == pucData[1])
{
//
// Increment the Y offset.
//
lY0++;
//
// Reset the X offset to the left side of the character
// glyph.
//
lX0 = 0;
}
}
//
// Loop while there are any on pixels.
//
while(lOn)
{
//
// See if the bottom of the clipping region has been exceeded.
//
if((lY + lY0) > sCon.sClipRegion.sYMax)
{
//
// Ignore the remainder of the on pixels.
//
break;
}
//
// See if there is more than one on pixel that will fit onto
// the current row.
//
if((lOn > 1) && ((lX0 + 1) < pucData[1]))
{
//
// Determine the number of on pixels that will fit on this
// row.
//
lCount = (((lX0 + lOn) > pucData[1]) ? pucData[1] - lX0 :
lOn);
//
// If this row is within the clipping region, draw a
// horizontal line that corresponds to the sequence of on
// pixels.
//
if((lY + lY0) >= sCon.sClipRegion.sYMin)
{
sCon.ulForeground = pContext->ulForeground;
GrLineDrawH(&sCon, lX + lX0, lX + lX0 + lCount - 1,
lY + lY0);
}
//
// Decrement the count of on pixels by the number on this
// row.
//
lOn -= lCount;
//
// Increment the X offset by the number of on pixels.
//
lX0 += lCount;
}
//
// Otherwise, there is only a single on pixel that can be
// drawn.
//
else
{
//
// If this pixel is within the clipping region, then draw
// it.
//
if(((lX + lX0) >= sCon.sClipRegion.sXMin) &&
((lX + lX0) <= sCon.sClipRegion.sXMax) &&
((lY + lY0) >= sCon.sClipRegion.sYMin))
{
DpyPixelDraw(pContext->pDisplay, lX + lX0, lY + lY0,
pContext->ulForeground);
}
//
// Decrement the count of on pixels.
//
lOn--;
//
// Increment the X offset.
//
lX0++;
}
//
// See if the X offset has reached the right side of the
// character glyph.
//
if(lX0 == pucData[1])
{
//
// Increment the Y offset.
//
lY0++;
//
// Reset the X offset to the left side of the character
// glyph.
//
lX0 = 0;
}
}
}
//
// Increment the X coordinate by the width of the character.
//
lX += pucData[1];
}
}
//*****************************************************************************
//
// Definitions and variables used by the decompression routine for the string
// table.
//
//*****************************************************************************
#define SC_MAX_INDEX 2047
#define SC_IS_NULL 0x0000ffff
#define SC_GET_LEN(v) ((v) >> (32 - 5))
#define SC_GET_INDEX(v) (((v) >> 16) & SC_MAX_INDEX)
#define SC_GET_OFF(v) ((v) & SC_IS_NULL)
#define SC_FLAG_COMPRESSED 0x00008000
#define SC_OFFSET_M 0x00007fff
//*****************************************************************************
//
// The globals that hold the shortcuts to various locations and values in the
// table.
//
//*****************************************************************************
static const unsigned long *g_pulStringTable;
static const unsigned short *g_pusLanguageTable;
static const unsigned char *g_pucStringData;
static unsigned short g_usLanguage;
static unsigned short g_usNumLanguages;
static unsigned short g_usNumStrings;
//*****************************************************************************
//
//! This function sets the location of the current string table.
//!
//! \param pvTable is a pointer to a string table that was generated by the
//! string compression utility.
//!
//! This function is used to set the string table to use for strings in an
//! application. This string table is created by the string compression
//! utility. This function is used to swap out multiple string tables if the
//! application requires more than one table. It does not allow using more
//! than one string table at a time.
//!
//! \return None.
//
//*****************************************************************************
void
GrStringTableSet(const void *pvTable)
{
//
// Save the number of languages and number of strings.
//
g_usNumStrings = ((unsigned short *)pvTable)[0];
g_usNumLanguages = ((unsigned short *)pvTable)[1];
//
// Save a pointer to the Language Identifier table.
//
g_pusLanguageTable = (unsigned short *)pvTable + 2;
//
// Save a pointer to the String Index table.
//
g_pulStringTable = (unsigned long *)(g_pusLanguageTable +
g_usNumLanguages);
//
// Save a pointer to the String Data.
//
g_pucStringData = (unsigned char *)(g_pulStringTable +
(g_usNumStrings * g_usNumLanguages));
}
//*****************************************************************************
//
//! This function sets the current language for strings returned by the
//! GrStringGet() function.
//!
//! \param usLangID is one of the language identifiers provided in the string
//! table.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -