add ta (text align) to RENDERDATA

This commit is contained in:
Vincent Wei
2019-04-02 12:36:31 +08:00
parent 704b6287ff
commit d13c31a08a
8 changed files with 207 additions and 155 deletions
+8
View File
@@ -9431,6 +9431,9 @@ MG_EXPORT int GUIAPI GetTabbedTextExtent (HDC hdc,
#define SetTextAlign(hdc, ta_flags) \
SetDCAttr (hdc, DC_ATTR_TEXT_ALIGN, (DWORD)ta_flags)
#define BIDI_FLAG_LTR 0x00
#define BIDI_FLAG_RTL 0x10
#define GetBIDIFlags(hdc) \
GetDCAttr (hdc, DC_ATTR_BIDI_FLAGS)
@@ -12908,6 +12911,11 @@ typedef struct _RENDERDATA {
*/
LOGFONT* logfont;
/**
* The text alignment for rendering the glyph
*/
Uint32 ta;
/**
* The Unicode character corresponding to the glyph.
*/
+33 -33
View File
@@ -1,33 +1,33 @@
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
*
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* Or,
*
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/en/about/licensing-policy/>.
*/
@@ -39,7 +39,7 @@
#ifndef _DC_H
#define _DC_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -78,14 +78,14 @@ void __mg_unlock_gcrinfo (PDC pdc);
#else
RECT g_rcScr;
PLOGFONT g_SysLogFont[1];
#define LOCK_GCRINFO(pdc)
#define UNLOCK_GCRINFO(pdc)
#define LOCK_GCRINFO(pdc)
#define UNLOCK_GCRINFO(pdc)
#define __mg_hwnd_desktop 0xFFFFFFFD
#define __mg_dsk_win 1
#define gui_Control(hwnd) NULL
#define DestroyDskMsgQueue()
#define salone_StandAloneStartup() TRUE
#define salone_StandAloneCleanup()
#define DestroyDskMsgQueue()
#define salone_StandAloneStartup() TRUE
#define salone_StandAloneCleanup()
#define salone_IdleHandler4StandAlone(qmsg) NULL
#define kernel_GetGCRgnInfo(hwnd) NULL
#define GetWindowFont(hwnd) NULL
@@ -101,7 +101,7 @@ PLOGFONT g_SysLogFont[1];
#define PreDefMainWinProc NULL
#define PreDefControlProc NULL
#define PreDefDialogProc NULL
#define SendMessage(hwnd, message, wParam, lParam) 1
#define SendMessage(hwnd, message, wParam, lParam) 1
#endif
BOOL dc_GenerateECRgn (PDC pdc, BOOL fForce);
@@ -124,10 +124,10 @@ typedef void* (* CB_GET_LINE_BUFF) (void* context, int y, void** alpha_line_mask
typedef void (* CB_LINE_SCALED) (void* context, const void* line, int y);
typedef BOOL (* CB_BITMAP_SCALER_FUNC )(
void* context,
const BITMAP* srjjc_bmp,
void* context,
const BITMAP* srjjc_bmp,
int dst_w, int dst_h,
CB_GET_LINE_BUFF cb_line_buff,
CB_GET_LINE_BUFF cb_line_buff,
CB_LINE_SCALED cb_line_scaled,
GAL_PixelFormat *format);
@@ -136,7 +136,7 @@ struct tagDC
{
short DataType; /* the data type, always be TYPE_HDC */
short DCType; /* the dc type */
BOOL inuse;
HWND hwnd;
@@ -227,7 +227,7 @@ struct tagDC
CLIPRECT* cur_ban;
RECT rc_output;
/* local clip region information */
CLIPRGN lcrgn;
@@ -252,9 +252,9 @@ extern DC __mg_screen_sys_dc;
/* This function convert HDC to PDC. */
static inline PDC dc_HDC2PDC (HDC hdc)
{
if (hdc == HDC_SCREEN_SYS)
if (hdc == HDC_SCREEN_SYS)
return &__mg_screen_sys_dc;
else if (hdc == HDC_SCREEN)
else if (hdc == HDC_SCREEN)
return &__mg_screen_dc;
return (PDC) hdc;
}
@@ -277,7 +277,7 @@ static inline BOOL dc_IsGeneralDC (PDC pdc)
static inline BOOL dc_IsVisible (PDC pdc)
{
PCONTROL pCtrl;
#if 0
if (pdc->DCType != TYPE_GENDC)
return TRUE;
@@ -289,10 +289,10 @@ static inline BOOL dc_IsVisible (PDC pdc)
else return TRUE;
}
#endif
if (pdc->hwnd == HWND_DESKTOP)
return TRUE;
MG_CHECK_RET (MG_IS_WINDOW(pdc->hwnd), FALSE);
pCtrl = (PCONTROL)(pdc->hwnd);
@@ -306,6 +306,7 @@ static inline BOOL dc_IsVisible (PDC pdc)
return TRUE;
}
static inline void coor_DP2SP(PDC pdc, int* x, int* y)
{
*x += pdc->DevRC.left;
@@ -318,7 +319,6 @@ static inline void coor_SP2DP(PDC pdc, int* x, int* y)
*y -= pdc->DevRC.top;
}
static inline void coor_LP2SP(PDC pdc, int* x, int* y)
{
if (dc_IsScreenDC (pdc))
@@ -511,7 +511,7 @@ static inline void _dc_step_y (PDC pdc, int step)
#define BLOCK_DRAW_SEM(pdc)
#define UNBLOCK_DRAW_SEM(pdc)
#endif
#endif
int __mg_enter_drawing (PDC pdc);
void __mg_enter_drawing_nocheck (PDC pdc);
@@ -610,7 +610,7 @@ MG_EXPORT void ReleaseSecondarySubDC (HDC secondary_subdc);
static inline HDC get_valid_dc (PMAINWIN pWin, BOOL client)
{
#if 1
if (!(pWin->dwExStyle & WS_EX_CTRLASMAINWIN)
if (!(pWin->dwExStyle & WS_EX_CTRLASMAINWIN)
&& (pWin->pMainWin->secondaryDC)) {
#else
if (pWin->pMainWin->secondaryDC) {
@@ -619,7 +619,7 @@ static inline HDC get_valid_dc (PMAINWIN pWin, BOOL client)
return pWin->privCDC;
}
else
return GetSecondarySubDC (pWin->pMainWin->secondaryDC,
return GetSecondarySubDC (pWin->pMainWin->secondaryDC,
(HWND)pWin, client);
}
else {
@@ -646,13 +646,13 @@ static inline void release_valid_dc (PMAINWIN pWin, HDC hdc)
ReleaseDC (hdc);
}
}
}
}
void update_secondary_dc (PMAINWIN pWin, HDC secondary_dc,
void update_secondary_dc (PMAINWIN pWin, HDC secondary_dc,
HDC real_dc, const RECT* rc, DWORD flags);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // _DC_H
#endif // _DC_H
+2 -2
View File
@@ -1737,7 +1737,7 @@ static void dc_InitDC (PDC pdc, HWND hWnd, BOOL bIsClient)
pdc->mapmode = MM_TEXT;
pdc->ta_flags = TA_LEFT | TA_TOP | TA_NOUPDATECP;
pdc->bidi_flags = 0;
pdc->bidi_flags = BIDI_FLAG_LTR;
pdc->ViewOrig.x = pdc->ViewOrig.y = 0;
pdc->ViewExtent.x = pdc->ViewExtent.y = 1;
@@ -1904,7 +1904,7 @@ static void dc_InitScreenDC (PDC pdc, GAL_Surface *surface)
pdc->mapmode = MM_TEXT;
pdc->ta_flags = TA_LEFT | TA_TOP | TA_NOUPDATECP;
pdc->bidi_flags = 0;
pdc->bidi_flags = BIDI_FLAG_LTR;
pdc->ViewOrig.x = pdc->ViewOrig.y = 0;
pdc->ViewExtent.x = pdc->ViewExtent.y = 1;
+2 -5
View File
@@ -72,10 +72,9 @@ BOOL DrawShapedGlyph(HDC hdc, Glyph32 gv,
render_data->uc_index);
if (glyph_pos->suppressed == 0 && glyph_pos->whitespace == 0) {
PLOGFONT old_lf = NULL;
gal_pixel fg_pixel, bg_pixel;
old_lf = SelectFont(hdc, render_data->logfont);
SelectFont(hdc, render_data->logfont);
fg_color = GetTextColorInTextRuns(render_data->truninfo,
render_data->uc_index);
@@ -91,11 +90,9 @@ BOOL DrawShapedGlyph(HDC hdc, Glyph32 gv,
SetBkMode(hdc, BM_TRANSPARENT);
}
SetTextAlign(hdc, render_data->ta);
DrawGlyph(hdc, glyph_pos->x + glyph_pos->x_off,
glyph_pos->y + glyph_pos->y_off, gv, NULL, NULL);
if (old_lf)
SelectFont(hdc, old_lf);
}
else if (glyph_pos->whitespace && bg_color) {
// TODO: draw background for whitespace.
+108 -41
View File
@@ -211,10 +211,10 @@ static int mult (fixed op1, fixed op2)
mult(itofix(advance), fixsin(ftofix(tenthradian)))
#define CAL_VEC_X(advance, tenthradian) \
fixtoi (fixmul (itofix(advance), fixcos (ftofix(tenthradian))))
fixtoi(fixmul(itofix(advance), fixcos(ftofix(tenthradian))))
#define CAL_VEC_Y(advance, tenthradian) \
fixtoi (fixmul (itofix(advance), fixsin (ftofix(tenthradian))))
fixtoi(fixmul(itofix(advance), fixsin(ftofix(tenthradian))))
/* global variables for pre-rendered bitmap glyph */
@@ -2103,50 +2103,50 @@ static inline void _gdi_direct_fillglyph (PDC pdc, Glyph32 glyph_value,
* (*parallel_x1,*parallel_y1) to (x1,y1) is vertical relative to line from (x1,y1) to (x2,y2)
* (*parallel_x2,*parallel_y2) is the point at the parallel line reponse to (x2,y2)
*/
void _gdi_get_point_at_parallel(int x1, int y1, int x2, int y2, int advance, int* parallel_x1,
int* parallel_y1, int* parallel_x2, int* parallel_y2, PDC pdc)
void _gdi_get_point_at_parallel(int x1, int y1, int x2, int y2, int advance,
int* parallel_x1, int* parallel_y1,
int* parallel_x2, int* parallel_y2, PDC pdc)
{
int adv_x, adv_y;
adv_x =CAL_VEC_X2(advance,((pdc->pLogFont->rotation +900)%3600+3600)%3600
adv_x = CAL_VEC_X2(advance,((pdc->pLogFont->rotation +900)%3600+3600)%3600
*256/3600);
adv_y =CAL_VEC_Y2(advance,((pdc->pLogFont->rotation +900)%3600+3600)%3600
adv_y = CAL_VEC_Y2(advance,((pdc->pLogFont->rotation +900)%3600+3600)%3600
*256 /3600);
*parallel_x1 =x1 +adv_x;
*parallel_y1 =y1 -adv_y;
*parallel_x1 = x1 + adv_x;
*parallel_y1 = y1 - adv_y;
*parallel_x2 =x2 +adv_x;
*parallel_y2 =y2 -adv_y;
*parallel_x2 = x2 + adv_x;
*parallel_y2 = y2 - adv_y;
}
void _gdi_get_glyph_box_vertices (int x1, int y1, int x2, int y2, POINT* pts, PDC pdc)
{
int adv_x, adv_y;
adv_x =CAL_VEC_X2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation +900)%3600
adv_x = CAL_VEC_X2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation +900)%3600
+3600)%3600*256/3600);
adv_y =CAL_VEC_Y2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation +900)%3600
adv_y = CAL_VEC_Y2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation +900)%3600
+3600)%3600 *256 /3600);
pts[0].x = x1+adv_x;
pts[0].y = y1-adv_y;
pts[0].x = x1 + adv_x;
pts[0].y = y1 - adv_y;
pts[1].x =x2 +adv_x;
pts[1].y =y2 -adv_y;
pts[1].x = x2 + adv_x;
pts[1].y = y2 - adv_y;
adv_x =CAL_VEC_X2(pdc->pLogFont->descent,((pdc->pLogFont->rotation +2700)%3600
adv_x = CAL_VEC_X2(pdc->pLogFont->descent,((pdc->pLogFont->rotation +2700)%3600
+3600)%3600 * 256 / 3600);
adv_y =CAL_VEC_Y2(pdc->pLogFont->descent,((pdc->pLogFont->rotation +2700)%3600
adv_y = CAL_VEC_Y2(pdc->pLogFont->descent,((pdc->pLogFont->rotation +2700)%3600
+3600)%3600 * 256 / 3600);
pts[3].x = x1+adv_x;
pts[3].y = y1-adv_y;
pts[3].x = x1 + adv_x;
pts[3].y = y1 - adv_y;
pts[2].x =x2 +adv_x;
pts[2].y =y2 -adv_y;
pts[2].x = x2 + adv_x;
pts[2].y = y2 - adv_y;
}
void _gdi_get_baseline_point (PDC pdc, int* x, int* y)
@@ -2168,21 +2168,34 @@ void _gdi_get_baseline_point (PDC pdc, int* x, int* y)
int adv_x, adv_y;
if ((pdc->ta_flags & TA_Y_MASK) == TA_TOP) {
adv_x =CAL_VEC_X2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation
adv_x = CAL_VEC_X2(pdc->pLogFont->ascent, ((pdc->pLogFont->rotation
+2700)%3600+3600)%3600 * 256 / 3600);
adv_y =CAL_VEC_Y2(pdc->pLogFont->ascent,((pdc->pLogFont->rotation
adv_y = CAL_VEC_Y2(pdc->pLogFont->ascent, ((pdc->pLogFont->rotation
+2700)%3600+3600)%3600 * 256 / 3600);
*x +=adv_x;
*y -=adv_y;
if ((pdc->ta_flags & TA_X_MASK) == TA_LEFT) {
*x -= adv_x;
}
else if ((pdc->ta_flags & TA_X_MASK) == TA_RIGHT) {
*x += adv_x;
}
*y += adv_y;
}
else if ((pdc->ta_flags & TA_Y_MASK) == TA_BOTTOM) {
adv_x =CAL_VEC_X2(pdc->pLogFont->descent,((pdc->pLogFont->rotation
adv_x = CAL_VEC_X2(pdc->pLogFont->descent, ((pdc->pLogFont->rotation
+900)%3600+3600)%3600 * 256 / 3600);
adv_y =CAL_VEC_Y2(pdc->pLogFont->descent,((pdc->pLogFont->rotation
adv_y = CAL_VEC_Y2(pdc->pLogFont->descent, ((pdc->pLogFont->rotation
+900)%3600+3600)%3600 * 256 / 3600);
*x +=adv_x;
*y -=adv_y;
if ((pdc->ta_flags & TA_X_MASK) == TA_LEFT) {
*x += adv_x;
}
else if ((pdc->ta_flags & TA_X_MASK) == TA_RIGHT) {
*x -= adv_x;
}
*y += adv_y;
}
/*
int x1 = *x;
int y1 = *y;
@@ -2274,9 +2287,13 @@ int _font_get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
adv_len = devfont->font_ops->get_glyph_advance (logfont, devfont,
REAL_GLYPH(glyph_value), &tmp_x, &tmp_y);
if (!direction) {
// VincentWei: adjust the bbox_x for not rotated glyph
if (!direction && logfont->rotation == 0) {
bbox_x -= (bold + ch_extra + adv_len);
}
else if (logfont->rotation) {
// adjust acorrding to the alignment
}
if (direction) {
tmp_x += bold + ch_extra;
@@ -2308,7 +2325,57 @@ done:
return adv_len + bold + ch_extra + advance;
}
void _gdi_get_next_point_online (int pre_x, int pre_y, int advance, BOOL direction, PDC pdc, int *next_x, int *next_y)
int _font_get_glyph_metrics(LOGFONT* logfont,
Glyph32 gv, int* adv_x, int* adv_y, BBOX* bbox)
{
int bold = 0;
int tmp_x = 0;
int tmp_y = 0;
int bbox_x = 0, bbox_y = 0;
int bbox_w = 0, bbox_h = 0;
int gbt, width;;
DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(logfont, gv);
gbt = devfont->font_ops->get_glyph_bmptype (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE;
devfont->font_ops->get_glyph_bbox (logfont, devfont,
REAL_GLYPH(gv), &bbox_x, &bbox_y, &bbox_w, &bbox_h);
if ((logfont->style & FS_WEIGHT_MASK) > FS_WEIGHT_MEDIUM
&& (devfont->style & FS_WEIGHT_MASK) < FS_WEIGHT_DEMIBOLD
&& (gbt == DEVFONTGLYPHTYPE_MONOBMP)) {
bold = GET_DEVFONT_SCALE (logfont, devfont);
bbox_w += bold;
}
if (bbox) {
bbox->x = bbox_x;
bbox->y = bbox_y;
bbox->w = bbox_w;
bbox->h = bbox_h;
}
width = devfont->font_ops->get_glyph_advance (logfont, devfont,
REAL_GLYPH(gv), &tmp_x, &tmp_y);
tmp_x += bold;
if (gbt == DEVFONTGLYPHTYPE_MONOBMP) {
if ((logfont->style & FS_RENDER_MASK) == FS_RENDER_GREY ||
(logfont->style & FS_DECORATE_OUTLINE)) {
tmp_x++;
width++;
}
}
if (adv_x) *adv_x = tmp_x;
if (adv_y) *adv_y = tmp_y;
return width;
}
void _gdi_get_next_point_online (int pre_x, int pre_y, int advance,
BOOL direction, PDC pdc, int *next_x, int *next_y)
{
int delta_x, delta_y;
int rotation;
@@ -2358,18 +2425,19 @@ void _gdi_get_next_point_online (int pre_x, int pre_y, int advance, BOOL directi
}
}
delta_x =CAL_VEC_X2(advance,rotation * 256 / 3600);
delta_y =CAL_VEC_Y2(advance,rotation * 256 / 3600);
delta_x = CAL_VEC_X2(advance,rotation * 256 / 3600);
delta_y = CAL_VEC_Y2(advance,rotation * 256 / 3600);
if(direction){
*next_x +=delta_x;
*next_y -=delta_y;
*next_x += delta_x;
*next_y -= delta_y;
}
else{
*next_x -=delta_x;
*next_y +=delta_y;
*next_x -= delta_x;
*next_y += delta_y;
}
}
#define SIN_DEGREE(degree) \
fixsin (fixdiv (itofix(degree), ftofix(62.831852)))
@@ -2848,8 +2916,7 @@ int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value,
_gdi_get_baseline_point (pdc, &x, &y);
advance = _gdi_draw_one_glyph (pdc, glyph_value,
(pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
x, y, &my_adv_x, &my_adv_y);
TRUE, x, y, &my_adv_x, &my_adv_y);
if (adv_x) *adv_x = my_adv_x;
if (adv_y) *adv_y = my_adv_y;
+48 -13
View File
@@ -363,7 +363,7 @@ static int get_tab_pos(LAYOUTINFO *layout, int index, BOOL *is_default)
}
}
static int get_line_width(const LAYOUTLINE *line)
static int calc_line_width(const LAYOUTLINE *line)
{
struct list_head *l;
int i;
@@ -382,7 +382,7 @@ static int get_line_width(const LAYOUTLINE *line)
return width;
}
static int get_line_height(const LAYOUTLINE *line)
static int calc_line_height(const LAYOUTLINE *line)
{
struct list_head *l;
int i;
@@ -403,7 +403,7 @@ static void shape_tab(LAYOUTLINE *line, GlyphString *glyphs)
{
int i, space_width;
int current_width = get_line_width(line);
int current_width = calc_line_width(line);
__mg_glyph_string_set_size (glyphs, 1);
@@ -1722,11 +1722,36 @@ static int traverse_line_glyphs(const LAYOUTINFO* layout,
struct list_head* i;
int line_adv = 0;
RENDERDATA extra;
Uint32 def_ta;
Uint32 up_ta;
extra.truninfo = layout->truninfo;
extra.layout = layout;
extra.line = line;
switch (layout->rf & GRF_WRITING_MODE_MASK) {
case GRF_WRITING_MODE_HORIZONTAL_BT:
def_ta = TA_LEFT | TA_BOTTOM | TA_NOUPDATECP;
up_ta = def_ta;
break;
case GRF_WRITING_MODE_VERTICAL_RL:
def_ta = TA_RIGHT | TA_TOP | TA_NOUPDATECP;
up_ta = def_ta;
break;
case GRF_WRITING_MODE_VERTICAL_LR:
def_ta = TA_LEFT | TA_BOTTOM | TA_NOUPDATECP;
up_ta = TA_LEFT | TA_TOP | TA_NOUPDATECP;
break;
case GRF_WRITING_MODE_HORIZONTAL_TB:
default:
def_ta = TA_LEFT | TA_TOP | TA_NOUPDATECP;
up_ta = def_ta;
break;
}
list_for_each(i, &line->gruns) {
GlyphRun* run = (GlyphRun*)i;
for (j = 0; j < run->gstr->nr_glyphs; j++) {
@@ -1745,18 +1770,26 @@ static int traverse_line_glyphs(const LAYOUTINFO* layout,
glyph_info = run->gstr->glyphs + j;
if (run->lrun->dir == GLYPH_RUN_DIR_TTB ||
run->lrun->dir == GLYPH_RUN_DIR_BTT) {
pos.x = glyph_info->x_off;
pos.y = line_adv + glyph_info->y_off;
pos.advance = glyph_info->height;
pos.x_off = pos.y_off = 0;
if (layout->rf & GRF_WRITING_MODE_VERTICAL_FLAG) {
pos.y = line_adv;
pos.x = 0;
}
else {
pos.x = line_adv + glyph_info->x_off;
pos.y = glyph_info->y_off;
pos.advance = glyph_info->width;
pos.x = line_adv;
pos.y = 0;
}
if (run->lrun->flags & LAYOUTRUN_FLAG_CENTERED_BASELINE) {
extra.ta = up_ta;
pos.x += (line->height - glyph_info->width) / 2;
}
else {
extra.ta = def_ta;
}
pos.advance = glyph_info->width;
pos.suppressed = 0;
pos.whitespace = 0;
pos.ellipsis = 0;
@@ -1895,6 +1928,8 @@ LAYOUTLINE* GUIAPI LayoutNextLine(
if (next_line) {
next_line->max_extent = max_extent;
next_line->is_last_line = last_line;
next_line->width = calc_line_width(next_line);
next_line->height = calc_line_height(next_line);
if (layout->persist) {
list_add_tail(&next_line->list, &layout->lines);
@@ -1938,8 +1973,8 @@ BOOL GUIAPI GetLayoutLineSize(LAYOUTLINE* line,
line_size->cy = line->height;
}
else {
line->width = line_size->cx = get_line_width(line);
line->height = line_size->cy = get_line_height(line);
line->width = line_size->cx = calc_line_width(line);
line->height = line_size->cy = calc_line_height(line);
}
return TRUE;
+6 -12
View File
@@ -189,13 +189,10 @@ static BOOL shape_layout_run(SEInstance* inst,
}
else {
if (run->flags & LAYOUTRUN_FLAG_CENTERED_BASELINE) {
BBOX bbox;
int width = _font_get_glyph_metrics(run->lf, gv,
NULL, NULL, &bbox);
gs->glyphs[j].width = run->lf->size;
gs->glyphs[j].height = width;
gs->glyphs[j].x_off = (width - bbox.w) / 2;
gs->glyphs[j].height
= _font_get_glyph_log_width(run->lf, gv);
gs->glyphs[j].x_off = 0;
gs->glyphs[j].y_off = 0;
}
else {
@@ -217,13 +214,10 @@ static BOOL shape_layout_run(SEInstance* inst,
gs->glyphs[j].is_cluster_start = 0;
if (run->flags & LAYOUTRUN_FLAG_CENTERED_BASELINE) {
BBOX bbox;
int width = _font_get_glyph_metrics(run->lf, gv,
NULL, NULL, &bbox);
gs->glyphs[j].width = run->lf->size;
gs->glyphs[j].height = width;
gs->glyphs[j].x_off = (width - bbox.w) / 2;
gs->glyphs[j].height
= _font_get_glyph_log_width(run->lf, gv);
gs->glyphs[j].x_off = 0;
gs->glyphs[j].y_off = 0;
}
else {
-49
View File
@@ -143,55 +143,6 @@ static BOOL is_horizontal_only_script(Uchar32 uc)
return TRUE;
}
int _font_get_glyph_metrics(LOGFONT* logfont,
Glyph32 gv, int* adv_x, int* adv_y, BBOX* bbox)
{
int bold = 0;
int tmp_x = 0;
int tmp_y = 0;
int bbox_x = 0, bbox_y = 0;
int bbox_w = 0, bbox_h = 0;
int gbt, width;;
DEVFONT* devfont = SELECT_DEVFONT_BY_GLYPH(logfont, gv);
gbt = devfont->font_ops->get_glyph_bmptype (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE;
devfont->font_ops->get_glyph_bbox (logfont, devfont,
REAL_GLYPH(gv), &bbox_x, &bbox_y, &bbox_w, &bbox_h);
if ((logfont->style & FS_WEIGHT_MASK) > FS_WEIGHT_MEDIUM
&& (devfont->style & FS_WEIGHT_MASK) < FS_WEIGHT_DEMIBOLD
&& (gbt == DEVFONTGLYPHTYPE_MONOBMP)) {
bold = GET_DEVFONT_SCALE (logfont, devfont);
bbox_w += bold;
}
if (bbox) {
bbox->x = bbox_x;
bbox->y = bbox_y;
bbox->w = bbox_w;
bbox->h = bbox_h;
}
width = devfont->font_ops->get_glyph_advance (logfont, devfont,
REAL_GLYPH(gv), &tmp_x, &tmp_y);
tmp_x += bold;
if (gbt == DEVFONTGLYPHTYPE_MONOBMP) {
if ((logfont->style & FS_RENDER_MASK) == FS_RENDER_GREY ||
(logfont->style & FS_DECORATE_OUTLINE)) {
tmp_x++;
width++;
}
}
if (adv_x) *adv_x = tmp_x;
if (adv_y) *adv_y = tmp_y;
return width;
}
static void normalize_glyph_metrics(LOGFONT* logfont,
Uint32 render_flags, const BBOX* bbox,
int* adv_x, int* adv_y, int* line_adv, int* line_width)