freemint / fvdi

fVDI fork with additional fixes and drivers.
https://fvdi.sourceforge.io
7 stars 6 forks source link

Proper fix31 support #30

Open chrisridd opened 2 years ago

chrisridd commented 2 years ago

While fvdi supports the v_ftext() etc calls from SpeedoGDOS that use fractional advances (i.e. internally they move the pen position using fractional pixels) actually it just ends up calling v_gtext() which uses integer advances.

It seems NVDI 5 supports both calls correctly, as can be seen by comparing text rendered using v_gtext() (top), v_ftext() (middle) and overlayed for illustration (bottom):

ftext-example

Clearly as you render longer lines the errors accumulate.

FreeType uses fractional fixed-point values internally, so it should be possible to expose this through fvdi using the SpeedoGDOS fix31 type.

A brief review of the fvdi code suggests this would require quite changing quite a lot of existing assembler. VDI calls that would certainly need changing include:

This might mean adding fix31 versions of various existing Fontheader fields such as size (short) into Fontextra. Presumably an application can use vst_arbpt32() and then use v_gtext() so it would mean modifying existing non-fix31 code as well.

mfro0 commented 2 years ago

Hmmm. Merged too early, I suppose. Your changes broke applications that were working fine before. Font sizes aren't calculated correctly anymore and are rendered much too small.

What is supposed to look like this

grab0002

before, now looks like this grab0001

Text is rendered using vst_font(), vst_height() and v_ftext() (while using v_gtext() instead doesn't change anything). The sources for my test program are here: https://github.com/mfro0/libcmini-examples , if it helps.

@chrisridd Can you look into it again please to see if there is an easy fix? Otherwise I probably need to revert your changes.

chrisridd commented 2 years ago

Thanks for the test case! I will look later today. While working on the commit I had noticed Papyrus was using vst_height() with the system font and misbehaving, but the fix for that was clearly insufficient. Good catch.

chrisridd commented 2 years ago

Looks like a one line fix. PR #37 out for review.

🤞

mfro0 commented 2 years ago

https://github.com/freemint/fvdi/pull/37#issuecomment-1126942949