support: Customer Portal
Focused on delivering choice, investment protection and flexibility to organizations with valuable COBOL assets
 

Veryant Knowledge Base
Home > All Categories > isCOBOL General > User Interface > How to use font-based icons in isCOBOL GUI programs
Question Title How to use font-based icons in isCOBOL GUI programs

When your GUI application is going to need a large variety of different bitmaps for any kind of GUI control that accepts a bitmap for its icon, you can use font-based bitmaps instead of trying to get different images for each control. Bitmap fonts provide a comprehensive set of glyphs, or icons.
In this article we will use one of the most popular bitmap fonts: FontAwesome. You can download it from: www.fontawesome.com.
However, any bitmap font can be used (Material Design Font, dafont.com, etc)
The .otf file that you download can be located in any folder that you choose. You create a named font with W$CREATEFONT that points to the path (full or relative) of the font.

   move "Font Awesome 5 Free Solid" to font-name
   call "w$createfont" using "files/Font Awesome 5 Free-Solid-900.otf"
                             font-name
Then you load a font with W$FONT based on that named font.
   initialize wfont-data
   set wfdevice-console to true
   move font-name       to wfont-name
   move 10              to wfont-size
   call "w$font" using wfont-get-font
                       h-font
                       wfont-data
Now, in order to use some of the icons from that font for your program, you need to create a strip of selected icons.
The FontAwesome font uses a hexadecimal code of 4 characters to refer to their icons.
Here's a link to all of the available icons and their hex codes: https://fontawesome.com/v5/cheatsheet
Each of those hex codes need to be converted to a decimal value and then combined in a national variable as in this example:
 77  character-1-hex         pic x(4).
 77  character-1-n           pic n(1).
 77  character-1-red         pic x(2) comp-x 
                                      redefines character-1-n.
 ...

 77  icon-characters         pic n any length.

 ...

   move "f1c3" to character-1-hex
   move "f576" to character-2-hex
   move "f008" to character-3-hex

   move function hex2dec(character-1-hex) to character-1-red
   move function hex2dec(character-2-hex) to character-2-red
   move function hex2dec(character-3-hex) to character-3-red

   initialize icon-characters 
   string character-1-n delimited by space
          character-2-n delimited by space
          character-3-n delimited by space
          into icon-characters.
Once you have the list of decimal values in a national string, you can create the bitmap strip in memory, using the W$BITMAP routine:
   call "w$bitmap" using wbitmap-load-symbol-font, 
                         h-font
                         icon-characters
                         20
                         icon-color
                  giving h-font-icon
Now, since the h-font-icon handle of font contains the strip of icons 20 pixels each, you can assign icons from it to a GUI control on the screen section:
    03 ef-1 
       entry-field
       line                       5
       col                        15
       size                       20 cells
       lines                      2 cells
       bitmap-handle              h-font-icon
       bitmap-width               20
       bitmap-number              1
       .

    03 pb-1
       push-button
       line                       9
       col                        15
       lines                      2 cells
       size                       20 cells
       bitmap-handle              h-font-icon
       bitmap-width               20
       title-position             2
       title                      "Option A"
       bitmap-number              2
       .
This code creates part of a simple example screen that looks like this:

Attached is a zip file with a full sample of using the FontAwesome bitmap font. After downloading it, you can compile:
iscc  fontawesome.cbl
and run:
iscrun FONTAWESOME

Authored by: Veryant Support This question has been viewed 536 times so far.
Click Here to View all the questions in User Interface category.
File Attachments File Attachments
How helpful was this article to you?
User Comments User Comments Add Comment
There are no user comments for this question. Be the first to post a comment. Click Here
Related Questions Related Questions
  1. How do I center a window on the desktop?
  2. UNC Paths with Browser Control don't work. What can I do to solve it?
  3. Does isCOBOL provide GUI design support?
  4. How to copy data from the clipboard
  5. iscobol.font.default and DEFAULT-FONT
  6. What are the specific fonts that isCOBOL uses by default?
  7. Can I have an entry-field that more or less works the same as Google Search? So I would like to be able to change the contents of the list while the user is typing...
  8. Does isCOBOL provide Graph modules to show statistics?
  9. Did you know isCOBOL has the Accordion control?
  10. Is it possible to sort dates in a grid control?
  11. Working with a grid control is there a way to get the double-click event?
  12. How can I refresh the current contents of the paged grid?
  13. How can I show an animated gif with isCOBOL?
  14. Is there a way to show leading zeros when numeric data items are displayed on a character based screen?
  15. Did you know isCOBOL supports a tip inside the entry-field and combo-box controls when they are empty?
  16. Did you know how to customize color of the borders of some controls?
  17. Is it possible to configure the color of the read-only entry-fields?
  18. Did you know that you can protect a Grid from editing without coding any event?
  19. Gradient effects
  20. How to detect if a computer has more than one monitor and use any of them?
  21. How may I display a notification window that requires no user intervention?
  22. Do isCOBOL GUI Screens have resizing capabilities?
  23. How to add pages and GUI controls inside them to a tab control dynamically?
  24. Can I modify the GUI controls of a Screen program from a called routine?
  25. How to deploy bitmaps when running in application server
  26. Modernizing your COBOL application by using isCOBOL Compiler code injection
  27. Modernize your character application
Article Information Additional Information
Article Number: 325
Created: 2022-01-10 1:57 AM
Rating: No Rating
 
Article Options Article Options
Print Question Print this Question
Email Question Email Question to Friend
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Bookmark Article
Subscribe to Article Subscribe to Article
 
Search Knowledge Base Search Knowledge Base



 
 

© Veryant - All Rights Reserved
Veryant and isCOBOL are trademarks or registered marks of Veryant in the United States and other countries. All other marks are the property of their respective owners.