1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

NEW - bug 206328: [regression] Terminal does not draw correctly with proportional font

https://bugs.eclipse.org/bugs/show_bug.cgi?id=206328
This commit is contained in:
Michael Scharf 2007-10-26 05:42:19 +00:00
parent 54925f0d08
commit 46c49d37c3

View file

@ -145,25 +145,27 @@ public class StyleMap {
for (char c = ' '; c <= '~'; c++) {
// consider only the first 128 chars for deciding if a font
// is proportional
if(measureChar(gc, c))
if(measureChar(gc, c, true))
fProportional=true;
}
// TODO should we also consider the upper 128 chars??
// for (char c = ' '+128; c <= '~'+128; c++) {
// measureChar(gc, c);
// }
for (char c = ' '+128; c <= '~'+128; c++) {
measureChar(gc, c,false);
}
for (int i = 0; i < fOffsets.length; i++) {
fOffsets[i]=(fCharSize.x-fOffsets[i])/2;
}
gc.dispose ();
}
private boolean measureChar(GC gc, char c) {
private boolean measureChar(GC gc, char c, boolean updateMax) {
boolean proportional=false;
Point ext=gc.textExtent(String.valueOf(c));
if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) {
proportional=true;
fCharSize.x=Math.max(fCharSize.x, ext.x);
fCharSize.y=Math.max(fCharSize.y, ext.y);
if(updateMax) {
fCharSize.x=Math.max(fCharSize.x, ext.x);
fCharSize.y=Math.max(fCharSize.y, ext.y);
}
}
fOffsets[c]=ext.x;
return proportional;