
João Pinto (Customer) asked a question.
How to use font after creating it at runtime
Hey guys. The problem is pretty simple. I'm trying to use a font after creating and i keep getting the same error and i don't know why: Can anyone spot the error in the following code?
- DEFINE TEMP-TABLE tt-test NO-UNDO
- FIELD oui AS CHAR
- FIELD croissant AS CHAR.
-
- CREATE tt-test.
- ASSIGN
- tt-test.oui = "2"
- tt-test.croissant = "3"
- .
-
- DEFINE FRAME cust-bal
- tt-test.oui
- tt-test.croissant
- WITH CENTERED ROW 3 TITLE "hon hon hon" USE-TEXT.
-
- FOR FIRST tt-test NO-LOCK WITH FRAME cust-bal:
- DISPLAY
- tt-test.oui
- tt-test.croissant .
- END.
- DEFINE VARIABLE i-FontIndex AS INTEGER NO-UNDO INITIAL 249.
- PUT-KEY-VALUE SECTION "fonts":U KEY "font":U + STRING(i-FontIndex) VALUE("Arial, size=32") NO-ERROR.
- FONT-TABLE:NUM-ENTRIES = i-FontIndex.
- MESSAGE 1
- SKIP FONT-TABLE:NUM-ENTRIES
- VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
- FRAME cust-bal:FONT = FONT-TABLE:NUM-ENTRIES.
There are a few issues and I'm not sure that you can make this work.
Font numbers have to be sequential. If you have fonts 0 through 7 the next one you add has to be 8. We stop reading them when we find a gap in the numbers. So adding font 249 won't work unless you have fonts 0 through 248 already.
Just adding the font to the "fonts" section doesn't change the set of fonts in use in the current session. You need to force a reload of the fonts by doing UNLOAD of the current environment and LOAD and USE of the new environment. But I tried that and I still couldn't make it recognize the new font. Maybe someone else has experience with this and has found a way to make it recognize a new font without restarting.
Hi Matt!
The sequential part is not a problem since I'm controlling that and it works perfectly. I also tried the "UNLOAD", "LOAD" and "USE" and the result was the same as yours, as expected.
Progress uses the following to save the font in runtime. Maybe there's a way to replicate that behavior?