It is currently Wed Nov 13, 2019 1:17 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Typeface - Sprite-based font include/module
PostPosted: Wed Aug 11, 2010 3:56 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1240
Location: Germany, Glienicke
Pure Basic Module: Typeface - Sprite-based engine for displaying text with bitmap fonts

Direct download of the include: Typeface.pbi (Version 1.4.2)
Download of a zip-file with include, example, two fonts and an editor: Typeface_20180930.zip

Features of the include:
  • Loading of bitmap-fonts (XML or TF)
  • Unicode and Kerning support
  • Displaying and measuring of texts on the screen
  • Changing color and opacity
  • Chaning of size, rotation (also 3D) and bending
  • Alignment and italic
  • ADisplay-clipping and word-wrap

Features of the editor:
  • Loading and saving of bitmap fonts (XML oder TF)
  • Creating of typefaces from TTF-Fonts
  • Editing of the font image
  • Editing of the characters and the kerning pairs

Image

Original post here: https://www.purebasic.fr/german/viewtopic.php?f=8&t=23015

_________________
ImageImage


Last edited by STARGÅTE on Sun Sep 30, 2018 4:36 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Thu Aug 12, 2010 6:43 am 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 3405
Location: New Zealand
That's great, was going to look into doing something like this myself next week.


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Fri Aug 13, 2010 7:32 am 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4520
Location: Lyon - France
Nice...thanks 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Tue Aug 17, 2010 5:28 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Aug 19, 2003 11:36 am
Posts: 1418
Location: Doubs - France
Great, Thank you.

_________________
Please correct my english
http://purebasic.developpez.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Mon Jan 24, 2011 5:01 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jan 02, 2007 8:16 pm
Posts: 4327
Location: Cypress TX
Looks great and I plan to see if it can be implemented with my new idea! 8)

_________________
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Mon Jan 24, 2011 8:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Dec 15, 2008 11:15 pm
Posts: 142
Location: Nashville, TN
Sweet !! I was just looking for something like this myself, saves me some time. :D


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Mon Jan 24, 2011 10:55 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Jan 02, 2007 8:16 pm
Posts: 4327
Location: Cypress TX
How can I integrate this with OGRE? It does not seem to want to display in PB4.51 :cry:

_________________
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Tue Jan 25, 2011 12:02 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1240
Location: Germany, Glienicke
@Rook Zimbabwe
I don't think it runs on OGRE,
because I use a DX9 structure to change the color and vertice of the Sprite3D

I change all the things (rotation, zoom, color, position, ...) in this structure.
I do not know how it is in OREG.

for transform you can use TransformSprite3D(), but for clipping and color i need this DX9 structure.

@All
nice that some of you can use the include
If I have time I try to write an editor, with which you can easily create my *.tf format from an images or *.TTF font

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite3D-Font (colorable,flexible,mo
PostPosted: Thu Jul 11, 2013 11:05 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1240
Location: Germany, Glienicke
Here is an update of my Typeface includes for PB 5.20 and some changes:

Typeface.zip (outdated)
Needs PB 5.20 !

Features:
  • display text with any character sets (XML & Image)
  • intensity and color support
  • (clean) zoom, rotate and bend
  • italic support with any angles
  • unicode, kerning and letter spacing

Image

XML structure:
Code:
<Typeface Image="Example.png"> <!-- file name of the image -->
   <Character Index="65"> <!-- character with index -->
      <Source X="344" Y="38" Width="27" Height="38"/> <!-- position and size in the image -->
      <Outlay X="-8" Y="-8" Width="11" Height="22"/> <!-- display offset and text flow size ->
   </Character>
   <KerningPair Left="39" Right="65" Amount="-1"/> <!-- kerning pair with both characters and their shift -->
</Typeface>

_________________
ImageImage


Last edited by STARGÅTE on Sun Sep 30, 2018 4:40 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Include - Typeface, Sprite-Font
PostPosted: Fri Jul 12, 2013 7:32 am 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1685
Location: Uttoxeter, UK
Another incredible piece of work!
Game-changer!
Love it! :D

Oh, and thanks for sharing.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Typeface - Sprite-based font include/module
PostPosted: Sun Sep 30, 2018 4:39 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1240
Location: Germany, Glienicke
Dear all,

I have updated my Typeface include:

Pure Basic Module: Typeface - Sprite-based engine for displaying text with bitmap fonts

Direct download of the include: Typeface.pbi (Version 1.4.2)
Download of a zip-file with include, example, two fonts and an editor: Typeface_20180930.zip

Features of the include:
  • Loading of bitmap-fonts (XML or TF)
  • Unicode and Kerning support
  • Displaying and measuring of texts on the screen
  • Changing color and opacity
  • Chaning of size, rotation (also 3D) and bending
  • Alignment and italic
  • ADisplay-clipping and word-wrap

Features of the editor:
  • Loading and saving of bitmap fonts (XML oder TF)
  • Creating of typefaces from TTF-Fonts
  • Editing of the font image
  • Editing of the characters and the kerning pairs

Image

Original post here: https://www.purebasic.fr/german/viewtopic.php?f=8&t=23015

Feedback is welcome :) .

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: Typeface - Sprite-based font include/module
PostPosted: Sun Sep 30, 2018 4:53 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1105
Location: Germany::Berlin()
Nice

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Typeface - Sprite-based font include/module
PostPosted: Sun Sep 30, 2018 5:48 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Apr 30, 2009 5:23 pm
Posts: 306
Location: Côtes d'Azur, France
Very nice !
How fast is it compared with DrawText() ?

_________________
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.70 LTS


Top
 Profile  
Reply with quote  
 Post subject: Re: Typeface - Sprite-based font include/module
PostPosted: Sun Sep 30, 2018 6:54 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1240
Location: Germany, Glienicke
Fig wrote:
How fast is it compared with DrawText()?

It's much faster!, because you don't need a StartDrawing() and #PB_2DDrawing_Transparent mode which is very slow compared to the Sprite-Lib with DisplayTransparentSprite.

Here my results:
Code:
Characters | Typeface | DrawText
180          3500 FPS   108 FPS
1800          700 FPS    13 FPS
18000          80 FPS    <1 FPS

I can only advise against using DrawText in games!

Test code:
Code:
InitSprite()

Enumeration
   #Window
   #Typeface
   #Sprite
   #Font
EndEnumeration

IncludeFile "Typeface.pbi" : UseModule Typeface

Declare FPS()

OpenWindow(#Window, 0, 0, 700, 520, "Typeface Example", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window), 0, 0, 0, #PB_Screen_NoSynchronization)
SpriteQuality(#PB_Sprite_BilinearFiltering)

UsePNGImageDecoder()
UsePNGImageEncoder()

LoadTypeface(#Typeface, "Tahoma20.tf")
LoadFont(#Font, "Tahoma", 16)

Define Characters = 18000

Define Typeface = #False;#True;

Repeat
   
   ClearScreen($000000)
   SpriteBlendingMode(#PB_Sprite_BlendSourceAlpha, #PB_Sprite_BlendInvertSourceAlpha)
   
   ResetTypefaceStyles(#Typeface)
   
   DisplayTypeface(#Typeface, 0, 0, "FPS: "+Str(FPS()))
   
   RandomSeed(0)

   If Typeface
      For I = 1 To Characters/60
         DisplayTypeface(#Typeface, 10, 20+Random(480), "Grumpy wizards make toxic brew For the evil Queen And Jack.")
      Next
   Else
      If StartDrawing(ScreenOutput())
         DrawingMode(#PB_2DDrawing_Transparent)
         DrawingFont(FontID(#Font))
         For I = 1 To Characters/60
            DrawText(10, 20+Random(480), "Grumpy wizards make toxic brew For the evil Queen And Jack.")
         Next
         StopDrawing()
      EndIf
   EndIf
      
   FlipBuffers()
   
Until WindowEvent() = #PB_Event_CloseWindow


Procedure.i FPS()
   
   Static Count.i, Time.i, FPS.i
   Protected CurrentTime
   
   CurrentTime = ElapsedMilliseconds()
   If Time = 0 : Time = CurrentTime : EndIf
   
   If CurrentTime - Time > 1000
      FPS = 1000 * Count / (CurrentTime - Time)
      Time = CurrentTime
      Count = 0
   EndIf
   
   Count + 1
   
   ProcedureReturn FPS
   
EndProcedure

_________________
ImageImage


Last edited by STARGÅTE on Sun Sep 30, 2018 7:23 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Typeface - Sprite-based font include/module
PostPosted: Sun Sep 30, 2018 7:11 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1105
Location: Germany::Berlin()
Thank you for this performance information.

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye