Variable size font 
Author Message
 Variable size font

How can I change the font width or height ? not the general size but just
double the height, for example.

Any idea welcome.

Regards
Michel Combe



Thu, 10 May 2001 03:00:00 GMT  
 Variable size font
Quote:

> How can I change the font width or height ? not the general size but just
> double the height, for example.

If you dont want to pick a standard font size that can be set with
prop:fontsize, then you need to go out the the api and create your own true
type font.  Font metrics are a little tricky but not too bad.  After you
create a font with createfontindirect(), next you must select it into the
device context for the control and destroy the existing font.  I just
finished a project that used quite a bit of font metrics.  Based on that
experience I'd say a font with double the height and not proportional width
increase would look pretty strange but can be done.
---
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com


Fri, 11 May 2001 03:00:00 GMT  
 Variable size font
Hi, Jim

Thanks a lot for the info. It looks as though I'm going to spend quite a bit
of time on this project...

In fact the font is already existing and there is also an application that
enable to change the font's height and width. The prospect wants me to
rewrite this app using the existing font.

Since you already have done the job, would it be too much to ask you if you
could send me some code samples to help ? or maybe you know of a VBX or OCX
that would allow this with not too much code writing.

Thanks again
Michel Combe

Quote:

>If you dont want to pick a standard font size that can be set with
>prop:fontsize, then you need to go out the the api and create your own true
>type font.



Sat, 12 May 2001 03:00:00 GMT  
 Variable size font
Quote:

> Since you already have done the job, would it be too much to ask you if you
> could send me some code samples to help ? or maybe you know of a VBX or OCX
> that would allow this with not too much code writing.

I'm not sure if this will help you but here is some minimal code to create a
font and display a test string using the font.  I'll email you a demo.  If
you have the font and can register the font on your system and see it in the
font dialog and dont need to modify it at run time, that should be relatively
easy.  If you need to create fonts at run time for special display, this is
the first step. After this you must also background mode, font color, text
align plus subclass the control and redisplay when wm_paint message is
received.

CRFontClassType.CreateFont Procedure(Long pFEQ, String Typeface, long
pFontHeight, long pFontWidth)
Lf          like(LOGFONTType)   !LogFont Structure to create a font
hwnd        unsigned
TestText    cstring('TEST TEXT')
  Code
  If ~TypeFace then return level:fatal.
  SetTarget(SELF.Wind)
  !Get the DC to work width
  hwnd  = pfeq{prop:handle}
  SELF.HDC = getdc(hwnd)
  If ~SELF.HDC then return level:fatal.
  SELF.FONTDPIX = GetDeviceCaps(SELF.HDC,88)

  !Create a font
  clear(LF)
  !90 = LogPixelsY = pixels per inch on the device
  !72 = pixels per point
  !Since MapMode is mm_text no DptoLP() conversion is needed
  SELF.FontDPIY = GetDeviceCaps(SELF.hDC,90)
  lf.lfheight       = - MulDiv(pFontHeight,SELF.FontDPIY,72)
  lf.lfwidth        = MulDIV(pFontWidth, SELF.FontDPIX,72)
  lf.lfFaceName     = Clip(TypeFace)
  lf.lfweight       =400
  SELF.hfont        = CreateFontIndirect(Address(LF))
  if ~SELF.hFont then Return level:fatal.
  SELF.holdfont     = selectobject(SELF.hdc,SELF.hfont)
  !Show a test
  TextOut(SELF.HDC, 0,0, TestText, len(TestText))

  ReleaseDC(hwnd,SELF.HDC)
  Clear(SELF.HDC)
  SetTarget()
 Return level:benign

With this code you can make fonts of arbitrary height and width. Using the
fonts is the hard part.

---
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com



Sun, 13 May 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using a Variable for the font size

2. Variable name with different font size

3. font size variable?

4. font size taken wrong from X font

5. Constant size exceeds variable size?

6. font size in Dolphin 5

7. need font with graded size plot symbols

8. how to change font/size in editfields

9. VA4.5 Dynamic font size

10. Font size in the CLW 2.0 debugger windows

11. Font Style & Size

12. Run-time font size control

 

 
Powered by phpBB® Forum Software