Commit da56e690 authored by Chris Wraight's avatar Chris Wraight Committed by ROOL
Browse files

[472] Make error handling when painting fonts less strict

Bad characters are skipped, replaced with a rectangle, and an error displayed, rather than reverting to the System Font.

Version 2.05. Tagged as 'Chars-2_05'
parent 6c0a0c7f
......@@ -34,16 +34,16 @@ Help:Help...
Choices:Choices...
# Error messages
ErrApp:!Chars
ErrApp:Chars
Fatal1:There is not enough memory to run Chars. Free up more memory by closing other applications.
Fatal2:There is not enough memory to create the font list. Free up more memory by closing other applications.
Fatal3:There is not enough memory to create the font list. Restart Chars to try again.
FontErr1:Chars is unable to display the selected font.
FontErr2:There is not enough memory to display the selected font.
FontErr3:Chars cannot find the selected font in this encoding; reverting to the default encoding.
FontErr5:Cannot scan string in this font; reverting to System Font
FontErr6:Cannot paint this font; reverting to System Font
FontErr7:The installed version of the Font Manager cannot display fonts with more than 255 entries in the internal encoding file; reverting to System Font.
FontErr4:Chars cannot display this font; reverting to System Font.
FontErr5:The installed version of the Font Manager cannot display fonts with more than 255 entries in the internal encoding file; reverting to System Font.
CharErr:An error occurred during font painting. Some characters may not be displayed correctly, and the font may cause errors if used in other applications.
#{HelpTokens}
CHelp:Click \s or press Shift to enter %0.
......
;
; This file is automatically maintained by srccommit, do not edit manually.
; Last processed by srccommit version: 1.1.
;
GBLS Module_MajorVersion
GBLA Module_Version
......@@ -10,14 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.04"
Module_Version SETA 204
Module_MajorVersion SETS "2.05"
Module_Version SETA 205
Module_MinorVersion SETS ""
Module_Date SETS "13 Apr 2018"
Module_ApplicationDate SETS "13-Apr-18"
Module_Date SETS "25 Apr 2020"
Module_ApplicationDate SETS "25-Apr-20"
Module_ComponentName SETS "Chars"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Chars"
Module_FullVersion SETS "2.04"
Module_HelpVersion SETS "2.04 (13 Apr 2018)"
Module_FullVersion SETS "2.05"
Module_HelpVersion SETS "2.05 (25 Apr 2020)"
END
/* (2.04)
/* (2.05)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.04
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Apr 2018
#define Module_MajorVersion_CMHG 2.05
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Apr 2020
#define Module_MajorVersion "2.04"
#define Module_Version 204
#define Module_MajorVersion "2.05"
#define Module_Version 205
#define Module_MinorVersion ""
#define Module_Date "13 Apr 2018"
#define Module_Date "25 Apr 2020"
#define Module_ApplicationDate "13-Apr-18"
#define Module_ApplicationDate "25-Apr-20"
#define Module_ComponentName "Chars"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Chars"
#define Module_FullVersion "2.04"
#define Module_HelpVersion "2.04 (13 Apr 2018)"
#define Module_LibraryVersionInfo "2:4"
#define Module_FullVersion "2.05"
#define Module_HelpVersion "2.05 (25 Apr 2020)"
#define Module_LibraryVersionInfo "2:5"
......@@ -87,6 +87,7 @@ Encoding$="" :REM Encoding name
Encodings%=0 :REM Total encodings on system
Alphabet$="" :REM System encoding 'Alphabet'
DesktopFont$=FNchars_getdesktopfont :REM Desktop font name
CharError%=0 :REM Error count for viewer redraw
REM GUI/window redrawing
FirstOpen%=TRUE :REM First-time open flag
......@@ -386,6 +387,7 @@ IF ucode%<&800 THEN =CHR$(&C0+(ucode%>>>6))+CHR$(&80+(ucode% AND &3F))
DEF PROCchars_changefont (font$)
REM Change the current Font
LOCAL flags%,encoding%,type%,claim%,ptr%,i%,f$
CharError%=0
IF UCSManager% THEN
IF Lookup% THEN PROCheap_freeblock(Lookup%):Lookup%=FALSE
ENDIF
......@@ -469,7 +471,7 @@ ELSE
REPEAT
IF LEFT$(GET$#file%,1)="/" THEN i%+=1
UNTIL EOF#file% OR i%>256
IF i%>256 THEN PROCchars_fonterror("FontErr7"):ENDPROC
IF i%>256 THEN PROCchars_fonterror("FontErr5"):ENDPROC
CLOSE#file%
ENDIF
ENDIF
......@@ -624,6 +626,13 @@ SYS "Wimp_CreateMenu",-1
PROCchars_changefont(SysFont$)
ENDPROC
DEF PROCchars_charerror (ex%,ey%)
REM Skip a char in redraw if it can't be drawn
SYS "Wimp_SetColour",11
RECTANGLE ex%,ey%-8,32,32
IF CharError%=0 THEN CharError%=1
ENDPROC
DEF FNchars_fonttype (font$)
REM Returns 1 if font is System font
IF font$=SysFont$ THEN =1 ELSE =font$
......@@ -810,9 +819,12 @@ WHILE more%
REM Centre the character and paint it
SYS "XFont_ScanString",,CharDef%,ssflags%,1000000,1000000,,,4 TO e%,,,width%;flags%
IF flags% AND 1 THEN PROCchars_fonterror("FontErr5"):ENDPROC
SYS "XFont_Paint",,CharDef%,fpflags%,cx%-(width% DIV 800)+(CHAR_XBOX% DIV 2),cy% TO e%;flags%
IF flags% AND 1 THEN PROCchars_fonterror("FontErr6"):ENDPROC
IF flags% AND 1 THEN
PROCchars_charerror(cx%,cy%)
ELSE
SYS "XFont_Paint",,CharDef%,fpflags%,cx%-(width% DIV 800)+(CHAR_XBOX% DIV 2),cy% TO e%;flags%
IF flags% AND 1 THEN PROCchars_charerror(cx%,cy%)
ENDIF
cx%+=CHAR_XBOX%
IF cx%>xlimit% THEN cx%=xorigin%:cy%-=CHAR_YBOX%
IF cy%<ylimit% THEN c%=end%
......@@ -840,6 +852,7 @@ ENDWHILE
REM Tidy up
IF FontHandle%=FONT_SYSFONT% THEN VDU 23,17,7,4,16>>XEig%;32>>YEig%;0;
IF CharError%=1 THEN PROCwimp_alert("CharErr"):CharError%=2
ENDPROC
DEF PROCchars_tidyup
......@@ -974,7 +987,7 @@ SYS "Wimp_CloseTemplate"
REM Create iconbar icon and update version in Info
Block%!0=-1:Block%!4=0:Block%!8=0:Block%!12=68:Block%!16=68
Block%!20=&3002:$(Block%+24)=FNmsg_get("ErrApp")
Block%!20=&3002:$(Block%+24)="!chars"
SYS "Wimp_CreateIcon",,Block% TO IconHandle%
PROCwimp_seticontext(InfoWin%,4,FNmsg_get("_Version"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment