Skip to content

Commit 718a1ca

Browse files
committed
eliminated several more android errors
1 parent 5d02f28 commit 718a1ca

3 files changed

Lines changed: 70 additions & 6 deletions

File tree

engine/src/mblandroidfont.cpp

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,63 @@ static const MCAndroidDroidFontMap s_droid_fonts[] = {
8484
static void MCAndroidCustomFontsList(char *&r_font_names);
8585
static MCAndroidFontStyle MCAndroidCustomFontsGetStyle(const char *p_name);
8686

87+
bool MCSystemListFontFamilies(MCListRef& r_names)
88+
{
89+
MCAutoListRef t_list;
90+
if (!MCListCreateMutable('\n', &t_list))
91+
return false;
92+
for (uint32_t i = 0; s_droid_fonts[i].name != nil; i++)
93+
if (!MCListAppendCString(*t_list, s_droid_fonts[i].name))
94+
return false;
95+
96+
char *t_custom_font_names;
97+
MCAndroidCustomFontsList(t_custom_font_names);
98+
if (!MCListAppendCString(*t_list, t_custom_font_names))
99+
return false;
100+
101+
MCCStringFree(t_custom_font_names);
102+
103+
return MCListCopy(*t_list, r_names);
104+
}
105+
106+
bool MCSystemListFontsForFamily(MCStringRef p_family, MCListRef& r_styles)
107+
{
108+
uint32_t t_styles;
109+
t_styles = 0;
110+
111+
for (uint32_t i = 0; s_droid_fonts[i].name != nil; i++)
112+
{
113+
if (MCStringIsEqualToCString(p_family, s_droid_fonts[i].name, kMCCompareCaseless))
114+
{
115+
t_styles = s_droid_fonts[i].styles;
116+
break;
117+
}
118+
}
119+
120+
if (t_styles == 0)
121+
t_styles = MCAndroidCustomFontsGetStyle(MCStringGetCString(p_family));
122+
123+
124+
MCAutoListRef t_list;
125+
if (!MCListCreateMutable('\n', &t_list))
126+
return false;
127+
128+
if (t_styles & kMCAndroidFontStyleRegular)
129+
if (!MCListAppendCString(*t_list, "plain"))
130+
return false;
131+
if (t_styles & kMCAndroidFontStyleBold)
132+
if (!MCListAppendCString(*t_list, "bold"))
133+
return false;
134+
if (t_styles & kMCAndroidFontStyleItalic)
135+
if (!MCListAppendCString(*t_list, "italic"))
136+
return false;
137+
if (t_styles & kMCAndroidFontStyleBoldItalic)
138+
if (!MCListAppendCString(*t_list, "bold-italic"))
139+
return false;
140+
141+
return MCListCopy(*t_list, r_styles);
142+
}
143+
/*
87144
void MCSystemListFontFamilies(MCExecPoint& ep)
88145
{
89146
ep . clear();
@@ -95,13 +152,13 @@ void MCSystemListFontFamilies(MCExecPoint& ep)
95152
MCAndroidCustomFontsList(t_custom_font_names);
96153
if (t_custom_font_names != nil)
97154
ep.concatcstring(t_custom_font_names, EC_RETURN, ep.getsvalue().getlength() == 0);
98-
/*UNCHECKED */ MCCStringFree(t_custom_font_names);
155+
MCCStringFree(t_custom_font_names);
99156
}
100157
158+
101159
bool MCSystemListFontsForFamily(MCExecPoint& ep, const char *p_family)
102160
{
103-
// TODO
104-
/* uint32_t t_styles;
161+
uint32_t t_styles;
105162
t_styles = 0;
106163
107164
for (uint32_t i = 0; s_droid_fonts[i].name != nil; i++)
@@ -124,11 +181,11 @@ bool MCSystemListFontsForFamily(MCExecPoint& ep, const char *p_family)
124181
if (t_styles & kMCAndroidFontStyleItalic)
125182
ep.concatcstring("italic", EC_RETURN, ep.getsvalue().getlength() == 0);
126183
if (t_styles & kMCAndroidFontStyleBoldItalic)
127-
ep.concatcstring("bold-italic", EC_RETURN, ep.getsvalue().getlength() == 0); */
184+
ep.concatcstring("bold-italic", EC_RETURN, ep.getsvalue().getlength() == 0);
128185
129186
return false;
130187
}
131-
188+
*/
132189
////////////////////////////////////////////////////////////////////////////////
133190

134191
struct MCAndroidCustomFont {

libfoundation/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ LOCAL_MODULE := libfoundation
99
LOCAL_SRC_FILES := src/foundation-array.cpp src/foundation-core.cpp src/foundation-debug.cpp \
1010
src/foundation-list.cpp src/foundation-name.cpp src/foundation-nativechars.cpp \
1111
src/foundation-number.cpp src/foundation-set.cpp src/foundation-stream.cpp \
12-
src/foundation-string.cpp src/foundation-unicodechars.cpp src/foundation-value.cpp
12+
src/foundation-string.cpp src/foundation-unicodechars.cpp src/foundation-value.cpp \
13+
src/foundation-error.cpp
1314

1415
LOCAL_C_INCLUDES := \
1516
$(LOCAL_PATH)/include

libfoundation/src/foundation-debug.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ void __MCLog(const char *p_file, uint32_t p_line, const char *p_format, ...)
178178
va_end(args);
179179
}
180180

181+
void __MCUnreachable(void)
182+
{
183+
fprintf(stderr, "**** UNREACHABLE CODE EXECUTED ****\n");
184+
abort();
185+
}
186+
181187
#endif
182188

183189
#endif

0 commit comments

Comments
 (0)