Skip to content

Commit

Permalink
Get everything build with latest toolkits, simplify build process
Browse files Browse the repository at this point in the history
  • Loading branch information
namazso committed Apr 12, 2020
1 parent c8d100e commit 0c70078
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 116 deletions.
100 changes: 51 additions & 49 deletions doc/HOWTOBUILD.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,64 @@
How to build
-------------

Personally, I use Visual Studio 2013 (msvc) to build mactype and all its dependencies, however, I believe you can build them with other compiles.
Here I will show you the steps I do to make the compilation.
# How to build

1. **Compiler / IDE**
msvc is preferred, I have provided a solution of msvc2013 in the repo. If you are using msvc2013+, just open my solution and you are ready to go. For msvc version lower than 2013, you have to make your own project.

Visual Studio 2019 with v142 toolkit has been tested and is working. Toolkits down to v120 should be able to compile the code, but be aware that the `_xp` ones might refuse to use the Windows 10 SDK.

2. **Dependencies**

Mactype depends on
- Freetype ([link](https://www.freetype.org/download.html))
- EasyHook ([link](http://easyhook.github.io/))
- or Detours(obsolete, better not use)
- iniParser (Get from my repo, orginal build is not fully functional)
- wow64ext (Get from my repo, or from official repo, but you need to modify it yourself)
- Windows sdk 10.0.14393.0 or later([link](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk))

3. **Building dependencies**
- FreeType
- [Freetype](https://www.freetype.org/download.html)
- [EasyHook](http://easyhook.github.io/)
- or Detours (obsolete, better not use)
- [IniParser (fork)](https://github.com/snowie2000/IniParser)
- [wow64ext (fork)](https://github.com/snowie2000/rewolf-wow64ext)
- Windows SDK (10.0.14393.0 or later)

3. **Building dependencies**

- FreeType

Apply `glyph_to_bitmapex.diff` before building.

Always build multi-thread release.

Remember to enable options you want in ftoptions.h

Compile freetype as Freetype.lib for x86 and freetype64.lib for x64

Static library is preferred, you are free to build freetype as independent dlls with better interchangeability but you will lose some compatibility in return, for some programs are delivered with their own copies of freetype which will conflict with your file.
- iniParser

Build as iniparser.lib and iniparser64.lib

- wow64ext
Build as wow64ext.lib. x64 library is not required. Dll library is also accepted (if you like).

- EasyHook
Remember to enable options you want in ftoptions.h

Compile freetype as freetype.lib for x86 and freetype64.lib for x64

Static library is preferred, you are free to build freetype as independent dlls with better interchangeability but you will lose some compatibility in return, for some programs are delivered with their own copies of freetype which will conflict with your file.

Set `FREETYPE_PATH` environment variable to root of freetype source.

- iniParser

Build as iniparser.lib and iniparser64.lib. Set `INI_PARSER_PATH` environment variable to root of IniParser project.

- wow64ext

Build as wow64ext.lib. x64 library is not required. Shared library also works if you prefer that.

- EasyHook

Only EasyHookDll project is required.

Build it as easyhk32.lib and easyhk64.lib.

Dll filename is not important but you'd better give it a special name to avoid dll confliction as I stated above.
- Windows SDK
Build it as easyhook32.lib and easyhook64.lib, or get the binary distributions.

Dll filename is not important but you'd better give it a special name to avoid dll confliction as stated above. Do not forget to modify filename in `hook.cpp` of MacType.

- Windows SDK

Actually it's not something you need to build, but the installation is tricky.

One word to rule them all: download **ALL COMPONENTS** in the installation list! Unless you want to waste several hours looking for these mysterious dependencies it pops to you. Don't worry, you will have a second chance to choose which component you want to install after download.
4. **Build**
One word to rule them all: download **ALL COMPONENTS** in the installation list! Unless you want to waste several hours looking for these mysterious dependencies it pops to you. Don't worry, you will have a second chance to choose which component you want to install after download.

4. **Build**

Last but easiest step: Put all `.lib` files you built earlier into a `lib` folder in the root of MacType, click build and enjoy.

Last but simplest step. Put all files you builds in the above steps to MacType folder, set up VC++ folders and hit F7.
Enjoy.
## FAQ

FAQ
-------
Q: Where are the sources of loader and tunner in the repo?
Q: Where are the sources of loader and tuner in the repo?

A: I'm sorry, but they are still close-source right now. Since you have the mactype source and will surely have a good understanding of how mactype works, I believe it's not a big challenge to write a loader for it.
If you wrote a great loader or something else wonderful, don't forget to send me link~
A: I'm sorry, but they are still closed-source right now. Since you have the mactype source and will surely have a good understanding of how mactype works, I believe it's not a big challenge to write a loader for it.
If you wrote a great loader or something else wonderful, please post an issue or a pull request. Hope we can make MacType better!
126 changes: 126 additions & 0 deletions doc/glyph_to_bitmapex.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
src/base/ftglyph.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 112 insertions(+)

diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 27402ecf8..7637388a8 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -634,6 +634,118 @@
}


+FT_EXPORT_DEF(FT_Error)
+ FT_Glyph_To_BitmapEx(FT_Glyph* the_glyph,
+ FT_Render_Mode render_mode,
+ FT_Vector* origin,
+ FT_Bool destroy,
+ FT_Bool loadcolor,
+ FT_UInt glyphindex,
+ FT_Face face)
+{
+ FT_GlyphSlotRec dummy;
+ FT_GlyphSlot_InternalRec dummy_internal;
+ FT_Error error = FT_Err_Ok;
+ FT_Glyph b, glyph;
+ FT_BitmapGlyph bitmap = NULL;
+ const FT_Glyph_Class* clazz;
+
+ FT_Library library;
+
+
+ /* check argument */
+ if (!the_glyph)
+ goto Bad;
+ glyph = *the_glyph;
+ if (!glyph)
+ goto Bad;
+
+ clazz = glyph->clazz;
+ library = glyph->library;
+ if (!library || !clazz)
+ goto Bad;
+
+ /* when called with a bitmap glyph, do nothing and return successfully */
+ if (clazz == &ft_bitmap_glyph_class)
+ goto Exit;
+
+ if (!clazz->glyph_prepare)
+ goto Bad;
+
+ /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
+ /* then calling FT_Render_Glyph_Internal() */
+
+ FT_ZERO(&dummy);
+ FT_ZERO(&dummy_internal);
+ dummy.internal = &dummy_internal;
+ dummy.library = library;
+ dummy.format = clazz->glyph_format;
+
+ if (loadcolor) {
+ dummy_internal.load_flags |= FT_LOAD_COLOR;
+ dummy.glyph_index = glyphindex;
+ dummy.face = face;
+ }
+
+ /* create result bitmap glyph */
+ error = ft_new_glyph(library, &ft_bitmap_glyph_class, &b);
+ if (error)
+ goto Exit;
+ bitmap = (FT_BitmapGlyph)b;
+
+#if 1
+ /* if `origin' is set, translate the glyph image */
+ if (origin)
+ FT_Glyph_Transform(glyph, 0, origin);
+#else
+ FT_UNUSED(origin);
+#endif
+
+ /* prepare dummy slot for rendering */
+ error = clazz->glyph_prepare(glyph, &dummy);
+ if (!error)
+ error = FT_Render_Glyph_Internal(glyph->library, &dummy, render_mode);
+
+#if 1
+ if (!destroy && origin)
+ {
+ FT_Vector v;
+
+
+ v.x = -origin->x;
+ v.y = -origin->y;
+ FT_Glyph_Transform(glyph, 0, &v);
+ }
+#endif
+
+ if (error)
+ goto Exit;
+
+ /* in case of success, copy the bitmap to the glyph bitmap */
+ error = ft_bitmap_glyph_init((FT_Glyph)bitmap, &dummy);
+ if (error)
+ goto Exit;
+
+ /* copy advance */
+ bitmap->root.advance = glyph->advance;
+
+ if (destroy)
+ FT_Done_Glyph(glyph);
+
+ *the_glyph = FT_GLYPH(bitmap);
+
+Exit:
+ if (error && bitmap)
+ FT_Done_Glyph(FT_GLYPH(bitmap));
+
+ return error;
+
+Bad:
+ error = FT_THROW(Invalid_Argument);
+ goto Exit;
+}
+
+
/* documentation is in ftglyph.h */

FT_EXPORT_DEF( void )
10 changes: 10 additions & 0 deletions ft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ void Log(wchar_t* Msg)
fclose(f);
}

FT_EXPORT_DEF(FT_Error)
FT_Glyph_To_BitmapEx(FT_Glyph* the_glyph,
FT_Render_Mode render_mode,
FT_Vector* origin,
FT_Bool destroy,
FT_Bool loadcolor,
FT_UInt glyphindex,
FT_Face face);


class CAlphaBlend
{
private:
Expand Down
2 changes: 1 addition & 1 deletion gdidll.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

Expand Down
Loading

3 comments on commit 0c70078

@wmjordan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Japanese comments in the source code was messed up in this commit.

@namazso
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wmjordan 65cb2f9 fixes it, should've asked snowie to squash the PR

@wmjordan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I overlooked it.

Please sign in to comment.