Closed stevesims closed 3 months ago
whilst the code in this PR works, there is a significant flaw in how selected fonts are handled. if the buffer for a font is deleted, then the font definition will be removed, but the graphics system will continue to use the font. this appears to "work", but in reality it will only work until the memory the font data lives in gets reassigned, at which point at best the font rendering will be corrupted
the fix for this is to either ensure that on buffer deletion all uses of the font are changed back to system font, or to keep hold of the underlying font data for as long as it's needed.
the latter approach is the direction I've taken, but that work has been done on #200 - as that PR builds on this one
for now this PR will be left open for the curious, but it will eventually be closed in favour of #200
this functionality was added via #200
adds commands for buffer-backed fonts...
VDU 23,0,&95,0,<bufferId>;flags
selects a font, assuming the buffer has been marked as containing a font using bufferId of 65535 will reset back to the system font the flags byte currently only supports bit zero, which indicates that the cursor position should be automatically tweaked so baselines match when picking a differently sized fontVDU 23,0,&95,1,<bufferId>;<width>,<height>,<ascent>,<flags>
marks a buffer as containing a fontflags
is here for future use - fab-gl/vdp-gl fonts can have flags that indicate italic, underline, strikeout, and variable width. of those only variable width actually has any meaning.VDU 23,0,&95,2,<bufferId>;<field>,<value>;
allows font information to be adjusted, allowing the setting of some extended information on a font. for the most part, this extended information has no effect with the current font rendering system. (more info when I write the real documentation - meanwhile you can read the source code to find out how this command works if you really want to)VDU 23,0,&95,4,<bufferId>;
clears font definition with given buffer ID, or clears all if sent 65535. Does not remove buffersVDU 23,0,&95,5,<bufferId>;
copies the system font definition into a given buffer. the buffer will be cleared before copy, and a new font will be defined. (system font remains intact). this allows copies of the system font to be manipulated without affecting the system fontVDU 23,0,&8C,<x>,<y>
performs a relative movement on the currently active cursor. this will allow features such as manual kerning, super-script and subscript printing, without needing to switch away from the text cursor to the graphics cursorcursor block now defaults to 255x255 size which, on rendering, is always restricted to font size. it therefore still looks the same, and doesn’t stay stuck at the 8x8 size when you change to a larger font
VDU 23,0,&93,<x>;<y>;
new version of "get screen character" that accepts graphics system coordinates, rather than text coordinatesVDU 23,0,&9C,<x1>;<y1>;<x2>;<y2>;
defines a text viewport using graphical coordinates coordinates must be given using currently selected graphical coordinates system. exact corners given doesn't matterTODO:
getScreenChar needs reworking for different sized fonts. that work has only been partially donebuffer deletion needs to delete corresponding fontssupport for variable width fonts (probably parking this feature for now, as the character-at-a-time method of printing we use doesn't appear to support variable width fonts)