Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Aressera

Member Since 25 Mar 2007
Offline Last Active Today, 11:10 AM
-----

Topics I've Started

How to enumerate the installed font paths on a system?

29 January 2013 - 03:40 PM

I'm looking to see if there is a better solution to this problem than my current implementation. Currently, I search certain predefined system paths for font files ("C:\Windows\Fonts\" on Windows and "/System/Library/Fonts/", "/Library/Fonts/" on OS X), then open each file with Freetype to determine the font's family and face names, then cache this information, along with the file's path, for later use. The problem is that this is really slow (a couple of seconds).

 

I've looked at the available functionality on OS X and Windows and the only font management tools allow you to list the installed font names but don't allow you to get the path on the system where the font file is stored. Therefore, there's no way for me to use a library like Freetype to open the file.

 

Am I missing something or is there no better way to do this?


Problems with SetParent() and window frames

07 September 2012 - 10:56 PM

I'm trying to implement a cross-platform wrapper for basic window management and OpenGL rendering. I've gotten the OS X version working well. To create an OpenGL rendering view I create an NSOpenGLView (on mac) or an HWND with the WS_CHILD style, then attach the view to a normal window, allowing the user to position the view anywhere in the window.

However, there is something weird that happens whenever I call SetParent() to make the GL view a child window of a normal window - the GL view is resized so that it fits inside in the parent window, but the strange thing is that it is reduced in size by the same amount as if it had a title bar/frame. The result is that there is now a border around the GL view between it and the parent window. This happens even if the client rectangle of the GL view and the normal window should be the same size. (I've attached an image of the behavior).

I should note that it does work as expected unless I call SetWindowPos() to update the frame. SetWindowPos() shouldn't move or size the window if I specify the flags SWP_NOMOVE and SWP_NOSIZE, but it does anyway.

As far as I'm aware, a window with the WS_CHILD style shouldn't have any title bar or frame but it seems like somewhere the windows API treats them as such.

I've spent several hours trying to find a workaround to this apparent problem. Does anyone have any idea what I could be doing wrong, or is there no way I can do what I'm trying to do?

Here is a rundown of the API calls I'm making that cause the problem:
  • CreateWindowEx() for the GL view with the WS_POPUP style. I use that style because I can't seem to create a window with the WS_CHILD style without specifying a parent window at creation. This also allows me to switch the GL view to fullscreen when running in non-windowed mode. I use a size of 800x600 for the window.
  • Change the style of the window from WS_POPUP to WS_CHILD using SetWindowLongPtr() in order to prepare it to be a child of another window.
  • Call SetParent() to make the GL view a child of the normal window.
  • If I call SetWindowPos() at any point after making the GL view a child, it resizes the GL view's client rectangle as described above. The resulting client area rectangle is 780x560, even though the window was created with a client size of 800x600. This makes the invisible frame of the GL view fit within the original 800x600 size.

PARTNERS