-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 59c9120
Showing
65 changed files
with
25,715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
/.vscode | ||
/bin-win*/phantom.exe | ||
/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Cyano Hao | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# War3R FontMod | ||
|
||
Font modification tool for _Warcraft III: Reforged_. | ||
|
||
## Features | ||
|
||
* Drag and drop, easy to use. | ||
* Keep letter spacing. | ||
![Letter spacing](image/letter-spacing.jpg) | ||
|
||
## Download | ||
|
||
[Latest release](https://github.com/nowar-fonts/War3R-FontMod/releases). | ||
|
||
## How-to | ||
|
||
1. Choose a replacement font. | ||
* If you have no idea, the bundled `sample-font.ttf` can be a good start. | ||
* [Google Fonts](https://fonts.google.com/) and [Font Squirrel](https://www.fontsquirrel.com/) are good places to find free fonts. | ||
* Variable fonts are not supported. (Choose a “static instance” instead.) | ||
2. Open the `War3R-FontMod` directory; then drag your font and drop it to `run.bat`. A folder `Fonts` will be created in several seconds. | ||
3. Move `Fonts` to _Warcraft III_ installation directory (usually `C:\Program Files (x86)\Warcraft III\`). | ||
|
||
## (For advanced users) command line interface | ||
|
||
### Compile | ||
|
||
With GCC or Clang, | ||
```bash | ||
g++ src/phantom.cpp src/iostream.cpp -Isrc/ -std=c++17 -O2 -o phantom | ||
``` | ||
|
||
### Run ([otfcc](https://github.com/caryll/otfcc) required) | ||
|
||
```bash | ||
otfccdump myfont.ttf -o myfont.otd | ||
./phantom myfont.otd | ||
otfccbuild myfont.otd -O2 -o out.ttf | ||
|
||
for font in FRIZQT__ BLQ55Web BLQ85Web THOWR___ NimrodMT | ||
do | ||
cp out.ttf path/to/war3r/$font.ttf | ||
done | ||
``` | ||
|
||
## Credits | ||
|
||
[otfcc](https://github.com/caryll/otfcc) is used to parse OpenType font files to JSON files and build them back to OpenType font files. | ||
|
||
A modified [nlohmann/json](https://github.com/nlohmann/json) library is used to process JSON files. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#! /bin/bash | ||
|
||
source ./version.bash | ||
|
||
VERSION=$VERSION-win64 | ||
|
||
x86_64-w64-mingw32-g++ src/phantom.cpp src/iostream.cpp -Isrc/ -std=c++2a -O3 -static -s -o bin-win64/phantom.exe | ||
|
||
mkdir -p release | ||
cd release | ||
|
||
|
||
R=War3R-FontMod-$VERSION | ||
|
||
mkdir -p $R | ||
|
||
cp ../bin-win64/{otfccbuild,otfccdump,phantom}.exe $R/ | ||
cp ../font/sample-font.ttf $R/ | ||
cp ../script-windows/run.bat $R/ | ||
cp ../script-windows/github-repo.url $R/ | ||
|
||
7z a -tzip -mm=Deflate:fb=258:pass=3 -mcu=on $R.zip $R/ |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[{000214A0-0000-0000-C000-000000000046}] | ||
Prop3=19,11 | ||
[InternetShortcut] | ||
IDList= | ||
URL=https://github.com/nowar-fonts/War3R-FontMod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%~d0 | ||
cd "%~dp0" | ||
|
||
.\otfccdump.exe --ignore-hints -o base.otd "%~1" | ||
|
||
.\phantom.exe base.otd | ||
|
||
@echo off | ||
IF %ERRORLEVEL% NEQ 0 ( | ||
echo [31mFAILED![0m | ||
|
||
del base.otd | ||
pause | ||
) ELSE ( | ||
IF exist Fonts rmdir /s /q Fonts | ||
mkdir Fonts | ||
|
||
.\otfccbuild.exe -q -O3 -o Fonts\FRIZQT__.ttf base.otd | ||
copy Fonts\FRIZQT__.ttf Fonts\BLQ55Web.ttf | ||
copy Fonts\FRIZQT__.ttf Fonts\BLQ85Web.ttf | ||
copy Fonts\FRIZQT__.ttf Fonts\THOWR___.ttf | ||
copy Fonts\FRIZQT__.ttf Fonts\NimrodMT.ttf | ||
|
||
del base.otd | ||
pause | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,263 @@ | ||
// | ||
// Copyright (c) 2012 Artyom Beilis (Tonkikh) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See | ||
// accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
#define NOWIDE_SOURCE | ||
#include <nowide/iostream.hpp> | ||
#include <nowide/convert.hpp> | ||
#include <stdio.h> | ||
#include <vector> | ||
|
||
#ifdef NOWIDE_WINDOWS | ||
|
||
#ifndef NOMINMAX | ||
# define NOMINMAX | ||
#endif | ||
|
||
|
||
#include <windows.h> | ||
|
||
|
||
namespace nowide { | ||
namespace details { | ||
|
||
namespace { | ||
bool is_atty_handle(HANDLE h) | ||
{ | ||
if(h) { | ||
DWORD dummy; | ||
return GetConsoleMode(h,&dummy) == TRUE; | ||
} | ||
return false; | ||
} | ||
} | ||
|
||
class console_output_buffer : public std::streambuf { | ||
public: | ||
console_output_buffer(HANDLE h) : | ||
handle_(h) | ||
{ | ||
} | ||
protected: | ||
int sync() | ||
{ | ||
return overflow(EOF); | ||
} | ||
int overflow(int c) | ||
{ | ||
if(!handle_) | ||
return -1; | ||
int n = pptr() - pbase(); | ||
int r = 0; | ||
|
||
if(n > 0 && (r=write(pbase(),n)) < 0) | ||
return -1; | ||
if(r < n) { | ||
memmove(pbase(),pbase() + r,n-r); | ||
} | ||
setp(buffer_, buffer_ + buffer_size); | ||
pbump(n-r); | ||
if(c!=EOF) | ||
sputc(c); | ||
return 0; | ||
} | ||
private: | ||
|
||
int write(char const *p,int n) | ||
{ | ||
namespace uf = nowide::utf; | ||
char const *b = p; | ||
char const *e = p+n; | ||
DWORD size=0; | ||
if(n > buffer_size) | ||
return -1; | ||
wchar_t *out = wbuffer_; | ||
uf::code_point c; | ||
size_t decoded = 0; | ||
while(p < e && (c = uf::utf_traits<char>::decode(p,e))!=uf::illegal && c!=uf::incomplete) { | ||
out = uf::utf_traits<wchar_t>::encode(c,out); | ||
decoded = p-b; | ||
} | ||
if(c==uf::illegal) | ||
return -1; | ||
if(!WriteConsoleW(handle_,wbuffer_,out - wbuffer_,&size,0)) | ||
return -1; | ||
return decoded; | ||
} | ||
|
||
static const int buffer_size = 1024; | ||
char buffer_[buffer_size]; | ||
wchar_t wbuffer_[buffer_size]; // for null | ||
HANDLE handle_; | ||
}; | ||
|
||
class console_input_buffer: public std::streambuf { | ||
public: | ||
console_input_buffer(HANDLE h) : | ||
handle_(h), | ||
wsize_(0) | ||
{ | ||
} | ||
|
||
protected: | ||
int pbackfail(int c) | ||
{ | ||
if(c==EOF) | ||
return EOF; | ||
|
||
if(gptr()!=eback()) { | ||
gbump(-1); | ||
*gptr() = c; | ||
return 0; | ||
} | ||
|
||
if(pback_buffer_.empty()) { | ||
pback_buffer_.resize(4); | ||
char *b = &pback_buffer_[0]; | ||
char *e = b + pback_buffer_.size(); | ||
setg(b,e-1,e); | ||
*gptr() = c; | ||
} | ||
else { | ||
size_t n = pback_buffer_.size(); | ||
std::vector<char> tmp; | ||
tmp.resize(n*2); | ||
memcpy(&tmp[n],&pback_buffer_[0],n); | ||
tmp.swap(pback_buffer_); | ||
char *b = &pback_buffer_[0]; | ||
char *e = b + n * 2; | ||
char *p = b+n-1; | ||
*p = c; | ||
setg(b,p,e); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int underflow() | ||
{ | ||
if(!handle_) | ||
return -1; | ||
if(!pback_buffer_.empty()) | ||
pback_buffer_.clear(); | ||
|
||
size_t n = read(); | ||
setg(buffer_,buffer_,buffer_+n); | ||
if(n == 0) | ||
return EOF; | ||
return std::char_traits<char>::to_int_type(*gptr()); | ||
} | ||
|
||
private: | ||
|
||
size_t read() | ||
{ | ||
namespace uf = nowide::utf; | ||
DWORD read_wchars = 0; | ||
size_t n = wbuffer_size - wsize_; | ||
if(!ReadConsoleW(handle_,wbuffer_,n,&read_wchars,0)) | ||
return 0; | ||
wsize_ += read_wchars; | ||
char *out = buffer_; | ||
wchar_t *b = wbuffer_; | ||
wchar_t *e = b + wsize_; | ||
wchar_t *p = b; | ||
uf::code_point c; | ||
wsize_ = e-p; | ||
while(p < e && (c = uf::utf_traits<wchar_t>::decode(p,e))!=uf::illegal && c!=uf::incomplete) { | ||
out = uf::utf_traits<char>::encode(c,out); | ||
wsize_ = e-p; | ||
} | ||
|
||
if(c==uf::illegal) | ||
return 0; | ||
|
||
|
||
if(c==uf::incomplete) { | ||
memmove(b,e-wsize_,sizeof(wchar_t)*wsize_); | ||
} | ||
|
||
return out - buffer_; | ||
} | ||
|
||
static const size_t buffer_size = 1024 * 3; | ||
static const size_t wbuffer_size = 1024; | ||
char buffer_[buffer_size]; | ||
wchar_t wbuffer_[buffer_size]; // for null | ||
HANDLE handle_; | ||
int wsize_; | ||
std::vector<char> pback_buffer_; | ||
}; | ||
|
||
winconsole_ostream::winconsole_ostream(int fd) : std::ostream(0) | ||
{ | ||
HANDLE h = 0; | ||
switch(fd) { | ||
case 1: | ||
h = GetStdHandle(STD_OUTPUT_HANDLE); | ||
break; | ||
case 2: | ||
h = GetStdHandle(STD_ERROR_HANDLE); | ||
break; | ||
} | ||
if(is_atty_handle(h)) { | ||
d.reset(new console_output_buffer(h)); | ||
std::ostream::rdbuf(d.get()); | ||
} | ||
else { | ||
std::ostream::rdbuf( fd == 1 ? std::cout.rdbuf() : std::cerr.rdbuf() ); | ||
} | ||
} | ||
winconsole_ostream::~winconsole_ostream() | ||
{ | ||
try { | ||
flush(); | ||
} | ||
catch(...){} | ||
} | ||
|
||
winconsole_istream::winconsole_istream() : std::istream(0) | ||
{ | ||
HANDLE h = GetStdHandle(STD_INPUT_HANDLE); | ||
if(is_atty_handle(h)) { | ||
d.reset(new console_input_buffer(h)); | ||
std::istream::rdbuf(d.get()); | ||
} | ||
else { | ||
std::istream::rdbuf(std::cin.rdbuf()); | ||
} | ||
} | ||
|
||
winconsole_istream::~winconsole_istream() | ||
{ | ||
} | ||
|
||
} // details | ||
|
||
NOWIDE_DECL details::winconsole_istream cin; | ||
NOWIDE_DECL details::winconsole_ostream cout(1); | ||
NOWIDE_DECL details::winconsole_ostream cerr(2); | ||
NOWIDE_DECL details::winconsole_ostream clog(2); | ||
|
||
namespace { | ||
struct initialize { | ||
initialize() | ||
{ | ||
nowide::cin.tie(&nowide::cout); | ||
nowide::cerr.tie(&nowide::cout); | ||
nowide::clog.tie(&nowide::cout); | ||
} | ||
} inst; | ||
} | ||
|
||
|
||
|
||
} // nowide | ||
|
||
|
||
#endif | ||
/// | ||
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 |
Oops, something went wrong.