Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default font should be mono #49

Closed
brad opened this issue Dec 28, 2011 · 17 comments
Closed

Default font should be mono #49

brad opened this issue Dec 28, 2011 · 17 comments

Comments

@brad
Copy link
Member

brad commented Dec 28, 2011

I opened up the windows build of openscad with wine for testing and noticed that the default font was "MS Sans Serif". I think the default font should be a mono font to enable the use of spaces for code alignment. Ex.

test_vector = [[0, 0, 0],
                     [0, 1, 1],
                     [1, 0, 0]];

This example will only look exactly aligned with a mono font. Is that a difficult problem to solve?

@kintel
Copy link
Member

kintel commented Dec 28, 2011

We are requesting a Typewriter font, which should prefer a fixed pitch font, also on Windows: https://github.com/openscad/openscad/blob/master/src/mainwin.cc#L1800

Are you sure the font isn't overridden in the preferences?

@brad
Copy link
Member Author

brad commented Dec 28, 2011

Yep, here are the registry contents when OpenSCAD was loaded:
REGEDIT4

[HKEY_CURRENT_USER\Software\OpenSCAD]

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD]
"recentFileList"=hex(7):5a,3a,2f,6d,65,64,69,61,2f,63,6f,64,65,2f,6f,70,65,6e,
73,63,61,64,2d,6d,61,73,74,65,72,2f,74,65,73,74,32,2e,73,63,61,64,00,00

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\view]
"orthogonalProjection"="false"

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window]
"position"="@point(67 55)"
"size"="@SiZe(800 600)"

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter1sizes]
"size"=dword:00000002

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter1sizes\1]
"entry"=dword:0000018e

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter1sizes\2]
"entry"=dword:0000018e

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter2sizes]
"size"=dword:00000002

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter2sizes\1]
"entry"=dword:00000175

[HKEY_CURRENT_USER\Software\OpenSCAD\OpenSCAD\window\splitter2sizes\2]
"entry"=dword:000000bb

To test the Ubuntu native version I deleted ~/.config/OpenSCAD/OpenSCAD.conf to start from defaults and the initial font was "DejaVu Sans"

My config file contains the following:

[editor]
fontsize=0

[view]
orthogonalProjection=false

[window]
size=@SiZe(800 600)
position=@point(0 24)
splitter1sizes\1\entry=397
splitter1sizes\2\entry=397
splitter1sizes\size=2
splitter2sizes\1\entry=381
splitter2sizes\2\entry=191
splitter2sizes\size=2

So it seams that QT isn't doing the job correctly? According to http://doc.trolltech.com/4.6/qfont.html#fontmatching the font matching algorithm is:

  1. The specified font family is searched for.
  2. If not found, the styleHint() is used to select a replacement family.
  3. Each replacement font family is searched for.
  4. If none of these are found or there was no styleHint(), "helvetica" will be searched for.
  5. If "helvetica" isn't found Qt will try the lastResortFamily().
  6. If the lastResortFamily() isn't found Qt will try the lastResortFont() which will always return a name of some kind.

Not sure where it's failing in there. My system doesn't have Helvetica, so for all I know it could be getting to the very last step and choosing the lastResortFamily. Any ideas how I can test further? Is there a list somewhere of fonts that classify as "Typewriter" fonts?

@kintel
Copy link
Member

kintel commented Dec 29, 2011

On Dec 28, 2011, at 21:46 PM, Brad Pitcher wrote:

So it seams that QT isn't doing the job correctly? According to http://doc.trolltech.com/4.6/qfont.html#fontmatching the font matching algorithm is:

It looks like we were inheriting the default font of QTextEdit.
I've committed a fix - it should work better now, but only tested on Mac.

-Marius

@kintel
Copy link
Member

kintel commented Dec 29, 2011

uh:
"Qt does not support style hints on X11 since this information is not provided by the window system."

I'm now forcing the font to fixed pitch, unless a concrete family is selected.

@kintel kintel closed this as completed Dec 29, 2011
@brad
Copy link
Member Author

brad commented Dec 29, 2011

This didn't fix the issue for me. The default is still "Deja Vu Sans" in Ubuntu.

@donbright
Copy link
Sponsor Member

how can i tell which font its loading?

@brad
Copy link
Member Author

brad commented Dec 30, 2011

Go to Edit->Preferences and select the Editor tab

@donbright
Copy link
Sponsor Member

d'oh.. thanks.

is there a fixed-width font that all ubuntu versions have? i can try to do some testing but dont know much about fonts.

@brad
Copy link
Member Author

brad commented Dec 30, 2011

I assume they all have "DejaVu Sans Mono" but we should be thinking about other distros too right?

@donbright
Copy link
Sponsor Member

oh... good point.. . . . thanks for the info.

my brain is fried at the moment. i will try to make a patch in a few days.

@donbright
Copy link
Sponsor Member

Here is an experimental patch to fix the bug reported.

#57

It chooses a specific substring for a font name depending on the OS.

On linux, it looks for anything with the word 'Mono' in the name

On Windows, it looks for anything with the word 'Console' in the name

On Mac it looks for anything named 'Monaco' in the name.

it doesn't use SetFont in mainwin.cc, because that gets overridden anyways by Preferences.cc constructor and Preferences.cc updategui. Even if there are no preferences set, and there is no .config file in existence, the Preferences code pulls the default font from the OS, regardless of SetFont in mainwin.cc.

@brad
Copy link
Member Author

brad commented Jan 4, 2012

I pulled the updates from openscad master and it works great mostly.
In Ubuntu, my default font was "Andale Mono"
In windows (wine) my default font was fixed pitch, but when I went to the preferences to see what font it was, it showed "MS Sans Serif" to be the font in use, which was definitely not true.
Any idea why it would show a different font from the font that is actually in use?
I wonder also if it's just a wine issue.

@donbright
Copy link
Sponsor Member

d'oh i think the problem might be that it's looking for "Console" named fonts in Wine because it thinks it's Windows. Wine though uses the Linux fonts, so Console won't be there... so i have no idea what it's doing.

Do you know where it stores the OpenSCAD.conf file in Wine? If I can figure out how to erase that and restart in Wine i think i can track it down and fix this bug.


scratch that, i found it,,, its in the registry (!) .

will debug tonight. thanks

@brad
Copy link
Member Author

brad commented Jan 4, 2012

Yeah, it stores the openscad configuration in the registry: [HKEY_CURRENT_USER\Software\OpenSCAD]

I would think getting this to work with wine shouldn't be a high priority though, there's no reason for anyone to use it with wine.

@donbright
Copy link
Sponsor Member

if my code breaks in wine it will probably break in windows some day. besides this wont take long.

i found this really cool page here:

http://www.codestyle.org/css/font-family/sampler-Monospace.shtml

@donbright
Copy link
Sponsor Member

thanks very much for reporting this bug. it would have shown up on any system where the default attempt didnt match a system font (not just wine). it should be fixed in this patch:

https://github.com/openscad/openscad/pull/58/files

@brad
Copy link
Member Author

brad commented Jan 7, 2012

Thanks Don, it looks good in Wine now. Default font for me was "Courier New", I wouldn't have guessed it was fixed pitch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants