Skip to content

Commit

Permalink
fix macosx build
Browse files Browse the repository at this point in the history
  • Loading branch information
onecoolx committed Feb 20, 2023
1 parent b54bc2b commit ce32cc9
Show file tree
Hide file tree
Showing 6 changed files with 398 additions and 146 deletions.
42 changes: 40 additions & 2 deletions build/configs.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
},
}],
['OS=="macosx" or OS=="ios"', {
['OS=="macosx"', {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_OBJC_WEAK': 'YES',
Expand All @@ -55,6 +55,23 @@
'MACOSX_DEPLOYMENT_TARGET': '10.9',
},
}],
['OS=="ios"', {
'xcode_settings': {
'SDKROOT': 'iphoneos',
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_OBJC_WEAK': 'YES',
'CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW': 'YES',
'DEAD_CODE_STRIPPING': 'NO',
'ONLY_ACTIVE_ARCH': 'YES',
'ENABLE_TESTABILITY': 'YES',
'CODE_SIGN_IDENTITY': "-",
'GCC_UNROLL_LOOPS': 'NO',
'GCC_OPTIMIZATION_LEVEL': '0',
'GCC_ENABLE_CPP_EXCEPTIONS': "NO",
'GCC_ENABLE_CPP_RTTI': "NO",
'IPHONEOS_DEPLOYMENT_TARGET': '12.0',
},
}],
['OS=="linux"', {
'cflags_cc': [
'-O0',
Expand Down Expand Up @@ -118,7 +135,7 @@
},
},
}],
['OS=="macosx" or OS=="ios"', {
['OS=="macosx"', {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_CODE_COVERAGE': 'NO',
Expand All @@ -138,6 +155,27 @@
'MACOSX_DEPLOYMENT_TARGET': '10.9',
},
}],
['OS=="ios"', {
'xcode_settings': {
'SDKROOT': 'iphoneos',
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'CLANG_ENABLE_CODE_COVERAGE': 'NO',
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
'CLANG_ENABLE_OBJC_WEAK': 'YES',
'CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW': 'NO',
'DEAD_CODE_STRIPPING': 'YES',
'ONLY_ACTIVE_ARCH': 'NO',
'CODE_SIGN_IDENTITY': "-",
'LLVM_LTO': 'YES',
'ENABLE_TESTABILITY': 'NO',
'GCC_UNROLL_LOOPS': 'YES',
'GCC_OPTIMIZATION_LEVEL': '3',
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
'GCC_ENABLE_CPP_RTTI': 'NO',
'IPHONEOS_DEPLOYMENT_TARGET': '12.0',
},
}],
['OS=="linux"', {
'cflags_cc': [
'-O3',
Expand Down
92 changes: 68 additions & 24 deletions demos/demos.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,23 @@
'xcode_settings': {
'INFOPLIST_FILE': 'demos/Info.plist',
},
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
'conditions': [
['OS=="macosx"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
}],
['OS=="ios"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
],
},
}],
],
}],
],
'includes':[
Expand Down Expand Up @@ -112,12 +123,23 @@
'xcode_settings': {
'INFOPLIST_FILE': 'demos/Info.plist',
},
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
'conditions': [
['OS=="macosx"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
}],
['OS=="ios"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
],
},
}],
],
}],
],
'includes':[
Expand Down Expand Up @@ -172,12 +194,23 @@
'xcode_settings': {
'INFOPLIST_FILE': 'demos/Info.plist',
},
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
'conditions': [
['OS=="macosx"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
}],
['OS=="ios"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
],
},
}],
],
}],
],
'includes':[
Expand Down Expand Up @@ -232,12 +265,23 @@
'xcode_settings': {
'INFOPLIST_FILE': 'demos/Info.plist',
},
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
'conditions': [
['OS=="macosx"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
],
},
}],
['OS=="ios"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/UIKit.framework',
],
},
}],
],
}],
],
'includes':[
Expand Down
2 changes: 0 additions & 2 deletions src/gfx/gfx_font_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class gfx_font_adapter : public abstract_font_adapter
virtual void destroy_storage(void*);
virtual void translate_storage(void*, scalar x, scalar y);
private:
void load_kerning_pairs(void);
void sort_kerning_pairs(void);
font_adapter_impl* m_impl;
};

