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: imageCan anyone spot the error in the following code?

  1. DEFINE TEMP-TABLE tt-test NO-UNDO
  2. FIELD oui AS CHAR
  3. FIELD croissant AS CHAR.
  4.  
  5. CREATE tt-test.
  6. ASSIGN
  7. tt-test.oui = "2"
  8. tt-test.croissant = "3"
  9. .
  10.  
  11. DEFINE FRAME cust-bal
  12. tt-test.oui
  13. tt-test.croissant
  14. WITH CENTERED ROW 3 TITLE "hon hon hon" USE-TEXT.
  15.  
  16. FOR FIRST tt-test NO-LOCK WITH FRAME cust-bal:
  17. DISPLAY
  18. tt-test.oui
  19. tt-test.croissant .
  20. END.
  21. DEFINE VARIABLE i-FontIndex AS INTEGER NO-UNDO INITIAL 249.
  22. PUT-KEY-VALUE SECTION "fonts":U KEY "font":U + STRING(i-FontIndex) VALUE("Arial, size=32") NO-ERROR.
  23. FONT-TABLE:NUM-ENTRIES = i-FontIndex.
  24. MESSAGE 1
  25. SKIP FONT-TABLE:NUM-ENTRIES
  26. VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
  27. FRAME cust-bal:FONT = FONT-TABLE:NUM-ENTRIES.

 


Peter Judge likes this.
  • Matt Gilarde (Progress Software)

    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.

    • João Pinto (Customer)

      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.

  • João Pinto (Customer)

    Progress uses the following to save the font in runtime. Maybe there's a way to replicate that behavior?

    image