part-cw / lambdanative

LambdaNative is a cross-platform development environment written in Scheme, supporting Android, iOS, BlackBerry 10, OS X, Linux, Windows, OpenBSD, NetBSD, FreeBSD and OpenWrt.
http://www.lambdanative.org
Other
1.4k stars 87 forks source link

Understanding Fonts #286

Open zwieblum opened 4 years ago

zwieblum commented 4 years ago

What is the best way to get crisp fonts? I ask this, because I always end up with mushy aliased fonts. In my understanding, fonts are created as one or more bitmaps from the ttf-fonts in the FONTS-file. So choosing a big font size in FONTS would create a bitmap with smaller antialiasing artefacts. But happens when using the fonts in the GUI? They still look as if they were antialiased a second time - bit where and why? Is there a way to prepare and use pixelperfect bitmaps for fonts?

mgorges commented 4 years ago

I don't think there is one - in the end we render pixmaps but don't include the actual traces or fonts to be rendered by the device as vectors. As for sizes I would not get them rescaled (scaled down from a larger font size) but get the correct size you need and include that size in the requested definitions. Finally, from personal experience, I always felt the LaTeX-rendered fonts looked much better than those made with GD?

zwieblum commented 4 years ago

LaTeX rendering is definitly better :) Correct me if I'm wrong: For me it looks like the only way to display fonts not-rescaled is to provide bitmaps for any pixel size from ~10 to 100, use the device default resolution and calculate the needed dimensions of elements and fonts myself. At the moment the font bitmaps are resized if the device resolution is not equal to the dimension given in (make-window ...).

It's been a while since I last used LN, but today I stumbled upon DemoHybridApp - this looks like the perfect way to get a native GUI. In fact, the application I want to port is a webinterface :)

mgorges commented 4 years ago

I have apps that make lots of different font sizes, but don't pick the 'best' one dynamically based on screen size, e.g. '12,16,20,24,40' - but its something you could consider.

I don't know if there are comprehensive examples for Hybrid apps, but we have one in production for a reasonably large research project (>10,000 participants) that uses a framework7 frontend for android (and in theory also iOS) with native widgets.

zwieblum commented 4 years ago

I just finished porting the project from C++ to lambdanative Hybride app. Codesize was reduced from ~ 900 lones to ~ 120 lines, so I'm quite satisfied whith that outcome.

@hybrid app: It looks like there are some glitches with

. As soon as a get-parameter is present, the browsers addressline becomes visible. If a form only has one submit-button without value, the resulting URL is of the form http://128.0.0.1:8080/? - which is not served by anything, not even the catchall-procedure. Anyway, when using POST, these things diappear.

ddunsmuir commented 4 years ago

I'll take a look at this when I get a chance.

ddunsmuir commented 4 years ago

The DemoHybridApp has a get call with three parameters. I do not see anything odd happen on Android and I don't see any change in the addressline on Mac. What platform are you using and can you give an example? Is this when it also goes to a new page? The DemoHybridApp stays on the same page.

If I remove the value from the submit button on the DemoHybridApp, the only change I see is that the button now has the default label Submit (again on Android and Mac). What am I missing here?

zwieblum commented 4 years ago

Please see attached testproject. The first page opens without addressbar. Clicking on the submit-button brings up the addressbar. Anyway, it might be a browser problem: on my android device the default browser is firefox.

gettest.tar.gz

You are right, DemoHybridApp does not show the problem. Looks like the reason is the <form ..> not having an action=...

ddunsmuir commented 4 years ago

I can run your example on Mac. When I press the second button on a.html it says "Invalid Request" and tries to go to http://127.0.0.1:8080/? . This doesn't meet your example though as this isn't a get and the submit value does have a value...? I assume the failure here happens because you have action="/". If I change "/" to "b.html" then it works. I assume it's the same issue on b.html. I assume we are not handling action="/". Do you mean action="./"?

It would not compile for me for Android. It says BUILD FAILED /usr/local/android-sdk-r25.2.5/tools/ant/build.xml:1109: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 61; Element type "activity" must be followed by either attribute specifications, ">" or "/>".

zwieblum commented 4 years ago

Please update your repository, that build problem was solved https://github.com/part-cw/lambdanative/issues/287 :)

Anyway, "Invalid request" happens when the 'catcall proc is not set. You can create a 'catchall proc, but on my system it still creates "Invalid request" --> I think there's a problem with the webserver on android (see the other issue that the webserver only works when binding to "*", not "127.0.0.1"). "/?" is absolutely valid, the URL sanitizer has to resolve it to a empty list of get parameters and "/" as the requested URL.

Running the same example on linux works like expected - but it's in a browser windows with addressbar, for sure.

zwieblum commented 4 years ago

Quick not on appearing addressbar: it does not appear when using submit-button or submit(), but appears in all other cases. (, location.replace() ...). And it depends on the pickiness of your browser.