立即注册
查看: 2245|回复: 0

[原创] mt2503 [Vector Font]使用矢量字体时VKV1显示'口'或死机

发表于 2017-10-18 15:00:00 | 显示全部楼层 |阅读模式 来自 广东省深圳市
[DESCRIPTION]
之前设计VKV1时,矢量字的使用并不普遍,因而当时没有考虑到兼容矢量字的情况;引入矢量字后VK也更新到了VKV2,没有对VKV1进行兼容性升级
,因此导致了在11B1308MP之前的软件版本中存在这个遗留问题。

[SOLUTION]
把PixcomFontEngine.c中函数Get_CharBoundingBox替换成如下即可。
void Get_CharBoundingBox(
U32 Ch,
S32 *pCharWidth,
S32 *pCharHeight,
S32 *pBoxXoffset,
S32 *pBoxYoffset,
S32 *pBoxWidth,
S32 *pBoxHeight)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U32 data_attr = 1;
U16 data_height;
U16 data_width;
#if !defined(__MMI_VECTOR_FONT_SUPPORT__)
S32 fx1, fy1, fx2, fy2, x, y;
U8 *font_data;
U32 font_data_size;
S32 char_width;
S32 ascent = 0, descent = 0;
S32 dwidth;
S32 bearing_x;
MMI_BOOL valid;
#endif
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
GDI_LOCK;
FE_LOCK;
#ifdef __MMI_VECTOR_FONT_SUPPORT__
{
mmi_lm_cluster_info cluster = {0}, prev_cluster = {0}, prev2_cluster = {0};
cluster.data_ptr = (U8 *)&Ch;
mmi_lm_get_current_cluster(cluster.data_ptr, cluster.data_ptr, &prev2_cluster, &prev_cluster, &cluster);
data_width = cluster.w;
data_height = cluster.h;
}
#else
{
font_data_size = mmi_fe_get_font_data(
MMI_FALSE,
(U16) Ch,
&font_data,
&data_attr,
&char_width,
&dwidth,
&data_width,
&data_height,
&bearing_x,
&ascent,
&descent,
&valid);
}
#endif
FE_UNLOCK;
GDI_UNLOCK;
#if defined(__MMI_BDF_SW_COMPRESSION__) && !defined(__MMI_VECTOR_FONT_SUPPORT__)
{
int i = 0, j = 0, nIndex = 0;
unsigned __int64 nCurrent = 0, nMask = 0, bU8 = 0;
gdi_layer_struct *handle_layer = NULL;
unsigned __int64 char_buffer[200] = {0};
U8 glyph_buffer[200] = {0};
unsigned char nBitsCopied = 0;
int nSourceBitsCopied = 0;
int nPadding = 0;
gdi_color border_color = 0, text_color = 0;
border_color = gdi_act_color_from_rgb(
0xff,
g_mmi_fe_text_border_color.r,
g_mmi_fe_text_border_color.g,
g_mmi_fe_text_border_color.b);
text_color = gdi_act_color_from_rgb(0xff, g_mmi_fe_text_color.r, g_mmi_fe_text_color.g, g_mmi_fe_text_color.b);
gdi_layer_get_active((gdi_handle*) & handle_layer);
bfcDecSetAttribute(g_decoder, BFC_STYLE_NORMAL, text_color, border_color);
bfcDecSetCanvas(g_decoder, (U8*) char_buffer, 100, 8, 100, BFC_RGB_FORMAT_1BPP);
bfcDecSetClipWindow(g_decoder, 0, 0, 99, 99);
bfcDecDrawGlyph(g_decoder, (U8*) font_data, char_width, data_height, 0, 0);
if (char_width % 8) /* char_width == font real width */
nPadding = 8 - (char_width % 8);
else
nPadding = 0;
for (i = 0; i < data_height; i++)
{
/*
* Because HW compression will pass the font byte sequence is:
* Left side of glyph pixel is in little endian(low memory), which is reverse with the
* sequence of font engine pass to HW compression.
* So we should reverse the byte sequence, and make them to "Raw data".
*/
U8 width_byte = (char_width / 8) + (char_width % 8 ? 1 : 0);
char *pch = (char *) & char_buffer;
for (j = 0; j < (width_byte / 2); j++)
{
char chr = pch[j];
pch[j] = pch[width_byte - j - 1];
pch[width_byte - j - 1] = chr;
}
nSourceBitsCopied = 0;
nCurrent = char_buffer;
nCurrent = nCurrent >> nPadding;
nCurrent = ReverseBitOrdering(nCurrent, char_width);
nMask = 1;
for (j = 0; j < char_width; ++j)
{
unsigned char nTemp;
// bU8 = (nCurrent)&nMask; /* the bit value, get each bit of width data */
/* glyph_buffer[nIndex]|= (unsigned char)bU8; */
bU8 = (nCurrent) & nMask; /* the bit value, get each bit of width data */
if (bU8 > 0)
{
bU8 = 0x01;
}
else
{
bU8 = 0x00;
}
bU8 = bU8 << nBitsCopied; /* Adjust to filled bit position. */
nTemp = (unsigned char)bU8;
glyph_buffer[nIndex] |= (unsigned char)nTemp;
++nBitsCopied; /* Note the count of current font data byte bit */
++nSourceBitsCopied; /* Note the count of current width bit */
nMask = nMask << 1;
if (nBitsCopied >= 8)
{
++nIndex;
nCurrent = char_buffer;
nCurrent = nCurrent >> nPadding;
nCurrent = ReverseBitOrdering(nCurrent, char_width);
nMask = 1 << nSourceBitsCopied;
nBitsCopied = 0;
}
}
if (nBitsCopied >= 8)
{
++nIndex;
nCurrent = char_buffer;
nCurrent = nCurrent >> nPadding;
nCurrent = ReverseBitOrdering(nCurrent, char_width);
nBitsCopied = 0;
nMask = 1 << nSourceBitsCopied;
}
}
font_data_size = nIndex + 1;
font_data = glyph_buffer;
}
#endif /* __MMI_BDF_SW_COMPRESSION__ */
#if !defined(__MMI_VECTOR_FONT_SUPPORT__)
*pCharWidth = data_width;
*pCharHeight = data_height;
fx1 = data_width - 1; /* min X of drawn area */
fx2 = 0; /* max X of drawn area */
fy1 = data_height - 1; /* min Y of drawn area */
fy2 = 0; /* max Y of drawn area */
x = 0;
y = 0;
#endif
#if defined(__MMI_VECTOR_FONT_SUPPORT__)
if (data_attr)
{
*pBoxXoffset = 0;
*pBoxYoffset = 0;
*pBoxWidth = data_width;
*pBoxHeight = data_height;
return;
}
#endif /* defined(__MMI_VECTOR_FONT_SUPPORT__) */
#if !defined(__MMI_VECTOR_FONT_SUPPORT__)
while (font_data_size--)
{
U8 pattern = *font_data++;
if (!pattern)
{
U32 nTemp;
x += 8;
nTemp = x / data_width;
if (nTemp)
{
y += nTemp;
data_height -= (U16) nTemp;
if (!data_height)
{
break;
}
}
x %= data_width;
}
else
{
S32 i;
for (i = 0; i < 8; i++)
{
if (pattern & 1)
{
if (x < fx1)
{
fx1 = x;
}
if (y < fy1)
{
fy1 = y;
}
if (x > fx2)
{
fx2 = x;
}
if (y > fy2)
{
fy2 = y;
}
}
x++;
if (x == (S32) data_width)
{
y++;
data_height--;
x = 0;
if (!data_height)
{
break;
}
}
pattern >>= 1;
}
}
}
MMI_DBG_Assert(fx2 >= fx1 && fy2 >= fy1);
*pBoxXoffset = fx1;
*pBoxYoffset = fy1;
*pBoxWidth = fx2 - fx1 + 1;
*pBoxHeight = fy2 - fy1 + 1;
#endif
}

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

合作/建议

TEL: 19168984579

工作时间:
周一到周五 9:00-11:30 13:30-19:30
  • 扫一扫关注公众号
  • 扫一扫打开小程序
Copyright © 2013-2024 一牛网 版权所有 All Rights Reserved. 帮助中心|隐私声明|联系我们|手机版|粤ICP备13053961号|营业执照|EDI证
在本版发帖搜索
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表