Index: source/blender/editors/space_text/text_draw.c =================================================================== --- source/blender/editors/space_text/text_draw.c (révision 45378) +++ source/blender/editors/space_text/text_draw.c (copie de travail) @@ -65,7 +65,8 @@ static void text_font_begin(SpaceText *st) { - BLF_size(mono, st->lheight, 72); + BLF_size(mono, st->lheight, U.dpi); + st->lpixheight = BLF_height_max(mono); } static void text_font_end(SpaceText *UNUSED(st)) @@ -728,7 +729,7 @@ if (st->showsyntax && format) format_draw_color(format[a]); x += text_font_draw_character_utf8(st, x, y, str + ma); } - y -= st->lheight; + y -= st->lpixheight; x = basex; lines++; start = end; mstart = mend; @@ -809,6 +810,7 @@ /* this is needed to check cache relevance */ int winx, wordwrap, showlinenrs, tabnumber; short lheight; + int lpixheight; char cwidth; char text_id[MAX_ID_NAME]; @@ -847,6 +849,7 @@ full_update |= drawcache->showlinenrs != st->showlinenrs; /* word-wrapping option was toggled */ full_update |= drawcache->tabnumber != st->tabnumber; /* word-wrapping option was toggled */ full_update |= drawcache->lheight != st->lheight; /* word-wrapping option was toggled */ + full_update |= drawcache->lpixheight != st->lpixheight; full_update |= drawcache->cwidth != st->cwidth; /* word-wrapping option was toggled */ full_update |= strncmp(drawcache->text_id, txt->id.name, MAX_ID_NAME); /* text datablock was changed */ @@ -923,6 +926,7 @@ drawcache->winx = ar->winx; drawcache->wordwrap = st->wordwrap; drawcache->lheight = st->lheight; + drawcache->lpixheight = st->lpixheight; drawcache->cwidth = st->cwidth; drawcache->showlinenrs = st->showlinenrs; drawcache->tabnumber = st->tabnumber; @@ -1281,39 +1285,39 @@ y = ar->winy - 3; if (y1 == y2) { - y -= y1 * st->lheight; + y -= y1 * st->lpixheight; glBegin(GL_LINE_LOOP); glVertex2i(x + x2 * st->cwidth + 1, y); glVertex2i(x + x1 * st->cwidth - 2, y); - glVertex2i(x + x1 * st->cwidth - 2, y - st->lheight); - glVertex2i(x + x2 * st->cwidth + 1, y - st->lheight); + glVertex2i(x + x1 * st->cwidth - 2, y - st->lpixheight); + glVertex2i(x + x2 * st->cwidth + 1, y - st->lpixheight); glEnd(); } else { - y -= y1 * st->lheight; + y -= y1 * st->lpixheight; glBegin(GL_LINE_STRIP); glVertex2i(ar->winx, y); glVertex2i(x + x1 * st->cwidth - 2, y); - glVertex2i(x + x1 * st->cwidth - 2, y - st->lheight); - glVertex2i(ar->winx, y - st->lheight); + glVertex2i(x + x1 * st->cwidth - 2, y - st->lpixheight); + glVertex2i(ar->winx, y - st->lpixheight); glEnd(); - y -= st->lheight; + y -= st->lpixheight; for (i = y1 + 1; i < y2; i++) { glBegin(GL_LINES); glVertex2i(x, y); glVertex2i(ar->winx, y); - glVertex2i(x, y - st->lheight); - glVertex2i(ar->winx, y - st->lheight); + glVertex2i(x, y - st->lpixheight); + glVertex2i(ar->winx, y - st->lpixheight); glEnd(); - y -= st->lheight; + y -= st->lpixheight; } glBegin(GL_LINE_STRIP); glVertex2i(x, y); glVertex2i(x + x2 * st->cwidth + 1, y); - glVertex2i(x + x2 * st->cwidth + 1, y - st->lheight); - glVertex2i(x, y - st->lheight); + glVertex2i(x + x2 * st->cwidth + 1, y - st->lpixheight); + glVertex2i(x, y - st->lpixheight); glEnd(); } } @@ -1349,9 +1353,9 @@ x += SUGG_LIST_WIDTH * st->cwidth + 50; } - /* top= */ /* UNUSED */ y = ar->winy - st->lheight * l - 2; + /* top= */ /* UNUSED */ y = ar->winy - st->lpixheight * l - 2; boxw = DOC_WIDTH * st->cwidth + 20; - boxh = (DOC_HEIGHT + 1) * st->lheight; + boxh = (DOC_HEIGHT + 1) * st->lpixheight; /* Draw panel */ UI_ThemeColor(TH_BACK); @@ -1383,7 +1387,7 @@ else if (*p == '\n') { buf[i] = '\0'; if (lines >= 0) { - y -= st->lheight; + y -= st->lpixheight; text_draw(st, buf, 0, 0, 1, x + 4, y - 3, NULL); } i = 0; br = DOC_WIDTH; lines++; @@ -1392,7 +1396,7 @@ if (i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */ buf[br] = '\0'; if (lines >= 0) { - y -= st->lheight; + y -= st->lpixheight; text_draw(st, buf, 0, 0, 1, x + 4, y - 3, NULL); } p -= i - br - 1; /* Rewind pointer to last break */ @@ -1438,10 +1442,10 @@ else { x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4; } - y = ar->winy - st->lheight * l - 2; + y = ar->winy - st->lpixheight * l - 2; boxw = SUGG_LIST_WIDTH * st->cwidth + 20; - boxh = SUGG_LIST_SIZE * st->lheight + 8; + boxh = SUGG_LIST_SIZE * st->lpixheight + 8; UI_ThemeColor(TH_SHADE1); glRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1); @@ -1453,7 +1457,7 @@ for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) { - y -= st->lheight; + y -= st->lpixheight; BLI_strncpy(str, item->name, SUGG_LIST_WIDTH); @@ -1461,7 +1465,7 @@ if (item == sel) { UI_ThemeColor(TH_SHADE2); - glRecti(x + 16, y - 3, x + 16 + w, y + st->lheight - 3); + glRecti(x + 16, y - 3, x + 16 + w, y + st->lpixheight - 3); } b = 1; /* b=1 color block, text is default. b=0 no block, color text */ switch (item->type) { @@ -1508,11 +1512,11 @@ y = ar->winy - 2; if (vcurl == vsell) { - y -= vcurl * st->lheight; + y -= vcurl * st->lpixheight; if (vcurc < vselc) - glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - st->lheight); + glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - st->lpixheight); else - glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - st->lheight); + glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - st->lpixheight); } else { int froml, fromc, tol, toc; @@ -1526,12 +1530,12 @@ fromc = vselc; toc = vcurc; } - y -= froml * st->lheight; - glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - st->lheight); y -= st->lheight; + y -= froml * st->lpixheight; + glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - st->lpixheight); y -= st->lpixheight; for (i = froml + 1; i < tol; i++) - glRecti(x - 4, y, ar->winx, y - st->lheight), y -= st->lheight; + glRecti(x - 4, y, ar->winx, y - st->lpixheight), y -= st->lpixheight; - glRecti(x - 4, y, x + toc * st->cwidth, y - st->lheight); y -= st->lheight; + glRecti(x - 4, y, x + toc * st->cwidth, y - st->lpixheight); y -= st->lpixheight; } } else { @@ -1555,12 +1559,12 @@ wrap_offset_in_line(st, ar, text->sell, text->selc, &offl, &offc); - y1 = ar->winy - 2 - (vsell - offl) * st->lheight; - y2 = y1 - st->lheight * visible_lines + 1; + y1 = ar->winy - 2 - (vsell - offl) * st->lpixheight; + y2 = y1 - st->lpixheight * visible_lines + 1; } else { - y1 = ar->winy - 2 - vsell * st->lheight; - y2 = y1 - st->lheight + 1; + y1 = ar->winy - 2 - vsell * st->lpixheight; + y2 = y1 - st->lpixheight + 1; } if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ @@ -1580,7 +1584,7 @@ /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x += vselc * st->cwidth; - y = ar->winy - 2 - vsell * st->lheight; + y = ar->winy - 2 - vsell * st->lpixheight; if (st->overwrite) { char ch = text->sell->line[text->selc]; @@ -1589,11 +1593,11 @@ if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; UI_ThemeColor(TH_HILITE); - glRecti(x, y - st->lheight - 1, x + w, y - st->lheight + 1); + glRecti(x, y - st->lpixheight - 1, x + w, y - st->lpixheight + 1); } else { UI_ThemeColor(TH_HILITE); - glRecti(x - 1, y, x + 1, y - st->lheight); + glRecti(x - 1, y, x + 1, y - st->lpixheight); } } } @@ -1698,7 +1702,7 @@ UI_ThemeColor(TH_HILITE); x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; - y = ar->winy - st->lheight; + y = ar->winy - st->lpixheight; /* draw opening bracket */ ch = startl->line[startc]; @@ -1708,8 +1712,8 @@ if (viewc >= 0) { viewl = txt_get_span(text->lines.first, startl) - st->top + offl; - text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lheight, ch); - text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lpixheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lpixheight, ch); } /* draw closing bracket */ @@ -1720,8 +1724,8 @@ if (viewc >= 0) { viewl = txt_get_span(text->lines.first, endl) - st->top + offl; - text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lheight, ch); - text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth, y - viewl * st->lpixheight, ch); + text_font_draw_character(st, x + viewc * st->cwidth + 1, y - viewl * st->lpixheight, ch); } } @@ -1736,7 +1740,7 @@ int i, x, y, winx, linecount = 0, lineno = 0; int wraplinecount = 0, wrap_skip = 0; - if (st->lheight) st->viewlines = (int)ar->winy / st->lheight; + if (st->lpixheight) st->viewlines = (int)ar->winy / st->lpixheight; else st->viewlines = 0; /* if no text, nothing to do */ @@ -1795,7 +1799,7 @@ st->linenrs_tot = 0; /* not used */ x = TXT_OFFSET; } - y = ar->winy - st->lheight; + y = ar->winy - st->lpixheight; winx = ar->winx - TXT_SCROLL_WIDTH; /* draw cursor */ @@ -1825,12 +1829,12 @@ if (st->wordwrap) { /* draw word wrapped text */ int lines = text_draw_wrapped(st, tmp->line, x, y, winx - x, tmp->format, wrap_skip); - y -= lines * st->lheight; + y -= lines * st->lpixheight; } else { /* draw unwrapped text */ text_draw(st, tmp->line, st->left, ar->winx / st->cwidth, 1, x, y, tmp->format); - y -= st->lheight; + y -= st->lpixheight; } wrap_skip = 0; Index: source/blender/editors/space_text/text_ops.c =================================================================== --- source/blender/editors/space_text/text_ops.c (révision 45378) +++ source/blender/editors/space_text/text_ops.c (copie de travail) @@ -2544,7 +2544,7 @@ { Text *text = st->text; text_update_character_width(st); - y = (ar->winy - 2 - y) / st->lheight; + y = (ar->winy - 2 - y) / st->lpixheight; if (st->showlinenrs) x -= TXT_OFFSET + TEXTXLOC; else x -= TXT_OFFSET; Index: source/blender/editors/space_text/text_python.c =================================================================== --- source/blender/editors/space_text/text_python.c (révision 45378) +++ source/blender/editors/space_text/text_python.c (copie de travail) @@ -78,10 +78,10 @@ else { x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4; } - y = ar->winy - st->lheight * l - 2; + y = ar->winy - st->lpixheight * l - 2; w = SUGG_LIST_WIDTH * st->cwidth + 20; - h = SUGG_LIST_SIZE * st->lheight + 8; + h = SUGG_LIST_SIZE * st->lpixheight + 8; // XXX getmouseco_areawin(mval); @@ -92,7 +92,7 @@ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) ; /* Work out the target item index in the visible list */ - tgti = (y - mval[1] - 4) / st->lheight; + tgti = (y - mval[1] - 4) / st->lpixheight; if (tgti < 0 || tgti > SUGG_LIST_SIZE) return 1; Index: source/blender/editors/space_info/textview.c =================================================================== --- source/blender/editors/space_info/textview.c (révision 45378) +++ source/blender/editors/space_info/textview.c (copie de travail) @@ -36,8 +36,8 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "DNA_userdef_types.h" - #include "BIF_gl.h" #include "BIF_glutil.h" @@ -47,12 +47,14 @@ static void console_font_begin(TextViewContext *sc) { - BLF_size(blf_mono_font, sc->lheight - 2, 72); + BLF_size(blf_mono_font, sc->lheight - 2, U.dpi); + sc->lpixheight = BLF_height_max(blf_mono_font); } typedef struct ConsoleDrawContext { int cwidth; int lheight; + int lpixheight; int console_width; /* number of characters that fit into the width of the console (fixed width) */ int winx; int ymin, ymax; @@ -89,9 +91,9 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str_len, unsigned char *fg, unsigned char *bg) { #define STEP_SEL(value) cdc->sel[0] += (value); cdc->sel[1] += (value) - int rct_ofs = cdc->lheight / 4; + int rct_ofs = cdc->lpixheight / 4; int tot_lines = (str_len / cdc->console_width) + 1; /* total number of lines for wrapping */ - int y_next = (str_len > cdc->console_width) ? cdc->xy[1] + cdc->lheight * tot_lines : cdc->xy[1] + cdc->lheight; + int y_next = (str_len > cdc->console_width) ? cdc->xy[1] + cdc->lpixheight * tot_lines : cdc->xy[1] + cdc->lpixheight; const int mono = blf_mono_font; /* just advance the height */ @@ -116,7 +118,7 @@ cdc->xy[1] = y_next; return 1; } - else if (y_next - cdc->lheight < cdc->ymin) { + else if (y_next - cdc->lpixheight < cdc->ymin) { /* have not reached the drawable area so don't break */ cdc->xy[1] = y_next; @@ -141,7 +143,7 @@ if (bg) { glColor3ubv(bg); - glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)) + rct_ofs); + glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, (cdc->xy[1] + (cdc->lpixheight * tot_lines)) + rct_ofs); } glColor3ubv(fg); @@ -153,12 +155,12 @@ if (cdc->sel[0] != cdc->sel[1]) { STEP_SEL(-initial_offset); // glColor4ub(255, 0, 0, 96); // debug - console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight); + console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lpixheight); STEP_SEL(cdc->console_width); glColor3ubv(fg); } - cdc->xy[1] += cdc->lheight; + cdc->xy[1] += cdc->lpixheight; line_stride -= cdc->console_width; @@ -168,12 +170,12 @@ if (cdc->sel[0] != cdc->sel[1]) { // glColor4ub(0, 255, 0, 96); // debug - console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight); + console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lpixheight); STEP_SEL(cdc->console_width); glColor3ubv(fg); } - cdc->xy[1] += cdc->lheight; + cdc->xy[1] += cdc->lpixheight; /* check if were out of view bounds */ if (cdc->xy[1] > cdc->ymax) @@ -187,7 +189,7 @@ if (bg) { glColor3ubv(bg); - glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, cdc->xy[1] + cdc->lheight - rct_ofs); + glRecti(0, cdc->xy[1] - rct_ofs, cdc->winx, cdc->xy[1] + cdc->lpixheight - rct_ofs); } glColor3ubv(fg); @@ -202,11 +204,11 @@ isel[1] = str_len - cdc->sel[0]; // glColor4ub(255, 255, 0, 96); // debug - console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight); + console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lpixheight); STEP_SEL(-(str_len + 1)); } - cdc->xy[1] += cdc->lheight; + cdc->xy[1] += cdc->lpixheight; if (cdc->xy[1] > cdc->ymax) return 0; @@ -223,7 +225,7 @@ { ConsoleDrawContext cdc = {0}; - int x_orig = CONSOLE_DRAW_MARGIN, y_orig = CONSOLE_DRAW_MARGIN + tvc->lheight / 6; + int x_orig = CONSOLE_DRAW_MARGIN, y_orig = CONSOLE_DRAW_MARGIN + tvc->lpixheight / 6; int xy[2], y_prev; int sel[2] = {-1, -1}; /* defaults disabled */ unsigned char fg[3], bg[3]; @@ -243,6 +245,7 @@ cdc.cwidth = (int)BLF_fixed_width(mono); assert(cdc.cwidth > 0); cdc.lheight = tvc->lheight; + cdc.lpixheight = tvc->lpixheight; cdc.console_width = (tvc->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN * 2) ) / cdc.cwidth; CLAMP(cdc.console_width, 1, INT_MAX); /* avoid divide by zero on small windows */ cdc.winx = tvc->winx - (CONSOLE_DRAW_MARGIN + CONSOLE_DRAW_SCROLL); @@ -297,7 +300,7 @@ tvc->end(tvc); - xy[1] += tvc->lheight * 2; + xy[1] += tvc->lpixheight * 2; return xy[1] - y_orig; } Index: source/blender/editors/space_info/textview.h =================================================================== --- source/blender/editors/space_info/textview.h (révision 45378) +++ source/blender/editors/space_info/textview.h (copie de travail) @@ -26,7 +26,7 @@ typedef struct TextViewContext { - int lheight; + int lheight, lpixheight; int sel_start, sel_end; /* view settings */ Index: source/blender/editors/space_image/image_draw.c =================================================================== --- source/blender/editors/space_image/image_draw.c (révision 45378) +++ source/blender/editors/space_image/image_draw.c (copie de travail) @@ -116,6 +116,8 @@ { char str[256]; float dx = 6; + int lheight; + /* text colors */ /* XXX colored text not allowed in Blender UI */ #if 0 @@ -130,16 +132,17 @@ float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0; float col[4], finalcol[4]; + BLF_size(blf_mono_font, 11, U.dpi); + lheight = BLF_height_max(blf_mono_font) - BLF_descender(blf_mono_font) - BLF_ascender(blf_mono_font); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); /* noisy, high contrast make impossible to read if lower alpha is used. */ glColor4ub(0, 0, 0, 190); - glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20); + glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, lheight + 12); glDisable(GL_BLEND); - BLF_size(blf_mono_font, 11, 72); - glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. @@ -261,8 +264,8 @@ dx += 5; glBegin(GL_QUADS); glVertex2f(dx, 3); - glVertex2f(dx, 17); - glVertex2f(dx + 30, 17); + glVertex2f(dx, lheight + 9); + glVertex2f(dx + 30, lheight + 9); glVertex2f(dx + 30, 3); glEnd(); @@ -270,8 +273,8 @@ glColor3ub(128, 128, 128); glBegin(GL_LINE_LOOP); glVertex2f(dx, 3); - glVertex2f(dx, 17); - glVertex2f(dx + 30, 17); + glVertex2f(dx, lheight + 9); + glVertex2f(dx + 30, lheight + 9); glVertex2f(dx + 30, 3); glEnd(); Index: source/blender/editors/screen/area.c =================================================================== --- source/blender/editors/screen/area.c (révision 45378) +++ source/blender/editors/screen/area.c (copie de travail) @@ -1781,12 +1781,13 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) { - const int header_height = 18; uiStyle *style= UI_GetStyle(); int fontid= style->widget.uifont_id; rcti rect; + int header_height; - BLF_size(fontid, 11.0f, 72); + BLF_size(fontid, 11.0f, U.dpi); + header_height = BLF_height_max(fontid) - BLF_descender(fontid) - BLF_ascender(fontid) + 10; /* background box */ rect= ar->winrct; Index: source/blender/makesdna/DNA_space_types.h =================================================================== --- source/blender/makesdna/DNA_space_types.h (révision 45378) +++ source/blender/makesdna/DNA_space_types.h (copie de travail) @@ -311,7 +311,8 @@ short lheight; /* user preference */ char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */ - int left; + short lpixheight; /* line height in pixels */ + short left; int showlinenrs; int tabnumber;