TTF to bitmap conversion needed!

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3252
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 235 times
Been thanked: 132 times
Contact:

Re: TTF to bitmap conversion needed!

Post by mol » Thu May 20, 2010 7:07 pm

Alex Gustow wrote:Marek, do you must type so many symbols in "Polish version" of simple "Thanks..."? :)

Seriously, I remember that I saw something like this... I'll try to find (but I'm not sure that successfully).
As I understand, you want to have something like:

Code: Select all

local oMyBMP
  ...
  oMyBMP := String_2_BMP( "Marek Olszewski", "Times New Roman", 12 )
  ...
and after that use bit array in "oMyBMP" as (for example) captcha... or save this array to temporary (or constant) BMP-file... That's right?

P.S. I googled right now on "create captcha Foxpro" - and try to look here: "A Captcha Image Generator for Foxpro"... Maybe it helps?

P.P.S. (10 minutes later) While I thought, googleed and wrote my post - Claudio give us his sample. I'm too late again... :( :) Claudio, I tested it right now too - it's cool and useful thing! :) Thanks!
Polish language is very verbose :)

Many thanks Claudio, I'll try your sample tomorrow morning when I'll find a few minutes...
Last time I'm very busy with my work, my second work, my third work... :D
And with programming my new application for billing (with HMG of course :)).

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 147 times
Contact:

Post by srvet_claudio » Thu May 20, 2010 9:41 pm

Alex Gustow wrote:P.P.S. (10 minutes later) While I thought, googleed and wrote my post - Claudio give us his sample. I'm too late again... Claudio, I tested it right now too - it's cool and useful thing! Thanks!
Thanks Alex.
Best Regards,
Claudio Soto.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 147 times
Contact:

Post by srvet_claudio » Thu May 20, 2010 9:46 pm

mol wrote:Many thanks Claudio, I'll try your sample tomorrow morning when I'll find a few minutes...
You are welcome.
Best regards,
Claudio Soto.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
mol
Posts: 3252
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 235 times
Been thanked: 132 times
Contact:

Post by mol » Fri May 21, 2010 12:17 pm

Great work!
It's really it what I'm searching for!
Many thanks for sharing!
Marek

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 147 times
Contact:

Post by srvet_claudio » Fri May 21, 2010 6:59 pm

mol wrote:Great work!
It's really it what I'm searching for!
Many thanks for sharing!
Marek
Hi Marek.
I'm glad that the program is useful to you.
Best Regards,
Claudio Soto.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
Rathinagiri
Posts: 5266
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 171 times
Been thanked: 173 times
Contact:

Post by Rathinagiri » Fri May 21, 2010 8:17 pm

I think it could be used by many. Thanks for sharing Claudio.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
srvet_claudio
Posts: 2044
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 35 times
Been thanked: 147 times
Contact:

Post by srvet_claudio » Fri May 21, 2010 9:00 pm

rathinagiri wrote:I think it could be used by many. Thanks for sharing Claudio.
Thanks Rathi.
You're very kind.
Best regards,
Claudio.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
mol
Posts: 3252
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 235 times
Been thanked: 132 times
Contact:

Post by mol » Mon May 24, 2010 6:12 am

I'm backing to this topic because I need to get list of fonts installed in system.

I know about function GetFont, but, I need to build my own font selection dialog.

Can anybody help me?

Best regards, Marek

User avatar
gfilatov
Posts: 672
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 24 times
Been thanked: 236 times
Contact:

Post by gfilatov » Mon May 24, 2010 1:16 pm

mol wrote:I'm backing to this topic because I need to get list of fonts installed in system.

I know about function GetFont, but, I need to build my own font selection dialog.

Can anybody help me?
Hi Marek,

Please try the following working sample: :arrow:

Code: Select all

/*
 * HMG - Harbour Win32 GUI library Demo
 *
*/

#include "hmg.ch"

Procedure Main()

	DEFINE WINDOW Form_Main ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'Main Window' ;
		MAIN ;
		BACKCOLOR BLUE

	DEFINE LABEL Label_1
		ROW 	205
		COL	Form_Main.Width - 294
		VALUE	'Fonts:' 
		WIDTH	48
		HEIGHT	16
		BACKCOLOR BLUE
	END LABEL

	DEFINE COMBOBOX Combo_1
		ROW	200
		COL	Form_Main.Width - 244
		ITEMS	GetFonts()
		WIDTH	200
		VALUE	1
		TOOLTIP	'Fonts'
	END COMBOBOX

	define button Btn_2
		row 290
		col Form_Main.Width - 234
		caption "Cancel"
		action Form_Main.Release()
	end button

	END WINDOW

	CENTER WINDOW Form_Main

	ACTIVATE WINDOW Form_Main

return

Function GetFonts()
Local aTmp, aFonts := {}, nHandle := GetDC(NIL)

   aTmp := GetFontNames( nHandle )
   ReleaseDC( NIL, nHandle )
   aeval( aTmp, {|e| IF(aScan(aFonts, e) == 0 .and. !"@" $ e, aAdd(aFonts, e), )} )

return aSort(aFonts)


#pragma BEGINDUMP

#define HB_OS_WIN_USED
#define _WIN32_WINNT   0x0400
#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"


static far int nFontIndex = 0;
static far BOOL bGetName = FALSE;

HB_FUNC ( GETDC )
{
   hb_retnl( (ULONG) GetDC( (HWND) hb_parnl(1) ) ) ;
}

HB_FUNC ( RELEASEDC )
{
   hb_retl( ReleaseDC( (HWND) hb_parnl(1), (HDC) hb_parnl(2) ) ) ;
}

// EnumFonts call back routine

static int CALLBACK EnumFontsCallBack( LOGFONT FAR *lpLogFont,
    TEXTMETRIC FAR *lpTextMetric, int nFontType , LPARAM lParam )
{
  ++nFontIndex;
  if ( bGetName )
    hb_storvc( lpLogFont->lfFaceName, -1, nFontIndex );
  return 1;
}

// GetFontNames: Count and return an unsorted array of font names

HB_FUNC ( GETFONTNAMES )
{

  FONTENUMPROC lpEnumFontsCallBack = ( FONTENUMPROC )
      MakeProcInstance( ( FARPROC ) EnumFontsCallBack, GetModuleHandle( NULL ) );

  // Get the number of fonts
  nFontIndex = 0;
  bGetName = FALSE;
  EnumFonts( ( HDC ) hb_parnl( 1 ), NULL, lpEnumFontsCallBack, 0 );

  // Get the font names
  hb_reta( nFontIndex );
  nFontIndex = 0;
  bGetName = TRUE;
  EnumFonts( ( HDC ) hb_parnl( 1 ), NULL, lpEnumFontsCallBack, 0 );

}

#pragma ENDDUMP
Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
mol
Posts: 3252
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 235 times
Been thanked: 132 times
Contact:

Post by mol » Mon May 24, 2010 7:19 pm

THX Grigori, I'll try tomorrow!
Regards, Marek

Post Reply