Skip to content

Commit

Permalink
macOS|libgui: Use stbtt for font rendering
Browse files Browse the repository at this point in the history
Same font rendering on all platforms for consistency.
  • Loading branch information
skyjake committed Dec 14, 2019
1 parent 47e4b76 commit 86ba427
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
41 changes: 22 additions & 19 deletions doomsday/libs/gui/net.dengine.stdlib.gui.pack/fonts.dei
Expand Up @@ -48,35 +48,38 @@ group {
condition: Version.OS in ['macx', 'ios']

script {
loadFonts()

# Define mappings for native font styles and weights.
import App
App.addFontMapping("Apple UI", {
['regular', 25]: '#system-light',
['regular', 50]: '#system',
['regular', 75]: '#system-bold',
['italic', 25]: '#system-italic-light',
['italic', 50]: '#system-italic',
['italic', 75]: '#system-italic-bold'
})
App.addFontMapping("Apple Mono", {
['regular', 25]: 'Menlo-Regular',
['regular', 50]: 'Menlo-Regular',
['regular', 75]: 'Menlo-Bold',
['italic', 25]: 'Menlo-Italic',
['italic', 50]: 'Menlo-Italic',
['italic', 75]: 'Menlo-BoldItalic'
})
# (These work with the CoreText font renderer.)
# import App
# App.addFontMapping("Apple UI", {
# ['regular', 25]: '#system-light',
# ['regular', 50]: '#system',
# ['regular', 75]: '#system-bold',
# ['italic', 25]: '#system-italic-light',
# ['italic', 50]: '#system-italic',
# ['italic', 75]: '#system-italic-bold'
# })
# App.addFontMapping("Apple Mono", {
# ['regular', 25]: 'Menlo-Regular',
# ['regular', 50]: 'Menlo-Regular',
# ['regular', 75]: 'Menlo-Bold',
# ['italic', 25]: 'Menlo-Italic',
# ['italic', 50]: 'Menlo-Italic',
# ['italic', 75]: 'Menlo-BoldItalic'
# })
}

font default {
family: Apple UI
family: SourceSansPro
size: 16pt
weight: normal
style: normal
}

font monospace inherits default {
family: Apple Mono
family: SourceCodePro
size: 12pt
}
}
Expand Down
10 changes: 5 additions & 5 deletions doomsday/libs/gui/src/text/font.cpp
Expand Up @@ -22,13 +22,13 @@
#include <de/Hash>
#include <de/ThreadLocal>

#if (defined(MACOSX) && defined(MACOS_10_7)) || defined(DE_IOS)
# include "coretextnativefont_macx.h"
namespace de { using PlatformFont = CoreTextNativeFont; }
#else
//#if (defined(MACOSX) && defined(MACOS_10_7)) || defined(DE_IOS)
//# include "coretextnativefont_macx.h"
// namespace de { using PlatformFont = CoreTextNativeFont; }
//#else
# include "stbttnativefont.h"
namespace de { using PlatformFont = StbTtNativeFont; }
#endif
//#endif

namespace std {
template<>
Expand Down

0 comments on commit 86ba427

Please sign in to comment.