Expand Down
10 changes: 2 additions & 8 deletions src/gfx/gfx_font_adapter_apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
font = 0;
}

CTFontRef font;
CGAffineTransform matrix;
CGGlyph cur_glyph_index;
Expand All @@ -62,7 +62,6 @@
scalar descent;
scalar leading;
unsigned int units_per_em;

picasso::graphic_path cur_font_path;
rect cur_bound_rect;
scalar cur_advance_x;
Expand Down Expand Up @@ -233,12 +232,7 @@ static rect get_bounding_rect(graphic_path& path)
return m_impl->cur_advance_y;
}

void gfx_font_adapter::add_kerning(unsigned int first, unsigned int second, scalar* x, scalar* y)
{
//FIXME:implement
}


void gfx_font_adapter::add_kerning(unsigned int first, unsigned int second, scalar* x, scalar* y) { }
void gfx_font_adapter::active(void) { }
void gfx_font_adapter::deactive(void) { }
void* gfx_font_adapter::create_storage(byte* buf, unsigned int len, scalar x, scalar y) { return NULL; }
Expand Down
30 changes: 16 additions & 14 deletions src/gfx/gfx_font_adapter_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class font_adapter_impl
delete [] buf;
}

void load_kerning_pairs(void);
void sort_kerning_pairs(void);

HFONT font;
bool antialias;
bool flip_y;
Expand Down Expand Up @@ -199,39 +202,38 @@ static int pair_less(const void* v1, const void* v2)
}


void gfx_font_adapter::load_kerning_pairs(void)
void font_adapter_impl::load_kerning_pairs(void)
{
if (m_impl->dc) {
if (!m_impl->kerning_pairs) {
m_impl->kerning_pairs = new KERNINGPAIR [16384-16];
m_impl->max_kerning_pairs = 16384-16;
if (dc) {
if (!kerning_pairs) {
kerning_pairs = new KERNINGPAIR [16384-16];
max_kerning_pairs = 16384-16;
}

m_impl->num_kerning_pairs = ::GetKerningPairs(m_impl->dc,
m_impl->max_kerning_pairs, m_impl->kerning_pairs);
num_kerning_pairs = ::GetKerningPairs(dc, max_kerning_pairs, kerning_pairs);

if (m_impl->num_kerning_pairs) {
for (unsigned int i = 1; i < m_impl->num_kerning_pairs; ++i) {
if (pair_less(&m_impl->kerning_pairs[i - 1], &m_impl->kerning_pairs[i]) >= 0) {
if (num_kerning_pairs) {
for (unsigned int i = 1; i < num_kerning_pairs; ++i) {
if (pair_less(&kerning_pairs[i - 1], &kerning_pairs[i]) >= 0) {
sort_kerning_pairs();
break;
}
}
}
m_impl->kerning_loaded = true;
kerning_loaded = true;
}
}

void gfx_font_adapter::sort_kerning_pairs(void)
void font_adapter_impl::sort_kerning_pairs(void)
{
qsort(m_impl->kerning_pairs, m_impl->num_kerning_pairs, sizeof(KERNINGPAIR), pair_less);
qsort(kerning_pairs, num_kerning_pairs, sizeof(KERNINGPAIR), pair_less);
}

void gfx_font_adapter::add_kerning(unsigned int first, unsigned int second, scalar* x, scalar* y)
{
if (m_impl->dc) {
if (!m_impl->kerning_loaded) {
load_kerning_pairs();
m_impl->load_kerning_pairs();
}

int end = m_impl->num_kerning_pairs - 1;
Expand Down
Loading

0 comments on commit ce32cc9

Please sign in to comment.