How to use Segoe MDL2 icons on Win 7 ?

How to use Segoe MDL2 icons on Win 7 ?

Postby shri_fwh » Mon Jun 17, 2019 12:47 pm

Dear All ,

Want to use MS Segoe MDL2 icons in the application. Could you please provide help on this. Thanks in advance...!

Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby ukoenig » Mon Jun 17, 2019 3:30 pm

Want to use MS Segoe MDL2 icons in the application.
Could you please provide help on this. Thanks in advance...!


Thanks to Mr. Rao,

just a question.
I noticed the images are painted to much to the right

Image

Code: Select all  Expand view

#include "fivewin.ch"

FUNCTION MAIN()
local aData := {}
local oFont, oSymbol
local oDlg, oBrw
local n, oBtn1, oBtn2, oBtn3

FOR n := 0xE100 to 0XE140
      AAdd( aData, { n, HB_UTF8CHR( n ) } )
NEXT

DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-20
IF IsWindows10()
      DEFINE FONT oSymbol NAME "Segoe MDL2 Assets" SIZE 0,-20
ELSE
      DEFINE FONT oSymbol NAME "Segoe UI Symbol" SIZE 0,-20
ENDIF

DEFINE DIALOG oDlg SIZE 350,550 PIXEL TRUEPIXEL FONT oFont

@ 20,20 XBROWSE oBrw SIZE -150, -20 PIXEL OF oDlg DATASOURCE aData ;
AUTOCOLS NOBORDER

// for HARBOUR = HB_NUMTOHEX
oBrw:aCols[ 1 ]:bEditValue := { || NUMTOHEX( oBrw:aRow[ 1 ] ) }
oBrw:aCols[ 2 ]:oDataFont  := oSymbol
oBrw:CreateFromCode()
 
@ 80, 220 BTNBMP oBtn1 PROMPT " Save " RESOURCE 0xE115 TOP 2007 ROUND OF oDlg SIZE 100, 120
//FWH understands that the number 0xE105 should be displayed as a symbol.
// oBtn1:lAdjust := .T.

@ 220, 220 BTNBMP oBtn2 PROMPT " Save " RESOURCE 0xE105 LEFT 2007 ROUND OF oDlg SIZE 120, 100

@ 350, 220 BTNBMP oBtn3 PROMPT " Exit " RESOURCE 0xE10F ACTION oDlg:End() LEFT 2007 OF oDlg SIZE 120, 100
//FWH understands that the number 0xE105 should be displayed as a symbol.


ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oSymbol

RETURN NIL
 


Regards
Uwe :D
Last edited by ukoenig on Wed Jun 19, 2019 8:03 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby shri_fwh » Mon Jun 17, 2019 3:38 pm

Hi Uwe ,

Many Thanks for this code.

Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby ukoenig » Mon Jun 17, 2019 6:41 pm

Bitmap and font-symbol with different adjustment :?

Image

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Mon Jun 17, 2019 10:44 pm

Edit the imgtxtio.prg file at line 785.
Original:
Code: Select all  Expand view

      if lSegoe
         nHeight     := Int( Min( aRect[ 1 ] - aRect[ 3 ], aRect[ 4 ] - aRect[ 2 ] ) * 0.6 )
         cFace    := If( lWin10, "Segoe MDL2 Assets", "Segoe UI Symbol" )
         DEFINE FONT oFont NAME cFace SIZE 0, -nHeight
         if oFont:hFont == 0
            lSegoe  := .f.
         else
            cText    := HB_UTF8CHR( nChr )
            nBkMode  := SetBkMode( hDC, TRANSPARENT )
            x     := Int( 0.2 * ( aRect[ 4 ] - aRect[ 2 ] ) ) //// -> line 785
            aRect[ 2 ]  += x
            aRect[ 4 ]  += x
            DrawTextEx( hDC, cText, aRect, DT_CENTER + DT_VCENTER + DT_SINGLELINE, oFont:hFont, nClrText )
         endif
         RELEASE FONT oFont
      endif
 


