Page 1 of 2

Font Preview ComboBox

Posted: Tue Jan 27, 2009 7:51 pm
by Fluid Byte
Update #1:
- Removed dependency from SetWindowCallback()
- Removed bug which made the code crash without using SetGagdetState() after creating the gadget
- Restructured, optimized and bundled code into compact set of functions
- You can now create multiple font preview combo boxes without the code crashing
- You can now specify item height and preview font size

Update #2:
- Added: CFP_GetGadgetText(Gadget,Item)

Code: Select all

; Title: Font Preview ComboBox
; Author: Fluid Byte
; Platform: Windows
; Created: Jan 27, 2009
; Updated: May 29, 2017
; E-Mail: fluidbyte@web.de

EnableExplicit

Declare CFP_CreateGagdet(Gadget,X,Y,Width,Height,ItemHeight=20,FontSize=11)
Declare.s CFP_GetGadgetText(Gadget,Item)
Declare CFP_FreeGadget(Gadget)
Declare CFP_EnumFonts(Gadget)
Declare CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
Declare CFP_WndProc(hWnd,uMsg,wParam,lParam)

Structure CFP_FONTDATA
	Type.b
	Symbol.b
	Name.s
EndStructure

Structure CFP_USERDATA
	himlFontType.i
	FontSize.b
	hwndParent.i
EndStructure

Global NewList ftd.CFP_FONTDATA()

Define EventID, Quit

