mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 02:15:31 +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:
parent
54925f0d08
commit
46c49d37c3
1 changed files with 9 additions and 7 deletions
|
@ -145,25 +145,27 @@ public class StyleMap {
|
||||||
for (char c = ' '; c <= '~'; c++) {
|
for (char c = ' '; c <= '~'; c++) {
|
||||||
// consider only the first 128 chars for deciding if a font
|
// consider only the first 128 chars for deciding if a font
|
||||||
// is proportional
|
// is proportional
|
||||||
if(measureChar(gc, c))
|
if(measureChar(gc, c, true))
|
||||||
fProportional=true;
|
fProportional=true;
|
||||||
}
|
}
|
||||||
// TODO should we also consider the upper 128 chars??
|
// TODO should we also consider the upper 128 chars??
|
||||||
// for (char c = ' '+128; c <= '~'+128; c++) {
|
for (char c = ' '+128; c <= '~'+128; c++) {
|
||||||
// measureChar(gc, c);
|
measureChar(gc, c,false);
|
||||||
// }
|
}
|
||||||
for (int i = 0; i < fOffsets.length; i++) {
|
for (int i = 0; i < fOffsets.length; i++) {
|
||||||
fOffsets[i]=(fCharSize.x-fOffsets[i])/2;
|
fOffsets[i]=(fCharSize.x-fOffsets[i])/2;
|
||||||
}
|
}
|
||||||
gc.dispose ();
|
gc.dispose ();
|
||||||
}
|
}
|
||||||
private boolean measureChar(GC gc, char c) {
|
private boolean measureChar(GC gc, char c, boolean updateMax) {
|
||||||
boolean proportional=false;
|
boolean proportional=false;
|
||||||
Point ext=gc.textExtent(String.valueOf(c));
|
Point ext=gc.textExtent(String.valueOf(c));
|
||||||
if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) {
|
if(ext.x>0 && ext.y>0 && (fCharSize.x!=ext.x || fCharSize.y!=ext.y)) {
|
||||||
proportional=true;
|
proportional=true;
|
||||||
fCharSize.x=Math.max(fCharSize.x, ext.x);
|
if(updateMax) {
|
||||||
fCharSize.y=Math.max(fCharSize.y, ext.y);
|
fCharSize.x=Math.max(fCharSize.x, ext.x);
|
||||||
|
fCharSize.y=Math.max(fCharSize.y, ext.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fOffsets[c]=ext.x;
|
fOffsets[c]=ext.x;
|
||||||
return proportional;
|
return proportional;
|
||||||
|
|
Loading…
Add table
Reference in a new issue