Changed file
Code: Select all  Expand view

      if lSegoe
         nHeight     := Int( Min( aRect[ 1 ] - aRect[ 3 ], aRect[ 4 ] - aRect[ 2 ] ) * 0.6 )
         cFace    := If( lWin10, "Segoe MDL2 Assets", "Segoe UI Symbol" )
         DEFINE FONT oFont NAME cFace SIZE 0, -nHeight
         if oFont:hFont == 0
            lSegoe  := .f.
         else
            cText    := HB_UTF8CHR( nChr )
            nBkMode  := SetBkMode( hDC, TRANSPARENT )
            ///x     := Int( 0.2 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            /// Change
            If lWin10
              x     := Int( 0.1 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            Else
              x     := Int( 0.14 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            EndIf
            /// End Change
            aRect[ 2 ]  += x
            aRect[ 4 ]  += x
            DrawTextEx( hDC, cText, aRect, DT_CENTER + DT_VCENTER + DT_SINGLELINE, oFont:hFont, nClrText )
         endif
         RELEASE FONT oFont
      endif
 
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Tue Jun 18, 2019 12:55 am

Windows 10 comes with Segoe MDL2 Assets font.
Windows 8 comes with Segoe UI Symbol font.
Windows 7 does not have these fonts.

If you use Segoe MDL2 Assets font in your application, that will not run on clients' Windows 7 computers.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Tue Jun 18, 2019 1:49 am

Windows 7 has the "Segoe Ui Symbol" font, but has few symbols.
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Tue Jun 18, 2019 2:09 am

Giovany Vecchi wrote:Windows 7 has the "Segoe Ui Symbol" font, but has few symbols.

So, it is not a good idea to use Segoe MDL2 Assets or Segoe UI Symbol for software meant to be distributed to different clients.
We can use when the software is used on our own computers or our company where we know all the computers are windows 10 or 8.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Tue Jun 18, 2019 2:24 am

I did a different process.
Download the "Typograf" utility at https://www.neuber.com/typograph/
Take the font of Windows 10 "Segoe MDL2 Assets" and slve it under another name "Segoe MDL2 Assets seven" and physically named "segmdl2_7.ttf"
When running Windows 7 perform this function at the beginning of the program:

Code: Select all  Expand view

FUNCTION G_SYMBOL_INSTALL()
  Local hDc, aFonts
  Local lc_oDb_FrFix

  If IsWindows10()
    Return nil
  EndIf
 
  hDC    := GetDC( WndMain():hWnd )
  aFonts := ASort( GetFontNames( hDC ) )
  ReleaseDC( WndMain():hWnd, hDC )

  if AScan( aFonts, "Segoe MDL2 Assets Seven" ) > 0

    Return Nil

  endif

  AddFontResource("segmdl2_7.ttf")
 
RETURN NIL
 


Then change in Prg "Imgtxtio.prg" the lines below in the SHOWSYMBOL () function
Code: Select all  Expand view

         cFace    := If( lWin10, "Segoe MDL2 Assets", "Segoe MDL2 Assets Seven" )
         DEFINE FONT oFont NAME cFace SIZE 0, -nHeight
         if oFont:hFont == 0
            lSegoe  := .f.
         else
            cText    := HB_UTF8CHR( nChr )
            SetBkMode( hDC, 1 )
            If lWin10
              x     := Int( 0.1 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            Else
              x     := Int( 0.14 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            EndIf
            aRect[ 2 ]  += x
            aRect[ 4 ]  += x
            DrawTextEx( hDC, cText, aRect, DT_CENTER + DT_VCENTER + DT_SINGLELINE, oFont:hFont, nClrText )
         endif
         RELEASE FONT oFont
      endif
 
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby ukoenig » Tue Jun 18, 2019 7:57 am

Giovany,

thank You,
with the changes the image is shown centered now inside the button.

something else :

it would be nice to save a selected font-symbol shown in xBrowse as a image
maybe using FW_SaveImage( :?: or is there another solution
I tested and getting the error-message "imagetype not supported"
a solution could be : display the symbol enlarged on screen and saving
the screen-area as a transparent image.

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Tue Jun 18, 2019 11:09 am

Please look into these functions in imgtxtio.prg:
FW_TextToBitmap()
FW_MakeYourBitmap()
and then
FW_SaveImage()

You may test this sample:
Code: Select all  Expand view
function Test()

   local hBmp, oWnd, cFile

   hBmp  := FW_TextToBitmap( HB_UTF8CHR( 0xE105 ), { "Segoe MDL2 Assets", -40 } )
   FW_SaveImage( hBmp, "SYMBOL.BMP" )
   DeleteObject( hBmp )

   DEFINE WINDOW oWnd
   ACTIVATE WINDOW oWnd CENTERED ;
      ON PAINT oWnd:DrawImage( "symbol.bmp" )

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Tue Jun 18, 2019 11:32 am

Mr. Giovany

Thanks for your correction to the code
Code: Select all  Expand view
           If lWin10
              x     := Int( 0.1 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            Else
              x     := Int( 0.14 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            EndIf
 

We are adopting this in FWH1906.

Request you and Mr. Uwe to test and improve FW_TextToBitmap()
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby ukoenig » Tue Jun 18, 2019 11:51 am

Mr. Rao,

thank You very much
exactly the solution I've been looking for. :D

What I'm planning to do :

1. a defined size and color for a icon-set
2. selecting any font and display the included symbols with xbrowse
3. saving a symbol in any format bmp, ico or png to the defined set
- with the size and color ( 1 )
4. a project file to arrange and save the different sets
- also possible to include external icons
5. a icon-extractor from exe will be included ( tested and works )

something to do :roll:

I think it belongs to this topic

viewtopic.php?f=3&t=37319

regards
Uwe :D
Last edited by ukoenig on Tue Jun 18, 2019 12:04 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Tue Jun 18, 2019 12:04 pm

Start with \fwh\samples\uisymbol.prg

For Mr. Shridhar, suggest websites you know which provide free icon-sets.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Tue Jun 18, 2019 2:04 pm

I think it's better to use windows fonts than to create bitmaps. If you register the source in windows 7 there are no problems. Later I will change some functions so they can change the colors of the texts and symbols. For while it is thus:


Image
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 47 guests

cron