OpenWindow(0,0,0,320,240,"Font Preview ComboBox",#WS_OVERLAPPEDWINDOW | #PB_Window_ScreenCentered)
CFP_CreateGagdet(101,10,10,300,24)

; ---------------------------------------------------------------------------------------
; MAIN LOOP
; ---------------------------------------------------------------------------------------

Repeat
	EventID = WaitWindowEvent()
	
	If EventID = #PB_Event_CloseWindow
	   ; The ImageList used will remain in memory even after you quit, you have to free it manually
	   CFP_FreeGadget(101)
	   Quit = 1
	EndIf
Until Quit = 1

; ---------------------------------------------------------------------------------------
; FUNCTIONS
; ---------------------------------------------------------------------------------------

Procedure CFP_CreateGagdet(Gadget,X,Y,Width,Height,ItemHeight=20,FontSize=11)
	Protected himlFontType, hwndParent, *cfpu.CFP_USERDATA
	
	himlFontType = ImageList_Create_(16,12,#ILC_MASK,0,0)
	ImageList_AddMasked_(himlFontType,CatchImage(0,?FontType),#Yellow)	
		
	hwndParent = GadgetID(ContainerGadget(#PB_Any,X,Y,Width,Height))
	ComboBoxGadget(Gadget,0,0,Width,Height,#CBS_OWNERDRAWFIXED)
	SendMessage_(GadgetID(Gadget),#CB_SETITEMHEIGHT,0,ItemHeight)	
	CloseGadgetList()
	
	*cfpu = AllocateMemory(SizeOf(CFP_USERDATA))
	*cfpu\himlFontType = himlFontType
	*cfpu\FontSize = FontSize
	*cfpu\hwndParent = hwndParent
	SetWindowLongPtr_(GadgetID(Gadget),#GWLP_USERDATA,*cfpu)
	
	SetWindowLongPtr_(hwndParent,#GWL_WNDPROC,@CFP_WndProc())
	
	CFP_EnumFonts(Gadget)
	
	SetGadgetState(Gadget,0)
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure.s CFP_GetGadgetText(Gadget,Item)
	If IsGadget(Gadget)
		Protected *cfpf.CFP_FONTDATA 
		*cfpf = GetGadgetItemData(Gadget,Item)		
		ProcedureReturn *cfpf\Name
	EndIf
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_FreeGadget(Gadget)
	If IsGadget(Gadget)
		Protected *cfpu.CFP_USERDATA, Result
		
		*cfpu = GetWindowLongPtr_(GadgetID(Gadget),#GWLP_USERDATA)

		If *cfpu
			Result = ImageList_Destroy_(*cfpu\himlFontType)
			
			If Result : Result = FreeMemory(*cfpu) : EndIf
		EndIf
	EndIf
	
	ProcedureReturn Result
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_WndProc(hWnd,uMsg,wParam,lParam)
	Select uMsg
		Case #WM_DRAWITEM
		Protected *lpdis.DRAWITEMSTRUCT = lParam	
		
		; --- Draw item focus rectangle or normal state		
		If *lpdis\itemState & #ODS_SELECTED
			Protected hbrFocus = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
			FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFocus)
			DeleteObject_(hbrFocus)
			DrawFocusRect_(*lpdis\hDC,*lpdis\rcItem)				
			SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_HIGHLIGHTTEXT))
		Else
			Protected hbrFace = CreateSolidBrush_(GetSysColor_(#COLOR_WINDOW))
			FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFace)
			DeleteObject_(hbrFace)
			SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_WINDOWTEXT))
		EndIf	

		Protected *ftd.CFP_FONTDATA = GetGadgetItemData(wParam,*lpdis\itemID)			
		Protected *cfpu.CFP_USERDATA = GetWindowLongPtr_(*lpdis\hwndItem,#GWLP_USERDATA)

		; --- Draw Font Icons
		If *ftd\Type > -1
			ImageList_Draw_(*cfpu\himlFontType,*ftd\Type,*lpdis\hDC,2,*lpdis\rcItem\top + 3,#ILD_TRANSPARENT)
		EndIf
		
		; --- Create Preview Font
		Protected lplf.LOGFONT, hfntPreview
		
		lplf\lfHeight = -MulDiv_(*cfpu\FontSize,GetDeviceCaps_(*lpdis\hDC,#LOGPIXELSY),72)			
		
		If *ftd\Symbol : lplf\lfCharSet = #SYMBOL_CHARSET : EndIf			
		
		PokeS(@lplf\lfFaceName,*ftd\name)			
		
		hfntPreview = CreateFontIndirect_(lplf)

		; --- Draw Preview Text
		SetBkMode_(*lpdis\hDC,#TRANSPARENT)	
		
		If *ftd\Symbol ; If it's a smybol font like Webdings
			Protected fsz.SIZE
			
			; Write the fonts name
			*lpdis\rcItem\left + 20
			SelectObject_(*lpdis\hDC,GetStockObject_(#DEFAULT_GUI_FONT))
			GetTextExtentPoint32_(*lpdis\hDC,*ftd\Name,Len(*ftd\Name),fsz)
			DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)	
			
			; Display demo charachters next to the name
			*lpdis\rcItem\left + fsz\cx + 3
			SelectObject_(*lpdis\hDC,hfntPreview)
			DrawText_(*lpdis\hDC,"ABC123",6,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
		Else
			*lpdis\rcItem\left + 20
			SelectObject_(*lpdis\hDC,hfntPreview)			
			DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
		EndIf	
		
		DeleteObject_(hfntPreview)

						
		ProcedureReturn #True
	EndSelect
	
	ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_EnumFonts(Gadget)
	Protected lplf.LOGFONT, hdc, Index
	
	lplf\lfCharset = #DEFAULT_CHARSET
	
	hdc = GetDC_(0)
	EnumFontFamiliesEx_(hdc,lplf,@CFP_EnumProc(),hdc,0)
	ReleaseDC_(0,hdc)
	
	SortStructuredList(ftd(),#PB_Sort_Ascending,OffsetOf(CFP_FONTDATA\Name),#PB_String)
	
	ForEach ftd()
		AddGadgetItem(Gadget,-1,ftd()\Name)	
		SetGadgetItemData(Gadget,Index,ftd())
		Index + 1				
	Next
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
	Protected CHRSET = *lpelfe\elfLogFont\lfCharSet & 255
	
	; WESTERN FONTS / SYSTEM FONTS / SYMBOL FONTS

 	If CHRSET = #ANSI_CHARSET Or CHRSET = #OEM_CHARSET Or CHRSET = #SYMBOL_CHARSET
		AddElement(ftd())
		
		Select FontType
			Case #TRUETYPE_FONTTYPE : ftd()\Type = 0
			Case #DEVICE_FONTTYPE : ftd()\Type = 1
			Case #RASTER_FONTTYPE : ftd()\Type = 2
			Default : ftd()\Type = -1
		EndSelect
		
		If CHRSET = #SYMBOL_CHARSET : ftd()\Symbol = 1 : EndIf
		
		; Using 'lfFaceName' of the LOGFONT structure gives unique fontnames and avoids dublicates.
		; When using 'elfFullName' of the ENUMLOGFONTEX structure you still can get dublicates even
		; though you limit the character set like above. Also you don't need to cycle through the 
		; whole LinkedList everytime to find out if a fontname already exists.
		;
		; The created fontlist SHOULD be identical to the one in MS Wordpad + bitmap fonts (Courier, etc.)
			
		ftd()\Name = PeekS(@*lpelfe\elfLogFont\lfFaceName)
	EndIf

   ProcedureReturn #True
EndProcedure

; ---------------------------------------------------------------------------------------
; DATA SECTION
; ---------------------------------------------------------------------------------------

DataSection
	FontType:
	Data.l $01964D42,$00000000,$00760000,$00280000,$00300000,$000C0000,$00010000,$00000004,$01200000,$00000000
	Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$80000080,$80000000,$00800080,$00800000,$80800080
	Data.l $80800000,$C0C00080,$000000C0,$FF0000FF,$FF000000,$00FF00FF,$00FF0000,$FFFF00FF,$FFFF0000,$BBBB00FF
	Data.l $5555BBBB,$BBBBBB55,$BB7B77B8,$B9BBBBBB,$97B97B99,$BBBBBBBB,$55BBBBBB,$BBBBBBBB,$8B868870,$99BBBBBB
	Data.l $79999799,$BBBBBBBB,$55BBBBBB,$B8BBBBBB,$68B8BB00,$99BBBBBB,$B799797B,$BBBBBB9B,$55666666,$B8BBBBBB
	Data.l $76BBBB00,$99BBBB8B,$7B99B77B,$BBBBBBBB,$55BB66BB,$B8BBBBBB,$86BBBB00,$99BBBB6B,$9B79BB7B,$BBBBBBBB
	Data.l $55BB65BB,$B8BB5BBB,$B6BB8B00,$79BBBB68,$97B9BB9B,$BBBBBBBB,$55BB65BB,$BBBB5BBB,$B6BB7B00,$B9BBBB68
	Data.l $99B7BB97,$BBBBBBBB,$555B65BB,$BBBB5BB5,$B7BB0B70,$B7BBBB66,$99BBBB99,$B6BBBB7B,$555565BB,$BBBB5B55
	Data.l $B7BB08B0,$BBBBBB68,$79BB9B79,$B6BBBB9B,$6BBB66BB,$BBBBBBBB,$B7BB00B8,$BBBBBB68,$79BB99B7,$B6BBBB97
	Data.l $6BB6666B,$BBBBBBBB,$867880BB,$BBBBBB6B,$9799B9BB,$B6BBBB79,$6B666666,$BBBBBBBB,$6887BBBB,$BBBBBBBB
	Data.l $BBBBBBBB
	Data.b $BB,$BB
EndDataSection

Posted: Tue Jan 27, 2009 8:51 pm
by Sparkie
Excellent job Fluid Byte 8)

Posted: Tue Jan 27, 2009 8:54 pm
by ts-soft
:D very usefull

Posted: Tue Jan 27, 2009 9:27 pm
by rsts
Nice.

And useful.

Good one. Thanks

Posted: Tue Jan 27, 2009 10:16 pm
by Fluid Byte
Thanks for the kind comments! :o

Just tweaked the code a little more. Now I use DrawText_() instead of TextOut_(). This has two advantages:

1.) The point size for the preview font can now be set to any value and the text will automatically be clipped so the it doesn't overlap with other items.

2.) The text is now vertically centered which looks much better.

Posted: Tue Jan 27, 2009 10:46 pm
by Arctic Fox
Such a great work, Fluid Byte :!: :o

What about setting a specific dropdown-list height like 300 px or so
I don't know how it looks on any other computer, but it covers - a bit exaggerated :wink: - almost the half of the screen here :lol:

Code: Select all

ComboBoxGadget(#CMB_FontPreview,10,10,300,24,#CBS_OWNERDRAWFIXED|#CBS_NOINTEGRALHEIGHT)
MoveWindow_(GadgetID(#CMB_FontPreview), GadgetX(#CMB_FontPreview), GadgetY(#CMB_FontPreview), GadgetWidth(#CMB_FontPreview), 300, 1)

Posted: Tue Jan 27, 2009 11:18 pm
by Fluid Byte
Yeah, I know what you mean. :wink:

It's a "feature" of Windows XP and above. The dropdown height will automatically set to the maximum possible to view as many items at once. But I admit it's really huge, even on a rather "small" 1280x1024, 4:3 monitor. Will add this tomorrow, thanks for pointing it out. Gotta sleep now! :D

Posted: Wed Jan 28, 2009 12:27 pm
by srod
Yep this is very nice and useful. Easily adapted as well to offer all kinds of functionality.

Thanks Fluid.

Posted: Wed Jan 28, 2009 3:08 pm
by dige
Well done. Thank you Fluid Byte for sharing!

Re: Font Preview ComboBox

Posted: Tue May 09, 2017 1:02 pm
by Fangbeast
Anyone still around years later that got this code working? I updated what I could to PB 5.44 and it works but without the graphical font preview.

The fonts are all normal and I don't have the code I did back in 2009 (When I had it working)

Re: Font Preview ComboBox

Posted: Tue May 09, 2017 1:27 pm
by Bisonte
It's only UnCompressMemory... so I start PB 4.41 (cause 2009) and save the image to disk, after that i put it into the datasection
and change the image initialization.

So its unmodified. Only the picture is uncompressed. And so it works with 5.60

(Btw. why you don't use the FontRequester()... native PB ?)

Code: Select all

 ; Title: Font Preview ComboBox
; Author: Fluid Byte
; Test-Platform: Windows XP SP3
; E-Mail: UncompressMemory

EnableExplicit

Declare WindowCallback(hWnd,uMsg,wParam,lParam)
Declare EnumFontsProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
Declare EnumFonts(Gadget)

#CMB_FontPreview = 101

Structure FONTDATA
   Type.b
   Symbol.b
   Name.s
EndStructure

Global NewList ftd.FONTDATA()
Global himlFontType

Define lpBuffer, EventID, Quit

CatchImage(0, ?FontType)

; Create ImageList
himlFontType = ImageList_Create_(16,12,#ILC_MASK,0,0)

ImageList_AddMasked_(himlFontType,ImageID(0),#Yellow)

; Open main window with owner-draw combobox
OpenWindow(0,200,200,320,240,"Font Preview ComboBox",#WS_OVERLAPPEDWINDOW)
ComboBoxGadget(#CMB_FontPreview,10,10,300,24,#CBS_OWNERDRAWFIXED)
SendMessage_(GadgetID(#CMB_FontPreview),#CB_SETITEMHEIGHT,0,20)
EnumFonts(#CMB_FontPreview)

SetActiveGadget(#CMB_FontPreview)
SetGadgetState(#CMB_FontPreview,0)

SetWindowCallback(@WindowCallback())

; ---------------------------------------------------------------------------------------
; MAIN LOOP
; ---------------------------------------------------------------------------------------

Repeat
   EventID = WaitWindowEvent()
   
   If EventID = #PB_Event_CloseWindow
      ImageList_Destroy_(himlFontType) : Quit = 1
   EndIf
Until Quit = 1

; ---------------------------------------------------------------------------------------
; FUNCTIONS
; ---------------------------------------------------------------------------------------

Procedure WindowCallback(hWnd,uMsg,wParam,lParam)
   Select uMsg
      Case #WM_DRAWITEM
      Protected *lpdis.DRAWITEMSTRUCT = lParam
      
      If *lpdis\hwndItem = GadgetID(#CMB_FontPreview)                                 
         If *lpdis\itemState & #ODS_SELECTED
            Protected hbrFocus = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
            FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFocus)
            DeleteObject_(hbrFocus)
            DrawFocusRect_(*lpdis\hDC,*lpdis\rcItem)            
            SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_HIGHLIGHTTEXT))
         Else
            Protected hbrFace = CreateSolidBrush_(GetSysColor_(#COLOR_WINDOW))
            FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFace)
            DeleteObject_(hbrFace)
            SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_WINDOWTEXT))      
         EndIf   
         
         Protected *ftd.FONTDATA = GetGadgetItemData(#CMB_FontPreview,*lpdis\itemID)         
         
         ; * Create Preview Font
         Protected lplf.LOGFONT, hfntPreview
         lplf\lfHeight = -MulDiv_(11,GetDeviceCaps_(*lpdis\hDC,#LOGPIXELSY),72)
         If *ftd\Symbol : lplf\lfCharSet = #SYMBOL_CHARSET : EndIf
          PokeS(@lplf\lfFaceName,GetGadgetItemText(#CMB_FontPreview,*lpdis\itemID))
          hfntPreview = CreateFontIndirect_(lplf)
         
         ; * Draw Font Icons
         If *ftd\Type > -1
            ImageList_Draw_(himlFontType,*ftd\Type,*lpdis\hDC,2,*lpdis\rcItem\top + 3,#ILD_TRANSPARENT)
         EndIf
                  
         ; * Draw Preview Text
         SetBkMode_(*lpdis\hDC,#TRANSPARENT)   

         If *ftd\Symbol
            Protected fsz.SIZE
            
            *lpdis\rcItem\left + 20
            SelectObject_(*lpdis\hDC,GetStockObject_(#DEFAULT_GUI_FONT))
            GetTextExtentPoint32_(*lpdis\hDC,*ftd\Name,Len(*ftd\Name),fsz)
            DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)   

            *lpdis\rcItem\left + fsz\cx + 3
            SelectObject_(*lpdis\hDC,hfntPreview)
            DrawText_(*lpdis\hDC,"ABC123",6,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
         Else
            *lpdis\rcItem\left + 20
            SelectObject_(*lpdis\hDC,hfntPreview)
            DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
         EndIf   
         
         DeleteObject_(hfntPreview)
      EndIf
                  
      ProcedureReturn #True
   EndSelect
   
   ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure EnumFontsProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
   Protected CHRSET = *lpelfe\elfLogFont\lfCharSet & 255
   
   ; WESTERN FONTS / SYSTEM FONTS / SYMBOL FONTS

    If CHRSET = #ANSI_CHARSET Or CHRSET = #OEM_CHARSET Or CHRSET = #SYMBOL_CHARSET
      AddElement(ftd())
      
      Select FontType
         Case #TRUETYPE_FONTTYPE : ftd()\Type = 0
         Case #DEVICE_FONTTYPE : ftd()\Type = 1
         Case #RASTER_FONTTYPE : ftd()\Type = 2
         Default : ftd()\Type = -1
      EndSelect
      
      If CHRSET = #SYMBOL_CHARSET : ftd()\Symbol = 1 : EndIf
      
      ; Using 'lfFaceName' of the LOGFONT structure gives unique fontnames and avoids dublicates.
      ; When using 'elfFullName' of the ENUMLOGFONTEX structure you still can get dublicates even
      ; though you limit the character set like above. Also you don't need to cycle through the
      ; whole LinkedList everytime to find out if a fontname already exists.
      ;
      ; The created fontlist SHOULD be identical to the one in MS Wordpad + bitmap fonts (Courier, etc.)
         
      ftd()\Name = PeekS(@*lpelfe\elfLogFont\lfFaceName)
   EndIf

   ProcedureReturn #True
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure EnumFonts(Gadget)
   Protected lplf.LOGFONT, hdc, Index
   
   lplf\lfCharset = #DEFAULT_CHARSET

   hdc = GetDC_(0)
   EnumFontFamiliesEx_(hdc,lplf,@EnumFontsProc(),hdc,0)
   ReleaseDC_(0,hdc)
   
   SortStructuredList(ftd(),#PB_Sort_Ascending,OffsetOf(FONTDATA\Name),#PB_String)
   
   ForEach ftd()
      AddGadgetItem(Gadget,-1,ftd()\Name)
      SetGadgetItemData(Gadget,Index,ftd())
      Index + 1
   Next
EndProcedure

; ---------------------------------------------------------------------------------------
; DATA SECTION
; ---------------------------------------------------------------------------------------

DataSection
  FontType: ;{ Datas : Size = 1784 Bytes
  Data.q $0000000006F64D42,$0028000000360000,$000C000000300000,$0000001800010000,$0000000006C00000
  Data.q $0000000000000000,$FF00000000000000,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$0080FFFF00FFFF00
  Data.q $8080008080008080,$8000808000808000,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$C0C0C0FFFF00FFFF
  Data.q $8080808080808080,$00FFFF00FFFF0080,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF
  Data.q $FF0000FF0000FF00,$FF00FFFF00808080,$80FF0000FF0000FF,$FFFF00FFFF008080,$FF00FFFF00FFFF00
  Data.q $00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$80800080FFFF00FF,$FFFF00FFFF008000
  Data.q $FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$000000808080FFFF,$C0C0C0C0C0C0C0C0,$00C0C0C0008080C0
  Data.q $FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$00FF0000FFFF00FF,$FF0000FF0000FF00,$0000808080FF0000
  Data.q $00808080FF0000FF,$FFFF00FFFF00FF00,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF
  Data.q $FF00FFFF00FFFF00,$80800080FFFF00FF,$FFFF00FFFF008000,$FF00FFFF00FFFF00,$C0FFFF00FFFF00FF
  Data.q $000000000000C0C0,$FF00FFFF00FFFF00,$C0008080C0C0C0FF,$FFFF00FFFF00C0C0,$FF00FFFF00FFFF00
  Data.q $00FF0000FFFF00FF,$FFFF00808080FF00,$0000FF0000808080,$80FFFF00FF0000FF,$FFFF00FF00008080
  Data.q $FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$008080008080FFFF,$8080008080008080,$8080008000808000
  Data.q $FFFF00FFFF008000,$FF00FFFF00FFFF00,$C0FFFF00FFFF00FF,$000000000000C0C0,$FF00FFFF00FFFF00
  Data.q $80808080FFFF00FF,$FFFF00C0C0C00080,$FF00FFFF00FFFF00,$00FF0000FFFF00FF,$FFFF00808080FF00
  Data.q $0000808080FFFF00,$00808080FF0000FF,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF
  Data.q $FFFF00FFFF00FFFF,$FF00008080008080,$80800080FFFF00FF,$FFFF00FFFF008000,$FF00FFFF00FFFF00
  Data.q $C0FFFF00FFFF00FF,$000000000000C0C0,$FF00FFFF00FFFF00,$80C0C0C0FFFF00FF,$FFFF000080800080
  Data.q $FF00FFFF00FFFF00,$00FF0000FFFF00FF,$FFFF00808080FF00,$8080FFFF00FFFF00,$00FF0000FF000080
  Data.q $FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$FF00800080008080
  Data.q $80800080FFFF00FF,$FFFF00FFFF008000,$FF00FFFF00800080,$C0FFFF00FFFF00FF,$000000000000C0C0
  Data.q $FF00FFFF00C0C0C0,$80FFFF00FFFF00FF,$C0C0C00080800080,$FF00FFFF00FFFF00,$00808080FFFF00FF
  Data.q $FFFF00FF0000FF00,$FF00FFFF00FFFF00,$80FF0000FF0000FF,$FFFF00FFFF008080,$FF00FFFF00FFFF00
  Data.q $00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$FF00800080008080,$80800080FFFF00FF,$FFFF00FFFF008000
  Data.q $FF00FFFF00800080,$00FFFF00FFFF00FF,$000000000000FFFF,$FF00FFFF00808080,$80FFFF00FFFF00FF
  Data.q $C0C0C00080800080,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$808080FF0000FF00,$FF00FFFF00FFFF00
  Data.q $00FF0000808080FF,$FFFF00FFFF00FF00,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF
  Data.q $0080800080008080,$80800080FFFF0080,$800080FFFF008000,$FF00FFFF00800080,$00FFFF00FFFF00FF
  Data.q $000000808080FFFF,$FF00FFFF00000000,$80FFFF00FFFF00FF,$0080800080808080,$FF00FFFF00FFFF00
  Data.q $80FFFF00FFFF00FF,$FF0000FF00008080,$FF00FFFF00FFFF00,$00FF0000FFFF00FF,$FFFF00808080FF00
  Data.q $FF00FFFF00FFFF00,$80FFFF00FFFF00FF,$FFFF00FFFF000080,$0080800080008080,$8080008080008080
  Data.q $8000808000808000,$FF00FFFF00800080,$00FFFF00FFFF00FF,$000000FFFF00FFFF,$FF00C0C0C0000000
  Data.q $80FFFF00FFFF00FF,$C0C0C00080808080,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FF0000808080FFFF
  Data.q $FF00FFFF00FF0000,$00808080FFFF00FF,$FFFF00FF0000FF00,$FF00FFFF00FFFF00,$80FFFF00FFFF00FF
  Data.q $FFFF00FFFF000080,$FF00008080008080,$00008080FFFF00FF,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00
  Data.q $00FFFF00FFFF00FF,$C0C0C0FFFF00FFFF,$FF00000000000000,$80FFFF00FFFF00FF,$C0C0C00080808080
  Data.q $FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$808080FFFF00FFFF,$FF00FF0000FF0000,$00808080FFFF00FF
  Data.q $808080FF0000FF00,$FF00FFFF00FFFF00,$80FFFF00FFFF00FF,$FFFF000080800080,$FF00008080008080
  Data.q $00008080008080FF,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF
  Data.q $8080000000C0C0C0,$80C0C0C0C0C0C080,$FFFF000080800080,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF
  Data.q $FFFF00FFFF00FFFF,$0000FF0000FFFF00,$80FF0000FF0000FF,$FF00008080808080,$FF00FFFF00FFFF00
  Data.q $80FFFF00FFFF00FF,$0080800080800080,$8080008080008080,$0000808000808000,$FFFF00FFFF00FFFF
  Data.q $FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$C0C0FFFF00FFFF00,$C0008080808080C0
  Data.q $FFFF00FFFF00C0C0,$FF00FFFF00FFFF00,$00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$FF00FFFF00FFFF00
  Data.q $00FFFF00FFFF00FF,$FFFF00FFFF00FFFF,$0000FFFF00FFFF00
  ;}
EndDataSection

Re: Font Preview ComboBox

Posted: Tue May 09, 2017 9:44 pm
by Fangbeast
(Btw. why you don't use the FontRequester()... native PB ?)
1. Because I am an idiot??? (Forgot it was there)

2. Because I like seeing this implemented directly in my programs. Always prefer code to learn from if I can.

Re: Font Preview ComboBox

Posted: Wed May 10, 2017 2:25 am
by Fangbeast
Hmm, better switch to 5.6 I suppose as I am still using 5.43 and still don't get the graphic font preview.

Bit scared of how much trouble I will have converting old sources though. Fingers crossed:(

Re: Font Preview ComboBox

Posted: Wed May 10, 2017 2:39 am
by Fangbeast
Bisonte, I installed PB 5.6 to test this out and it still isn't rendering the fonts graphically as they should look.

The PB font requester does as it hooks the system but I'd still like to fix this somehow if possible. It used to work years ago.

Beginning to wonder if it isn't a Windows 10 problem. I am running the current Redstone release.

Re: Font Preview ComboBox

Posted: Wed May 10, 2017 8:26 am
by Bisonte
Ah now I see what you mean.
I tested it with PB 4.41 and the fontnames are styled like the fonts, but not with PB5.60 on my Win10.

I don't know what happen'd, maybe an API artist can do it ?