Skip to content

Commit 69a2d7f

Browse files
committed
ANDROID: add ubuntu mono font
1 parent e04de50 commit 69a2d7f

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

src/platform/android/app/src/main/assets/main.bas

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,17 @@ sub do_setup()
187187
print "Envy Code R:"
188188
print " http://damieng.com/envy-code-r"
189189
print "Inconsolata:"
190-
print " Copyright 2006 The Inconsolata Project Authors"
190+
print " Copyright 2006 The Inconsolata Project"
191191
print " http://scripts.sil.org/OFL"
192+
print "Ubuntu:"
193+
print " https://ubuntu.com/legal/font-licence"
192194
print
193195
dim frm.inputs(1)
194196
frm.inputs(0).type="list"
195-
frm.inputs(0).value="Inconsolata|Envy Code R"
197+
frm.inputs(0).value="Inconsolata|Envy Code R|UbuntuMono"
196198
frm.inputs(0).selectedIndex=env("fontId")
197-
frm.inputs(0).height=TXTH("Q")*2+4
199+
frm.inputs(0).height=TXTH("Q")*3+4
200+
frm.inputs(0).width=TXTW("Q")*12
198201
frm = form(frm)
199202
frm.doEvents()
200203
env("fontId=" + frm.inputs(0).selectedIndex)

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import java.net.URLDecoder;
6666
import java.nio.file.Files;
6767
import java.nio.file.Path;
68-
import java.nio.file.Paths;
6968
import java.util.Date;
7069
import java.util.Enumeration;
7170
import java.util.HashMap;
@@ -811,7 +810,7 @@ private Map<String, String> getPostData(DataInputStream inputStream, final Strin
811810
String nextLine = line;
812811
while (nextLine != null && nextLine.length() > 0) {
813812
if (nextLine.toLowerCase(Locale.ENGLISH).startsWith(lengthHeader)) {
814-
length = Integer.valueOf(nextLine.substring(lengthHeader.length()));
813+
length = Integer.parseInt(nextLine.substring(lengthHeader.length()));
815814
}
816815
nextLine = readLine(inputStream);
817816
}
@@ -919,7 +918,7 @@ private void processSettings() {
919918
try {
920919
Properties p = new Properties();
921920
p.load(getApplication().openFileInput("settings.txt"));
922-
int socket = Integer.valueOf(p.getProperty("serverSocket", "-1"));
921+
int socket = Integer.parseInt(p.getProperty("serverSocket", "-1"));
923922
String token = p.getProperty("serverToken", new Date().toString());
924923
if (socket != -1) {
925924
startServer(socket, token);

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/Sound.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void setSilent(boolean silent) {
5353
*/
5454
private byte[] generateTone(int freqOfTone, int durationMillis) {
5555
int numSamples = Math.max(1, durationMillis * AUDIO_SAMPLE_RATE / 1000);
56-
double sample[] = new double[numSamples];
57-
byte result[] = new byte[2 * numSamples];
56+
double[] sample = new double[numSamples];
57+
byte[] result = new byte[2 * numSamples];
5858

5959
for (int i = 0; i < numSamples; ++i) {
6060
// Fill the sample array

src/platform/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.1.1'
8+
classpath 'com.android.tools.build:gradle:4.1.3'
99
classpath "com.github.ben-manes:gradle-versions-plugin:0.22.0"
1010
}
1111
}

src/platform/android/jni/display.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define FONT_FACE_BOLD_0 "Inconsolata-Bold.ttf"
1717
#define FONT_FACE_REGULAR_1 "Envy Code R.ttf"
1818
#define FONT_FACE_BOLD_1 "Envy Code R Bold.ttf"
19+
#define FONT_FACE_REGULAR_2 "UbuntuMono-Regular.ttf"
20+
#define FONT_FACE_BOLD_2 "UbuntuMono-Bold.ttf"
1921

2022
extern ui::Graphics *graphics;
2123

@@ -197,6 +199,10 @@ bool Graphics::loadFonts(int fontId) {
197199
regularName = FONT_FACE_REGULAR_1;
198200
boldName = FONT_FACE_BOLD_1;
199201
break;
202+
case 2:
203+
regularName = FONT_FACE_REGULAR_2;
204+
boldName = FONT_FACE_BOLD_2;
205+
break;
200206
default:
201207
regularName = FONT_FACE_REGULAR_0;
202208
boldName = FONT_FACE_BOLD_0;

src/ui/image.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,16 @@ void screen_dump() {
476476
if (image != nullptr) {
477477
const char *path = gsb_bas_dir;
478478
#if defined(_ANDROID)
479-
path = getenv("EXTERNAL_STORAGE");
479+
path = getenv("EXTERNAL_DIR");
480480
#endif
481481
for (int i = 0; i < 1000; i++) {
482482
String file;
483483
if (strstr(path, "://") == nullptr) {
484484
file.append(path);
485485
}
486+
if (file.lastChar() != '/') {
487+
file.append("/");
488+
}
486489
file.append("sbasic_dump_");
487490
file.append(i);
488491
file.append(".png");

src/ui/strlib.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ int main() {
386386
assertEq(1, s3.equals("CATS", true));
387387
assertEq(0, s3.equals("CATS", false));
388388
assertEq(1, s3.equals("cats", false));
389+
assertEq('x', s1.lastChar());
390+
assertEq('\0', s2.lastChar());
391+
assertEq('s', s3.lastChar());
389392
return 0;
390393
}
391394
#endif

src/ui/strlib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct String {
5050
int indexOf(char chr, int fromIndex) const;
5151
int indexOf(const char *s, int fromIndex) const;
5252
bool empty() const { return _buffer == NULL || _buffer[0] == '\0'; };
53+
char lastChar() const { return (_buffer == NULL || !_buffer[0] ? '\0' : _buffer[strlen(_buffer) - 1]); }
5354
int lastIndexOf(char chr, int untilIndex) const;
5455
int length() const { return (_buffer == NULL ? 0 : strlen(_buffer)); }
5556
String leftOf(char ch) const;

0 commit comments

Comments
 (0)