From 2dcb53d326a35dec5cd533e67e24156491212d5d Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sun, 18 Jul 2010 22:22:22 +0000 Subject: [PATCH] Fix bug #1994 and apply patch #1998 - Change Mac OS X to use DejaVu Sans like in Windows/Linux, which fixes problems with text alignment. refs #1994, closes #1998 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@11230 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/ivis_opengl/textdraw.c | 18 ++++++++++ macosx/Resources/Warzone-Info.plist | 2 ++ macosx/Warzone.xcodeproj/project.pbxproj | 42 ++++++++++++++++++++++++ src/configuration.c | 14 ++------ src/intdisplay.c | 6 ++-- 5 files changed, 67 insertions(+), 15 deletions(-) diff --git a/lib/ivis_opengl/textdraw.c b/lib/ivis_opengl/textdraw.c index 5b336461d..badeba423 100644 --- a/lib/ivis_opengl/textdraw.c +++ b/lib/ivis_opengl/textdraw.c @@ -34,6 +34,8 @@ #include "lib/ivis_common/bitimage.h" #ifdef WZ_OS_MAC +# include +# include # include #else # include @@ -131,6 +133,22 @@ static void iV_initializeGLC(void) glcRenderStyle(GLC_TEXTURE); glcStringType(GLC_UTF8_QSO); // Set GLC's string type to UTF-8 FIXME should be UCS4 to avoid conversions + #ifdef WZ_OS_MAC + { + char resourcePath[PATH_MAX]; + CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + if (CFURLGetFileSystemRepresentation(resourceURL, true, (UInt8 *) resourcePath, PATH_MAX)) + { + sstrcat(resourcePath, "/Fonts"); + glcAppendCatalog(resourcePath); + } + else + { + debug(LOG_ERROR, "Could not change to resources directory."); + } + } + #endif + _glcFont_Regular = glcGenFontID(); _glcFont_Bold = glcGenFontID(); diff --git a/macosx/Resources/Warzone-Info.plist b/macosx/Resources/Warzone-Info.plist index dd01c3b35..7140fb617 100644 --- a/macosx/Resources/Warzone-Info.plist +++ b/macosx/Resources/Warzone-Info.plist @@ -26,6 +26,8 @@ CFBundleAllowMixedLocalizations + ATSApplicationFontsPath + Fonts/ CFBundleVersion SVN_REV CFBundleShortVersionString diff --git a/macosx/Warzone.xcodeproj/project.pbxproj b/macosx/Warzone.xcodeproj/project.pbxproj index 7f1969272..4b485f9e1 100644 --- a/macosx/Warzone.xcodeproj/project.pbxproj +++ b/macosx/Warzone.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ buildConfigurationList = 43FA570F10FF8EBB0074E914 /* Build configuration list for PBXAggregateTarget "Setup Prebuilt Components" */; buildPhases = ( 43FA570B10FF8E9B0074E914 /* SDL */, + 43D4865411EE98F300997E08 /* Fonts */, 4345290E1130F84E002AD731 /* msgfmt */, ); dependencies = ( @@ -501,6 +502,8 @@ 43C3B9BE118BEB63000BBE59 /* residue_44p51.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C3B9BC118BEB63000BBE59 /* residue_44p51.h */; }; 43C3B9BF118BEB63000BBE59 /* setup_44p51.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C3B9BD118BEB63000BBE59 /* setup_44p51.h */; }; 43C3B9E0118BEC40000BBE59 /* res_books_51.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C3B9B4118BEA9D000BBE59 /* res_books_51.h */; }; + 43D4861711EE6F6F00997E08 /* DejaVuSans-Bold.ttf in Copy Fonts */ = {isa = PBXBuildFile; fileRef = 43D4861511EE6F6F00997E08 /* DejaVuSans-Bold.ttf */; }; + 43D4861811EE6F6F00997E08 /* DejaVuSans.ttf in Copy Fonts */ = {isa = PBXBuildFile; fileRef = 43D4861611EE6F6F00997E08 /* DejaVuSans.ttf */; }; 43E1890411440D8C000870EB /* eval-plural.h in Headers */ = {isa = PBXBuildFile; fileRef = 022B2F850BD55B4F002E64E3 /* eval-plural.h */; }; 43E1890511440D8D000870EB /* gettextP.h in Headers */ = {isa = PBXBuildFile; fileRef = 022B2F860BD55B4F002E64E3 /* gettextP.h */; }; 43E1890611440D8F000870EB /* gmo.h in Headers */ = {isa = PBXBuildFile; fileRef = 022B2F870BD55B50002E64E3 /* gmo.h */; }; @@ -812,6 +815,18 @@ name = "Copy frameworks"; runOnlyForDeploymentPostprocessing = 0; }; + 43D4861211EE6EEC00997E08 /* Copy Fonts */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Fonts; + dstSubfolderSpec = 7; + files = ( + 43D4861711EE6F6F00997E08 /* DejaVuSans-Bold.ttf in Copy Fonts */, + 43D4861811EE6F6F00997E08 /* DejaVuSans.ttf in Copy Fonts */, + ); + name = "Copy Fonts"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -1608,6 +1623,8 @@ 43C3B9C0118BEBE0000BBE59 /* barkmel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = barkmel.c; path = external/libvorbis/lib/barkmel.c; sourceTree = ""; }; 43C3B9C1118BEBE0000BBE59 /* psytune.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = psytune.c; path = external/libvorbis/lib/psytune.c; sourceTree = ""; }; 43C3B9C2118BEBE0000BBE59 /* tone.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tone.c; path = external/libvorbis/lib/tone.c; sourceTree = ""; }; + 43D4861511EE6F6F00997E08 /* DejaVuSans-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "DejaVuSans-Bold.ttf"; path = "external/fonts/DejaVuSans-Bold.ttf"; sourceTree = ""; }; + 43D4861611EE6F6F00997E08 /* DejaVuSans.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = DejaVuSans.ttf; path = external/fonts/DejaVuSans.ttf; sourceTree = ""; }; 43E188F311440CC9000870EB /* tsearch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tsearch.c; path = "external/gettext/gettext-runtime/intl/tsearch.c"; sourceTree = ""; }; 43E188F411440CC9000870EB /* tsearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tsearch.h; path = "external/gettext/gettext-runtime/intl/tsearch.h"; sourceTree = ""; }; 43E1897311441009000870EB /* os2compat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = os2compat.c; path = "external/gettext/gettext-runtime/intl/os2compat.c"; sourceTree = ""; }; @@ -1993,6 +2010,7 @@ 432BE3FD10D9CF1300A486AB /* vorbis */, 0246A05C0BD3C975004D1C70 /* Warzone.icns */, 02356D780BD3BB3500E9A019 /* Warzone-Info.plist */, + 43D4861411EE6F4000997E08 /* Fonts */, 43025C2B111FB072006C49B1 /* wzlocal */, ); name = Resources; @@ -3028,6 +3046,15 @@ name = coupled; sourceTree = ""; }; + 43D4861411EE6F4000997E08 /* Fonts */ = { + isa = PBXGroup; + children = ( + 43D4861511EE6F6F00997E08 /* DejaVuSans-Bold.ttf */, + 43D4861611EE6F6F00997E08 /* DejaVuSans.ttf */, + ); + name = Fonts; + sourceTree = ""; + }; 43F3008010D344B000707B6E /* x86 */ = { isa = PBXGroup; children = ( @@ -3396,6 +3423,7 @@ buildConfigurationList = 02356D790BD3BB3600E9A019 /* Build configuration list for PBXNativeTarget "Warzone" */; buildPhases = ( 02356D710BD3BB3400E9A019 /* Resources */, + 43D4861211EE6EEC00997E08 /* Copy Fonts */, 43025CD1111FB66E006C49B1 /* i18n */, 02356D720BD3BB3400E9A019 /* Sources */, 02356D730BD3BB3400E9A019 /* Frameworks */, @@ -4001,6 +4029,20 @@ shellPath = /bin/sh; shellScript = "DirectorY=\"gettext-0.17.mpkg_\"\nOutDir=\"gettext-0.17.mpkg\"\nFileName=\"gettext-0.17.mpkg.tar.gz\"\nBuiltDLP=\"http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/gettext-0.17.mpkg.tar.gz\"\nMD5Sum=\"ba7984918fe0b36e2e7c786693e005f2\"\n\n# Checks\nexport PATH=$PATH:/sw/bin:/opt/local/bin\nif type -aP msgfmt; then\n echo \"msgfmt exists, skipping\"\n exit 0\nelif [ -x \"/opt/local/bin/port\" ]; then\n echo \"warning: Please run the following command in the terminal: 'sudo port install gettext'.\" >&2\n open -b com.apple.Terminal\n exit 1\nelif [ -d \"${SRCROOT}/external/${OutDir}\" ]; then\n touch build/notrans.dis\n echo \"warning: Gettext support has been disabled because we could not find a binary.\" >&2\n exit 0\nelif [ ! `sw_vers -productVersion | sed -e 's:^...\\(.\\)..$:\\1:'` -ge \"6\" ]; then\n touch build/notrans.dis\n echo \"warning: Gettext support has been disabled because we could not find a binary.\" >&2\n exit 0\nfi\n\nconfigs/FetchPrebuilt.sh \"${DirectorY}\" \"${OutDir}\" \"${FileName}\" \"${BuiltDLP}\" \"${MD5Sum}\"\nFetchExitStatus=$?\n\n# Install\nif [ ! \"${FetchExitStatus}\" = \"0\" ]; then\n exit \"${FetchExitStatus}\"\nelif [ -d \"${SRCROOT}/external/${OutDir}\" ]; then\n echo \" Please install the gettext package before continuing.\" >&2\n open \"${SRCROOT}/external/${OutDir}\"\n exit 1\nfi"; }; + 43D4865411EE98F300997E08 /* Fonts */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = Fonts; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "DirectorY=\"fonts_\"\nOutDir=\"fonts\"\nFileName=\"fonts.tar.gz\"\nBuiltDLP=\"http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/fonts.tar.gz\"\nMD5Sum=\"1b8805b36f6f1ba71026d6b5ece1ed52\"\n\nconfigs/FetchPrebuilt.sh \"${DirectorY}\" \"${OutDir}\" \"${FileName}\" \"${BuiltDLP}\" \"${MD5Sum}\"\nexit ${?}\n\n# tar -czf fonts.tar.gz --exclude '.DS_Store' fonts_"; + }; 43F3011910D3572400707B6E /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/src/configuration.c b/src/configuration.c index 36779679a..d102c3124 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -277,34 +277,24 @@ BOOL loadConfig(void) setWarzoneKeyString("masterserver_name", NETgetMasterserverName()); } - if (getWarzoneKeyString("fontname", sBuf)) + if (getWarzoneKeyString("fontname", sBuf) && strcmp(sBuf,"Lucida Grande")) { iV_font(sBuf, NULL, NULL); } else { -#ifdef WZ_OS_MAC - iV_font("Lucida Grande", NULL, NULL); - setWarzoneKeyString("fontname", "Lucida Grande"); -#else iV_font("DejaVu Sans", NULL, NULL); setWarzoneKeyString("fontname", "DejaVu Sans"); -#endif } - if (getWarzoneKeyString("fontface", sBuf)) + if (getWarzoneKeyString("fontface", sBuf) && strcmp(sBuf,"Normal")) { iV_font(NULL, sBuf, NULL); } else { -#ifdef WZ_OS_MAC - iV_font(NULL, "Regular", NULL); - setWarzoneKeyString("fontface", "Regular"); -#else iV_font(NULL, "Book", NULL); setWarzoneKeyString("fontface", "Book"); -#endif } if (getWarzoneKeyString("fontfacebold", sBuf)) diff --git a/src/intdisplay.c b/src/intdisplay.c index 28ca96816..e55b099d7 100644 --- a/src/intdisplay.c +++ b/src/intdisplay.c @@ -626,7 +626,7 @@ void intDisplayPowerBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC iV_DrawImage(IntImages,IMAGE_PBAR_TOP,x0,y0); iX = x0 + 3; - iY = y0 + 9; + iY = y0 + 10; x0 += iV_GetImageWidth(IntImages,IMAGE_PBAR_TOP); @@ -2887,7 +2887,7 @@ void intDisplayStatsBar(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_DEC /* draw text value */ sprintf(szVal, "%d", BarGraph->iOriginal); iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( szVal, x0, iY+2 ); + iV_DrawText( szVal, x0, iY ); //draw the comparison value - only if not zero if (BarGraph->minorSize != 0) @@ -2944,7 +2944,7 @@ void intDisplayDesignPowerBar(WIDGET *psWidget, UDWORD xOffset, /* draw text value */ sprintf(szVal, "%d", BarGraph->iOriginal); iV_SetTextColour(WZCOL_TEXT_BRIGHT); - iV_DrawText( szVal, x0, iY+2 ); + iV_DrawText( szVal, x0, iY ); //draw the comparison value - only if not zero if (BarGraph->minorSize != 0)