TTF to bitmap conversion needed!

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

Re: TTF to bitmap conversion needed!

Post by mol »

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: 2100
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 47 times
Been thanked: 209 times
Contact:

Post by srvet_claudio »

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: 2100
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 47 times
Been thanked: 209 times
Contact:

Post by srvet_claudio »

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: 3395
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 267 times
Been thanked: 170 times
Contact:

Post by mol »

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

User avatar
srvet_claudio
Posts: 2100
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 47 times
Been thanked: 209 times
Contact:

Post by srvet_claudio »

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: 5317
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 196 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

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: 2100
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 47 times
Been thanked: 209 times
Contact:

Post by srvet_claudio »

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: 3395
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 267 times
Been thanked: 170 times
Contact:

Post by mol »

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: 759
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 30 times
Been thanked: 397 times
Contact:

Post by gfilatov »

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: 3395
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 267 times
Been thanked: 170 times
Contact:

Post by mol »

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

Post Reply