Browse Source

Blide.FontMachine. Initial Import.

woollybah 8 years ago
parent
commit
09124f6bf3
32 changed files with 1902 additions and 0 deletions
  1. 7 0
      .gitignore
  2. 746 0
      fontmachine.mod/BitMapFont.bmx
  3. 49 0
      fontmachine.mod/Exceptions/TDrawTextException.bmx
  4. 0 0
      fontmachine.mod/Font Preview app.bls
  5. 23 0
      fontmachine.mod/Font Properties/BitMapChar.bmx
  6. 33 0
      fontmachine.mod/Font Properties/fontBlends.bmx
  7. 43 0
      fontmachine.mod/FontFX/FontKerning.bmx
  8. 101 0
      fontmachine.mod/FontFX/TextRendererFX.bmx
  9. 0 0
      fontmachine.mod/FontMachine.bls
  10. 12 0
      fontmachine.mod/Utils/Check Version.bmx
  11. 80 0
      fontmachine.mod/Utils/Drawing.bmx
  12. 94 0
      fontmachine.mod/Utils/fontmachineUtils.bmx
  13. 30 0
      fontmachine.mod/Utils/functions.bmx
  14. BIN
      fontmachine.mod/doc/Banner1.png
  15. 19 0
      fontmachine.mod/doc/DrawBitMapText.bmx
  16. 20 0
      fontmachine.mod/doc/DrawText.bmx
  17. 58 0
      fontmachine.mod/doc/DrawTextBegin.bmx
  18. BIN
      fontmachine.mod/doc/Examples/Test Program/Fonts/Jungle.fmf
  19. BIN
      fontmachine.mod/doc/Examples/Test Program/Fonts/NewCaveman.fmf
  20. BIN
      fontmachine.mod/doc/Examples/Test Program/Fonts/Small.fmf
  21. BIN
      fontmachine.mod/doc/Examples/Test Program/Fonts/luxury.fmf
  22. BIN
      fontmachine.mod/doc/Examples/Test Program/Images/GNOME-GreenField_1024x768.jpg
  23. BIN
      fontmachine.mod/doc/Examples/Test Program/Sample Program1.bmx
  24. 113 0
      fontmachine.mod/doc/Examples/Test Program/TestProgram 1.bmx
  25. 108 0
      fontmachine.mod/doc/Examples/TestProgram2/FMFPreview.bmx
  26. BIN
      fontmachine.mod/doc/Examples/TestProgram2/Images/fondo.png
  27. 203 0
      fontmachine.mod/doc/Examples/TestProgram2/Preview dialog.bmx
  28. BIN
      fontmachine.mod/doc/Examples/TestProgram2/TestForn1/Small.fmf
  29. BIN
      fontmachine.mod/doc/SampleFont.fmf
  30. 29 0
      fontmachine.mod/doc/SetHKerning.bmx
  31. 29 0
      fontmachine.mod/doc/SetVKerning.bmx
  32. 105 0
      fontmachine.mod/fontmachine.bmx

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+.bmx
+*.bak
+*.x64.a
+*.x64.i
+*.x86.a
+*.x86.i
+commands.html

+ 746 - 0
fontmachine.mod/BitMapFont.bmx

@@ -0,0 +1,746 @@
+
+'This is the font machine module source code.
+'Use it as you wish. If you publish any game or application using this module, please state it on the credits as:
+'This program uses the Font Machine Module written by Manel Ibañez
+'
+'Enjoy!
+
+Rem
+	bbdoc: This is the BitMap font base class
+end rem
+Type TBitmapFont
+	Rem
+		bbdoc:This field contains the metrics of the current font.
+	end rem
+	Field Kerning:TFontKerning = New TFontKerning
+	
+	Rem
+		bbdoc: This flag enables the usage of a MaskColor when loading a bitmap font. Useful only for experimental ClearType support.
+	end rem
+	Field UseMask:Int = False
+	
+	Rem
+		bbdoc: This field contains the Red component of the mask color used to load the bitmap font when the UseMask flag is set to true. <br>This is experimetal.
+	end rem
+	Field MaskColorRed:Int = 0
+
+	Rem
+		bbdoc: This flag enables the usage of a MaskColor when loading a bitmap font. Useful only for experimental ClearType support.
+	end rem
+	Field MaskColorGreen:Int = 0
+
+	Rem
+		bbdoc: This flag enables the usage of a MaskColor when loading a bitmap font. Useful only for experimental ClearType support.
+	end rem
+	Field MaskColorBlue:Int = 0
+	
+
+	Rem
+		bbdoc: This flag enables the fisical pixel rounding to prevent artifacts when the fonts are scaled down due to virtual resolution usage in some hardware configurations.
+	end rem
+	Field PhisicalPixelRounding:Int = False
+
+	Rem
+		bbdoc:This field contains a collection of callback function for advanced text drawing operations.
+	end rem
+	Field RenderFX:iTextRendererFXBase
+	Rem
+		bbdoc:<font color=#FF0000><b>PRIVATE DATA</b></font>
+	end rem
+	Field PrivateData:TPrivateBitmapFont = New TPrivateBitmapFont
+	Rem
+		bbdoc:Set the status of the bitmapfont shadow<br><b>True</b>: Shadow will be enabled<br><b>False</b>: Shadow will be disabled
+	end rem
+	Method SetDrawShadow(Value:Int) 
+		privatedata.drawshadow = value
+	End Method
+
+	Rem
+		bbdoc:Gets the status of the bitmapfont shadow<br><b>True</b>: Shadow is enabled<br><b>False</b>: Shadow is disabled
+	end rem
+	Method GetDrawShadow:Int() 
+		Return privatedata.DrawShadow
+	End Method
+
+	Rem
+		bbdoc:Sets the status of the bitmapfont border <br><b>True</b>: Border will be enabled<br><b>False</b>: Border will be disabled
+	end rem	
+	Method SetDrawBorder(Value:Int) 
+		privatedata.drawBorder = value
+	End Method
+
+	Rem
+		bbdoc:Gets the status of the bitmapfont border <br><b>True</b>: Border is enabled<br><b>False</b>: Border is disabled
+	end rem	
+	Method GetDrawBorder:Int() 
+		Return privatedata.DrawBorder
+	End Method
+
+	Rem
+		bbdoc:Sets the a pointer to a function that will be called while the font is being loaded, to provide load progress in the host application.
+	end rem	
+	Method SetProgressFunction(FunctionPointer(Percent:Float)) 
+		privatedata.Progress = FunctionPointer
+	End Method
+	
+	Rem
+		bbdoc:Method to load the bitmap font (FMF file)
+	end rem	
+	Method Load(Url:Object, ImageFilters:Int = FILTEREDIMAGE)
+		Local Read:TStream = OpenStream(url, True, False)
+		Local LastProgres:Int = 0
+		If read = Null Then Return
+		GCSuspend()
+		While read.Eof() = False
+			Local Char:Int = read.ReadInt()
+
+			If Char > 255 And Self.PrivateData.Face.Length <= 256 Then	'Activate UNICODE:
+				Self.PrivateData.Face = Self.PrivateData.Face[..65536]
+				Self.PrivateData.border = Self.PrivateData.border[..65536]
+				Self.PrivateData.shadow = Self.PrivateData.shadow[..65536]
+			End If
+			If Self.PrivateData.shadow[Char] = Null Then Self.PrivateData.shadow[Char] = New TBitMapChar
+			If Self.PrivateData.border[Char] = Null Then Self.PrivateData.border[Char] = New TBitMapChar
+			If Self.privatedata.face[char] = Null Then Self.privatedata.face[char] = New TBitMapChar
+			Local id:String = read.ReadLine() 
+			Select id
+				Case "SHADOW"
+					'DPrint "SHADOW INT11:" + 
+					read.ReadInt()  'FUTURE USE
+					Self.PrivateData.shadow[Char].Image = LoadImage(Read, ImageFilters)
+					Self.PrivateData.shadow[Char].Image.handle_x = 0
+					Self.PrivateData.shadow[char].Image.handle_y = 0
+
+					'DPrint
+					read.ReadLine()       'FUTURE USE
+					If Self.privatedata.shadow[char].Image = Null Then
+						Print "ERROR LOADING PNG"
+					End If
+					read.ReadInt() 
+					Self.privatedata.shadow[char].LoadDrawRenderingData(read) 
+					SetImageHandle(Self.PrivateData.shadow[char].Image, - Self.PrivateData.shadow[char].drawoffsetx, - Self.PrivateData.shadow[char].DrawOffsetY) 
+
+					'DPrint
+					read.ReadLine()    'FUTURE USE
+
+				Case "BORDER"
+					'DPrint "BORDER INT1:" + 
+					read.ReadInt()  'FUTURE USE
+					Self.PrivateData.border[Char].Image = LoadImage(Read, ImageFilters)
+					Self.PrivateData.border[char].Image.handle_x = 0
+					Self.PrivateData.border[char].Image.handle_y = 0
+
+					'DPrint
+					read.ReadLine()      'FUTURE USE
+					read.ReadInt() 
+					Self.privatedata.Border[char].LoadDrawRenderingData(read)
+					SetImageHandle(Self.PrivateData.border[char].Image, - Self.PrivateData.border[char].drawoffsetx, - Self.PrivateData.border[char].DrawOffsetY)
+					'DPrint
+					read.ReadLine()    'FUTURE USE
+
+				Case "FACE"
+					'DPrint "FACE INT1:" + 
+					Read.ReadInt()  'FUTURE USE
+					If UseMask = False Then
+						'Local pm:TPixmap = LoadPixmap(Read)
+						'For Local x:Int = 0 Until pm.width
+						'	For Local y:Int = 0 Until pm.height
+						'		Local PD:Int = pm.ReadPixel(x, y)
+						'		If PD = 0 Then pm.WritePixel(x, y, $00090909)
+						'	Next
+						'Next
+						'Self.PrivateData.face[Char].Image = LoadImage(pm, MIPMAPPEDIMAGE | FILTEREDIMAGE)
+						Self.PrivateData.face[Char].Image = LoadImage(Read, ImageFilters)
+					Else
+						Local pm:TPixmap=LoadPixmap(Read)
+						pm = MaskPixmap(pm, Self.MaskColorRed, Self.MaskColorGreen, Self.MaskColorBlue)
+						Self.PrivateData.face[Char].Image = LoadImage(pm,MASKEDIMAGE)
+					EndIf
+					Self.PrivateData.face[Char].Image.handle_x = 0
+					Self.PrivateData.face[char].Image.handle_y = 0
+					SetImageHandle(Self.PrivateData.face[char].Image, - Self.PrivateData.face[char].drawoffsetx, - Self.PrivateData.face[char].DrawOffsetY)
+					'DPrint
+					read.ReadLine()   	'CHECkPOINT
+					read.ReadInt() 
+					Self.privatedata.Face[char].LoadDrawRenderingData(read) 
+					'DPrint
+					read.ReadLine()   	'CHECkPOINT
+				Default
+					GCResume
+					Local Ex:TBitmapFontLoadException
+					ex = New TBitmapFontLoadException
+					ex.PrivateData.Description = "Unable to load the bitmapfont due to corrupted or unsuported file format"
+					ex.PrivateData.Offending = Self
+					Throw ex
+			End Select
+			If Self.PrivateData.Progress <> Null Then
+				If Int(LastProgres) <> Int(Char / Float(Self.PrivateData.Face.Length) * 100.0) Then
+					LastProgres = Char
+					Self.PrivateData.Progress(char / Float(Self.PrivateData.Face.Length) * 100.0)
+				End If
+			End If
+		Wend
+		READ.Close() 
+		Self.PrivateData.FontLoaded = True
+		GCResume()
+	End Method
+	
+	Rem
+		bbdoc:Returns TRUE if the font has been loaded, otherwise returns false
+	end rem
+	Method FontLoaded:Int() 
+		Return Self.PrivateData.fontloaded
+	End Method
+	Rem
+		bbdoc:Method to draw text on the current graphics object.<br>Parameters:<br><b>TEXT</b>: The text to draw<br><b>X</b>:The X position for the text in the current graphics context<br><b>Y</b>: The Y position for the text in the current graphics context<br><b>CustomBlend</b><i> optional </i> :a boolean value to enable or disable customb blend drawing.
+	end rem	
+	Method DrawText(Text:String, x:Float, y:Float, CustomBlend:Int = True)
+		privatedata.DrawTextLine(Text, x, y, customblend, Self)
+	End Method
+
+	Rem
+		bbdoc:Method to draw text on the current graphics object with a maximum width in pixels.
+	end rem	
+	Method DrawTextMaxWidth(Txt:String, x:Float, y:Float, MaxWidth:Double, CustomBlend:Int = True)
+	'DebugStop
+		Local curLength:Double = 0
+		Local Str:String = ""
+		Local curY:Float = Y
+		Local ScaleX:Float, ScaleY:Float
+		Local skip:Int = False
+		GetScale(ScaleX, ScaleY)
+		For Local i:Int = 1 To Txt.Length
+			Local Sum:Double = 0
+			If Asc(Mid(Txt, i, 1)) <> 10 And Asc(Mid(Txt, i, 1)) < Self.PrivateData.Face.length Then
+			
+				If Self.privatedata.Face[Asc(Mid(Txt, i, 1))] <> Null Then
+					Local Char:TBitMapChar = Self.privatedata.Face[Asc(Mid(Txt, i, 1))]
+					sum = Double(char.DrawWidth) * ScaleX + kerning.PrivateData.HKF * ScaleX
+					If (curlength + sum) < (MaxWidth - Abs(ScaleX)) Then	'ScaleX reduce floating poing accuracy errors.
+						Str:+Mid(Txt, i, 1)
+						sum = (Double(char.Charwidth)) * ScaleX + kerning.PrivateData.HKF * scalex
+						curlength:+Sum
+					Else
+						DrawText(Str, x, CurY, CustomBlend)
+						If str <> "" Then CurY:+Self.GetFontHeight() * ScaleY + Self.Kerning.PrivateData.VKF * ScaleY
+						Str = Mid(Txt, i, 1)
+						curLength = (Double(char.Charwidth)) * ScaleX + kerning.PrivateData.HKF * scalex
+					End If
+				EndIf
+			Else
+				DrawText(Str, x, CurY, CustomBlend)
+				CurY:+Self.GetFontHeight() * ScaleY + Self.Kerning.PrivateData.VKF * ScaleY
+				Str = ""
+				curlength = 0
+			EndIf
+			If curY > GraphicsHeight() Then
+				Skip = True
+				Exit 'For
+			EndIf
+		Next
+		If str <> "" And Skip = False Then
+			DrawText(Str, x, CurY, CustomBlend)
+		End If
+	End Method
+		
+	Rem
+		bbdoc:Method to get the drawing with, in pixels, of a given string
+	end rem	
+	Method GetTxtWidth:Int(Text:String) 
+		Local TWidth:Int
+		
+		'debugstop
+		Local char:Int
+		Local lastchar:Int = 0
+		For Local i:Int = 1 To Text.Length
+			char = Asc(Mid(Text, i, 1))
+			If char >= 0 And char < Self.PrivateData.Face.length Then
+				If privatedata.face[char] <> Null Then
+				lastchar = char
+					twidth = twidth + privatedata.face[char].charwidth + kerning.PrivateData.HKF
+				End If
+			End If
+		Next
+		If lastchar >= 0 And lastchar < Self.PrivateData.Face.Length Then
+				If privatedata.face[lastchar] <> Null Then
+					twidth = twidth - privatedata.face[lastchar].charwidth
+					twidth = twidth + privatedata.face[lastchar].drawwidth
+				End If		
+		End If
+		Return TWidth
+	End Method
+	
+	Rem
+		bbdoc:Method to get the bitmap font height
+	end rem	
+	Method GetFontHeight:Int() 
+		If privatedata.face[32] = Null Then Return 0
+		Return privatedata.face[32].DrawHeight
+	End Method
+
+	Rem
+		bbdoc:Method to get the face image object of a given char
+	end rem	
+	Method GetFaceImage:TImage(Char:Byte) 
+		If privatedata.face[char] = Null Then Return Null
+		Return privatedata.face[char].Image
+	End Method
+	
+	Rem
+		bbdoc:Method to get the border image object of a given char
+	end rem	
+	Method GetBorderImage:TImage(Char:Byte) 
+		If privatedata.Border[char] = Null Then Return Null
+		Return privatedata.Border[char].Image
+	End Method
+
+	Rem
+		bbdoc:Method to get the shadow image object of a given char
+	end rem	
+	Method GetShadowImage:TImage(char:Byte) 
+		If privatedata.shadow[char] = Null Then Return Null
+		Return privatedata.shadow[char].image
+	End Method
+
+	Rem
+		bbdoc:Method to get the face info of the given char.<br>The returned object represents the X and Y drawing offset, and the width and height of the face char
+	end rem	
+	Method GetFaceInfo:TRectangle(Char:Byte) 
+		If privatedata.face[char] = Null Then Return Null
+		Local R:TRectangle = New TRectangle
+		Local BMC:TBitMapChar = privatedata.face[char] 
+		r.X = BMC.DrawOffsetX
+		r.Y = BMC.DrawOffsetY
+		r.Width = BMC.DrawWidth
+		r.Height = BMC.DrawHeight
+		Return r
+	End Method
+	
+	Rem
+		bbdoc:Method to get the border info of the given char.<br>The returned object represents the X and Y drawing offset, and the width and height of the border char
+	end rem	
+	Method GetBorderInfo:TRectangle(Char:Byte) 
+		If privatedata.border[char] = Null Then Return Null
+		Local R:TRectangle = New TRectangle
+		Local BMC:TBitMapChar = privatedata.border[char] 
+		r.X = BMC.DrawOffsetX
+		r.Y = BMC.DrawOffsetY
+		r.Width = BMC.DrawWidth
+		r.Height = BMC.DrawHeight
+		Return r
+	End Method
+
+	Rem
+		bbdoc:Method to get the shadow info of the given char.<br>The returned object represents the X and Y drawing offset, and the width and height of the shadow char
+	end rem	
+	Method GetShadowInfo:TRectangle(Char:Byte) 
+		If privatedata.Shadow[char] = Null Then Return Null
+		Local R:TRectangle = New TRectangle
+		Local BMC:TBitMapChar = privatedata.Shadow[char] 
+		r.X = BMC.DrawOffsetX
+		r.Y = BMC.DrawOffsetY
+		r.Width = BMC.DrawWidth
+		r.Height = BMC.DrawHeight
+		Return r
+	End Method
+	
+	Rem
+		bbdoc:Method to get a character spacing width to its relative next character.
+	end rem	
+	Method GetCharOffset:Int(Char:Byte) 
+		If privatedata.face[char] = Null Then Return 0
+		Return privatedata.face[char].Charwidth
+	End Method
+	
+
+	Rem
+		bbdoc:Returns a relative border drawing point for a speciffic char
+	end rem	
+	Method GetCharBorderOffset:TDrawingPoint(Char:Byte) 
+		If privatedata.border[char] = Null Then
+			Return CreateDrawingPoint(0, 0) 
+		EndIf
+		Local CharB:TBitMapChar = privatedata.border[char] 
+		Return CreateDrawingPoint(charB.DrawOffsetX, charB.DrawOffsetY) 
+	End Method
+	
+	Rem
+		bbdoc:Returns a relative shadow drawing point for a speciffic char
+	end rem	
+	Method GetCharShadowOffset:TDrawingPoint(char:Byte) 
+		If privatedata.Shadow[char] = Null Then
+			Local DP:TDrawingPoint = New TDrawingPoint
+			DP.X = 0
+			DP.Y = 0
+			Return DP
+		EndIf
+		Local DP:TDrawingPoint = New TDrawingPoint
+		dp.X = privatedata.Shadow[char].DrawOffsetX
+		dp.Y = privatedata.Shadow[char].DrawOffsetY
+		Return dp
+	End Method
+	
+	Rem
+		bbdoc:This method will determine the blend mode for the face of the font.<br>By default this Blend mode is set to Alpha.
+	end rem
+	Method SetFaceBlend(Mode:Int = EConstBlend.Alpha) 
+		Self.PrivateData.FaceBlend = Mode
+	End Method
+	
+	Rem
+		bbdoc:This method will return the current blend mode for the face of the font.
+	end rem
+	Method GetFaceBlend:Int() 
+		Return privatedata.faceblend
+	End Method
+	
+	Rem
+		bbdoc:This method will determine the blend mode for the border of the font.<br>By default this Blend mode is set to Alpha.
+	end rem
+	Method SetBorderBlend(Mode:Int = EConstBlend.Alpha) 
+		privatedata.BorderBlend = Mode
+	End Method
+	
+	Rem
+		bbdoc:This method will return the current blend mode for the border of the font.
+	end rem
+	Method GetBorderBlend:Int() 
+		Return privatedata.borderblend
+	End Method
+	
+	Rem
+		bbdoc:This method will determine the blend mode for the shadow of the font.<br>By default this Blend mode is set to Alpha.
+	end rem
+	Method SetShadowBlend(Mode:Int = EConstBlend.Alpha) 
+		privatedata.ShadowBlend = Mode
+	End Method
+	
+	Rem
+		bbdoc:This method will return the current blend mode for the shadow of the font.
+	end rem
+	Method GetShadowBlend:Int() 
+		Return privatedata.shadowblend
+	End Method
+
+	
+End Type
+
+Rem
+	bbdoc:Create a BitMapFont object from an existing FMF file.
+	returns: A @TBitmapFont object if load succeed. Otherwise returns @NULL
+	about: Parameters:<br>
+	@URL: The place to load the font from<br>
+	@ProgressPointer: This parameter is optional. It is a function pointer to the function to be called to inform about loading progress. the function has to have one float parameter called progress. This parameter will get the loading percent while the font is being loaded.
+end rem
+Function LoadBitmapFont:TBitmapFont(Url:Object, ProgressPointer(Progress:Float) = Null, ImageFilters:Int = FILTEREDIMAGE)
+	Local BMF:TBitmapFont = New TBitmapFont
+	bmf.SetProgressFunction(ProgressPointer) 
+	bmf.Load(Url) 
+	If bmf.FontLoaded() = True Then
+		Return bmf
+	Else
+		Return Null
+	End If
+End Function
+Rem
+	bbdoc:Function to draw text using a bitmap font.
+	returns: Nothing
+	about: Parameters:<br>
+	@BitMapFont: The bitmap font to be used in the draw operation<br>
+	@Text: The text to be draw<br>
+	@X: the X position to draw the text<br>
+	@Y: the Y position to draw the text<br>
+	@CustomBlend: To enable or disable the custom blending mode. defaults to TRUE
+end rem	
+Function DrawBitMapText(BitMapfont:TBitmapFont, Text:String, X:Int, Y:Int, customBlend:Int = True) 
+	If bitmapfont = Null Then
+		Local ex:TDrawTextException
+		ex = New TDrawTextException
+		ex.PrivateData.Description = "Can't draw text becouse the bitmapfont is null."
+		ex.PrivateData.Offending = Null
+		Throw ex
+		Return
+	End If
+	Try
+		bitmapfont.DrawText(Text, x, y, customblend)
+	Catch ex:Object
+		Local newex:TDrawTextException
+		newex = New TDrawTextException
+		newex.PrivateData.Description = "There was an unhandled exception inside this drawtext operation. The exception source is: " + TTypeId.ForObject(ex).Name() + ":" + ex.ToString()
+		Throw newex
+	End Try
+End Function
+
+Private
+
+Type TPrivateBitmapFont
+	Field Shadow:TBitMapChar[256] 
+	Field Border:TBitMapChar[256] 
+	Field Face:TBitMapChar[256] 
+	Field Progress(Percent:Float) 
+	Field DrawShadow:Int = True
+	Field DrawBorder:Int = True
+	Field FontLoaded:Int = False
+	Field ShadowBlend:Int = EConstBlend.Alpha
+	Field FaceBlend:Int = EConstBlend.Alpha
+	Field BorderBlend:Int = EConstBlend.Alpha
+	Field RenderStatus:TRenderStatus = New TRenderStatus
+	Method DrawFaceText(Text:String, X:Float, Y:Float, Base:TBitmapFont)
+		Local DRX:Float = X, DRY:Float = y
+		Local OldX:Float = x', OldY:Float = y
+		Local scalex:Float = RenderStatus.ScaleX, scaley:Float = RenderStatus.scaley
+		'GetScale(scalex, scaleY) 
+		Local center:TDrawingPoint = CreateDrawingPoint(x, y) 
+		Local rotation:Float = RenderStatus.rotation
+		Local DoCallBack:Int = (base.renderfx <> Null) 
+		For Local i:Int = 1 To Text.Length
+			Local char:Int = Asc(Mid(Text, i, 1)) 
+			If char >= 0 And char <= Self.Face.Length Then
+				If char = 10 Then
+					'DRx = OldX
+					DRY = DRy + face[32].DrawHeight * scaley + Base.kerning.PrivateData.VKF * scaley
+					Self.DrawFaceText(Mid(Text, i + 1), oldx, dry, base)
+					Return
+
+				ElseIf face[char] <> Null Then
+					If face[char].Image <> Null Then
+						Local DrawPos:TDrawingPoint = New TDrawingPoint
+						Local Origin:TDrawingPoint
+						Origin = New TDrawingPoint
+						Origin.X = DRx '+ privatedata.shadow[char].DrawOffsetX * scalex
+						Origin.Y = DRy '+ privatedata.shadow[char].DrawOffsetY * scaley
+						DrawPos = GetRotationCords(Rotation, Origin, Center) 
+						'DrawImage(face[char].Image, drawpos.x, drawpos.y) 
+						If Not DoCallBack
+							If Base.PhisicalPixelRounding = False Then
+								DrawImage(Face[char].Image, DrawPos.X, DrawPos.Y)  'OLD
+							Else
+								Local VRWidth:Float = VirtualResolutionWidth() , VRHeight:Float = VirtualResolutionHeight()
+								Local PhisicalX:Float = DrawPos.X * (Double(GraphicsWidth()) / VRWidth)
+								Local PhisicalY:Float = DrawPos.y * (Double(GraphicsHeight()) / VRHeight)
+								SetVirtualResolution(GraphicsWidth(), GraphicsHeight())
+								Local RScaleX:Double = scalex * Double(GraphicsWidth()) / VRWidth
+								Local RScaleY:Double = scaley * Double(GraphicsHeight()) / VRHeight
+								
+								RScaleX = FM_Round (RScaleX * Double(Face[char].Image.width)) / Double(Face[char].Image.width)
+								RScaleY = FM_Round (RScaleY * Double(Face[char].Image.height)) / Double(Face[char].Image.height)
+
+								
+								SetScale(Float(RScaleX), Float(RScaleY))
+								
+								'SetScale 1, 1
+								DrawImage(Face[char].Image, FM_Round (PhisicalX), FM_Round (PhisicalY))
+								If char = Asc("m") Then
+									Print "(" + FM_Round (PhisicalX) + ", " + FM_Round(PhisicalY) + ")" + Double(Face[char].Image.width * RScaleX) + "  -  " + RScaleX
+								EndIf
+								SetVirtualResolution(VRWidth, VRHeight)
+								SetScale scalex, scaley
+							EndIf
+						Else
+							Local DrawFace:TDrawCharAction = New TDrawCharAction
+							DrawFace.Char = char
+							DrawFace.font = base
+							DrawFace.Handled = False
+							DrawFace.Status = eDrawCharStatus.Face
+							DrawFace.X = drawpos.X
+							DrawFace.Y = drawpos.y
+							drawface.CurrentScaleX = renderstatus.ScaleX
+							drawface.CurrentScaleY = renderstatus.scaley
+							Local Call:iTextRendererFXBase = base.renderfx
+							While Call <> Null
+								Call.DrawFaceChar (DrawFace) 
+								Call = Call.chainfx
+							Wend
+							char = DrawFace.char							
+							If DrawFace.Handled = False Then
+								If face[char] <> Null Then DrawImage(Face[char].Image, DrawFace.X, DrawFace.y) 
+							EndIf
+						EndIf
+						If face[char] <> Null Then
+							DRx:+face[char].charwidth * ScaleX + base.kerning.PrivateData.HKF * scalex
+							'DRx:+face[char].charwidth * ScaleX + base.kerning.PrivateData.HKF * scalex
+						EndIf
+					End If
+				End If
+			End If
+		Next
+	End Method
+	
+	Method DrawBorderText(Text:String, X:Float, Y:Float, Base:TBitmapFont)
+		Local OldX:Float = X ' RenderStatus.scalex', OldY:Float = RenderStatus.scaley
+		Local scalex:Float = renderstatus.scalex, scaley:Float = renderstatus.scaley
+		Local center:TDrawingPoint = CreateDrawingPoint(x, y) 
+		Local rotation:Float = RenderStatus.rotation
+		Local DoCallBack:Int = (base.renderfx <> Null) 
+		For Local i:Int = 1 To Text.Length
+			Local char:Int = Asc(Mid(Text, i, 1)) 
+			If char >= 0 And char < Self.Face.Length Then
+				If char = 10 Then
+					x = OldX
+					Y = y + face[32].DrawHeight * scaley + base.kerning.PrivateData.VKF * scaley
+					'Local drawpos:TDrawingPoint
+					'Local origin:TDrawingPoint = CreateDrawingPoint(x, y) 
+					'drawpos = GetRotationCords(rotation, origin, center) 
+					Self.drawbordertext(Mid(Text, i + 1), x, y, base)
+					Return
+				ElseIf Border[char] <> Null Then
+					If Border[char].Image <> Null Then
+						Local DrawPos:TDrawingPoint = New TDrawingPoint
+						Local Origin:TDrawingPoint
+						Origin = New TDrawingPoint
+						Origin.X = x
+						Origin.Y = y
+						Drawpos = GetRotationCords(Rotation, Origin, Center) 
+						If Not DoCallBack
+							If Base.PhisicalPixelRounding = False Then
+								DrawImage(Border[char].Image, DrawPos.X, DrawPos.Y)
+							Else							
+								Local VRWidth:Float = VirtualResolutionWidth() , VRHeight:Float = VirtualResolutionHeight()
+								Local PhisicalX:Float = DrawPos.X * (GraphicsWidth() / VRWidth)
+								Local PhisicalY:Float = DrawPos.y * (GraphicsHeight() / VRHeight)
+								SetVirtualResolution(GraphicsWidth(), GraphicsHeight())
+								
+								
+								Local RScaleX:Double = scalex * Double(GraphicsWidth()) / VRWidth
+								Local RScaleY:Double = scaley * Double(GraphicsHeight()) / VRHeight
+								
+								RScaleX = FM_Round (RScaleX * Double(Border[char].Image.width)) / Double(Border[char].Image.width)
+								RScaleY = FM_Round (RScaleY * Double(Border[char].Image.height)) / Double(Border[char].Image.height)
+
+								SetScale(Float(RScaleX), Float(RScaleY))
+								'SetScale 1, 1
+								DrawImage(Border[char].Image, FM_Round (PhisicalX), FM_Round(PhisicalY))
+								SetVirtualResolution(VRWidth, VRHeight)
+								SetScale scalex, scaley
+							EndIf
+							
+						Else
+							Local DrawBorder:TDrawCharAction = New TDrawCharAction
+							DrawBorder.Char = char
+							DrawBorder.font = base
+							DrawBorder.Handled = False
+							DrawBorder.Status = eDrawCharStatus.Border
+							DrawBorder.X = drawpos.X
+							DrawBorder.Y = drawpos.y
+							drawborder.CurrentScaleY = renderstatus.ScaleY
+							drawborder.CurrentScaleX = renderstatus.ScaleX
+							'base.renderfx.DrawborderChar(DrawBorder) 							
+							Local Call:iTextRendererFXBase = base.renderfx
+							While Call <> Null
+								Call.DrawBorderChar (DrawBorder) 
+								Call = Call.chainfx
+							Wend
+							char = drawborder.char
+							If DrawBorder.Handled = False Then
+								If face[char] <> Null Then DrawImage(Border[char].Image, DrawBorder.X, DrawBorder.y) 
+							EndIf
+						EndIf
+
+						'DrawImage(Border[char].Image, X, y) 
+						If face[char] <> Null Then
+							x:+face[char].charwidth * ScaleX + base.kerning.PrivateData.HKF * scalex
+						EndIf
+					End If
+				End If
+			End If
+		Next
+	End Method
+	
+	Method DrawShadowText(Text:String, x:Float, y:Float, Base:TBitmapFont)
+		Local OldX:Float = x', OldY:Float = y
+		Local scalex:Float = RenderStatus.ScaleX, scaley:Float = RenderStatus.scaley
+		Local center:TDrawingPoint = CreateDrawingPoint(x, y) 
+		Local rotation:Float = RenderStatus.rotation
+		Local DoCallBack:Int = (base.renderfx <> Null) 
+		'Local FaceX:Int = OldX
+		For Local i:Int = 1 To Text.Length
+			Local char:Int = Asc(Mid(Text, i, 1)) 
+			If char >= 0 And char < Self.Face.Length Then
+			If char = 10 Then
+				x = OldX
+				'FaceX = x
+				Y = y + face[32].DrawHeight * scaley + base.kerning.PrivateData.VKF * scaley
+				Self.drawshadowtext(Mid(Text, i + 1), oldx, y, base)
+				Return
+				'Print "ENTER " + privatedata.face[32].drawheight
+			ElseIf shadow[char] <> Null Then
+					If shadow[char].Image <> Null Then
+						Local DrawPos:TDrawingPoint = New TDrawingPoint
+						Local Origin:TDrawingPoint = New TDrawingPoint
+						Origin.X = x
+						Origin.Y = y
+						drawpos = GetRotationCords(Rotation, Origin, center) 
+						If Not docallback
+							DrawImage(shadow[char].Image, DrawPos.X, DrawPos.y) 
+						Else
+							Local drawshadow:TDrawCharAction = New TDrawCharAction
+							drawshadow.Char = char
+							drawshadow.font = base
+							drawshadow.Handled = False
+							drawshadow.Status = eDrawCharStatus.Shadow
+							drawshadow.X = drawpos.X
+							drawshadow.Y = drawpos.y
+							Local Call:iTextRendererFXBase = base.renderfx
+							While Call <> Null
+								Call.DrawShadowChar (DrawShadow) 
+								Call = Call.chainfx
+							Wend
+							char = drawshadow.char
+							If drawshadow.Handled = False Then
+								If face[char] <> Null Then DrawImage(shadow[char].Image, drawshadow.X, drawshadow.y) 
+							EndIf
+						EndIf
+						'DrawImage(shadow[char].Image, X, y) 
+						If face[char] <> Null Then
+							x:+face[char].charwidth * ScaleX + base.kerning.PrivateData.HKF * scalex
+						EndIf
+					End If
+				End If
+			End If
+		Next
+
+	End Method
+	
+	Method DrawTextLine(Text:String, x:Float, y:Float, customblend:Int = True, base:TBitmapFont)
+		'Local OldBlend:Int = GetBlend() 
+		If base.renderfx <> Null Then
+			Local DTBA:TDrawTextAction = New TDrawTextAction
+			DTBA.Font = base
+			dtba.Text = Text
+			dtba.X = x
+			dtba.Y = y
+			base.RenderFX.DrawTextBegin(DTBA)
+		End If
+		RenderStatus.OldBlend = GetBlend() 
+		GetScale(RenderStatus.ScaleX, RenderStatus.ScaleY) 
+		renderstatus.Rotation = GetRotation() 
+		If drawshadow Then
+			If CustomBlend = True Then SetBlend(ShadowBlend) 
+			DrawShadowText(Text, x, y, base)
+		EndIf
+		If drawborder Then
+			If CustomBlend = True Then SetBlend(borderblend) 
+			DrawBorderText(Text, x, y, base)
+		EndIf
+		If CustomBlend = True Then SetBlend(faceblend) 
+		DrawFaceText(Text, x, y, base)
+		SetBlend RenderStatus.oldblend
+		If base.renderfx <> Null Then
+			Local DTBA:TDrawTextAction = New TDrawTextAction
+			DTBA.Font = base
+			dtba.Text = Text
+			dtba.X = x
+			dtba.Y = y
+			base.renderfx.DrawTextEnd(dtba) 
+		End If
+	End Method
+End Type
+
+Type TRenderStatus
+	Field OldBlend:Int
+	Field Rotation:Float
+	Field ScaleX:Float
+	Field ScaleY:Float
+End Type
+
+Public

+ 49 - 0
fontmachine.mod/Exceptions/TDrawTextException.bmx

@@ -0,0 +1,49 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+Rem
+	bbdoc:This exception is thrown when a draw operation using a bitmap font can't be completed.
+End Rem
+Type TDrawTextException
+	Field PrivateData:TPrivateException = New TPrivateException
+	rem
+		bbdoc: This method contains a explanation of the exception
+	end rem
+	Method ToString:String()
+		If privatedata.description <> "" Then
+			Return privatedata.description
+		Else
+			Return "The requested action could not be completed."
+		EndIf
+	End Method
+	
+	rem
+		bbdoc: This method will return a instance of the offending @TBitmapFont object, if available.
+	end rem
+	Method GetFontObject:TBitmapFont()
+		Return privatedata.Offending
+	End Method
+End Type
+
+Rem
+	bbdoc: This exception is thrown when a load operation of a bitmap font can't be completed.
+end rem
+Type TBitmapFontLoadException Extends TDrawTextException
+	rem
+		bbdoc: This method contains a explanation of the exception
+	end rem
+	Method ToString:String()
+		Return Super.ToString()
+	End Method
+	rem
+		bbdoc: This method will return a instance of the offending @TBitmapFont object, if available.
+	end rem
+	Method GetFontObject:TBitmapFont()
+		Return Super.GetFontObject()
+	End Method
+End Type
+
+Private
+Type TPrivateException
+	Field Description:String = ""
+	Field Offending:TBitmapFont
+End Type
+Public

File diff suppressed because it is too large
+ 0 - 0
fontmachine.mod/Font Preview app.bls


+ 23 - 0
fontmachine.mod/Font Properties/BitMapChar.bmx

@@ -0,0 +1,23 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+Private
+Type TBitMapChar
+	Field DrawOffsetX:Int
+	Field DrawOffsetY:Int
+	Field DrawWidth:Int
+	Field DrawHeight:Int
+	Field Charwidth:Int
+	Field Image:TImage
+	
+	Method LoadDrawRenderingData(Url:Object) 
+		Local LS:TStream
+		Ls = OpenStream(Url, True, False) 
+		Self.DrawOffsetX = ls.ReadInt() 
+		Self.DrawOffsetY = ls.ReadInt() 
+		Self.DrawWidth = ls.ReadInt() 
+		Self.DrawHeight = ls.ReadInt() 
+		Self.Charwidth = ls.ReadInt() 
+		'Print charwidth
+		ls.Close()
+	End Method
+End Type
+Public

+ 33 - 0
fontmachine.mod/Font Properties/fontBlends.bmx

@@ -0,0 +1,33 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+rem
+	bbdoc:This class has a list of all available blend modes for bitmap fonts.
+end rem
+Type EConstBlend Final
+	rem
+		bbdoc: This Blend mode will draw images respecting the alpha channel.<br>This is the default blend mode for bitmap fonts.
+	end rem
+	Const Alpha:Int = Alphablend
+	rem
+		bbdoc: This Blend mode will draw images using light information on the pixels to combine them to the backbuffer.
+	end rem
+	Const Light:Int = LightBlend
+	rem
+		bbdoc: This Blend mode will draw images overwriting directly any existing pixel in the backbuffer.
+	end rem
+	Const Solid:Int = SolidBlend
+	rem
+		bbdoc: This Blend mode will draw images solid images.<br>Any alpha value will be rounded to 1 or 0.
+	end rem
+	Const Mask:Int = MaskBlend
+	rem
+		bbdoc: This Blend mode will draw images using dark information on the pixels to combine them to the backbuffer.
+	end rem
+	Const Shade:Int = ShadeBlend
+	rem
+		bbdoc: This function return the active blend mode in the active graphic context.
+	end rem
+	Function GetCurrent:Int() 
+		Return GetBlend()    
+	End Function
+End Type
+

+ 43 - 0
fontmachine.mod/FontFX/FontKerning.bmx

@@ -0,0 +1,43 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+
+rem
+	bbdoc: This class stores all the kerning-releated operations for a bitmap font class.
+endrem
+Type TFontKerning
+	rem
+		bbdoc:<font color=#FF0000><b>PRIVATE DATA</b></font>
+	end rem
+	Field PrivateData:TPrivateFontKerning = New TPrivateFontKerning
+	
+	rem
+		bbdoc:Set the horizontal kerning for the font, in pixels.
+	end rem
+	Method SetHKerning(Value:Float) 
+		privatedata.HKF = value
+	End Method
+	rem
+		bbdoc:Set the vertical kerning for the font, in pixels
+	end rem
+	Method SetVKerning(Value:Float) 
+		privatedata.VKF = value
+	End Method
+	rem
+		bbdoc:Get the current horizontal kerning for this font, in pixels
+	end rem
+	Method GetHKerning:Float() 
+		Return privatedata.HKF
+	End Method
+	rem
+		bbdoc:Get the current vertical kerning for this font, in pixels
+	end rem
+	Method GetVKerning:Float() 
+		Return privatedata.vkf
+	End Method
+End Type
+
+Private
+Type TPrivateFontKerning
+	Field HKF:Float = 0	'Horizontal kerning factor
+	Field VKF:Float = 0	'Vertical kerning factor
+End Type
+Public

+ 101 - 0
fontmachine.mod/FontFX/TextRendererFX.bmx

@@ -0,0 +1,101 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+rem
+	bbdoc: Renderer effect base class (interface)
+end rem
+Type iTextRendererFXBase Abstract
+	'Field PrivateData:TTextRendererPrivateData = New TTextRendererPrivateData
+	Field ChainFX:iTextRendererFXBase
+	rem
+		bbdoc: This method will be called whenever a DrawText operation starts from the bitmap font owning this object instance.
+	end rem
+	Method DrawTextBegin(e:TDrawTextAction)
+	End Method
+	rem
+		bbdoc: This method will be called whenever a DrawText operation ends from the bitmap font owning this object instance.
+	end rem
+	Method DrawTextEnd(e:TDrawTextAction) 
+	End Method
+	rem
+		bbdoc: This method will be called before a shadow of a character is drawn from the bitmap font owning this object instance.
+	end rem
+	Method DrawShadowChar(e:TDrawCharAction)
+	End Method
+	rem
+		bbdoc: This method will be called before a border of a character is drawn from the bitmap font owning this object instance.
+	end rem
+	Method DrawBorderChar(e:TDrawCharAction) 
+	End Method
+	rem
+		bbdoc: This method will be called before the face of a character is drawn from the bitmap font owning this object instance.
+	end rem
+	Method DrawFaceChar(e:TDrawCharAction) 
+	End Method
+	
+End Type
+
+rem
+	bbdoc: This class is instantiated and passed as a parameter for any DrawTextAction callback used for advanced text drawing.
+end rem
+Type TDrawTextAction
+	rem
+		bbdoc: The text to be drawed.
+	end rem
+	Field Text:String
+	rem
+		bbdoc: The X position where the text is going to be drawed.
+	end rem
+	Field X:Float
+	rem
+		bbdoc: The Y position where the text is going to be drawed.
+	end rem
+	Field Y:Float
+	rem
+		bbdoc: The bitmapfont object that has fired the Draw Char action. This is read only.
+	end rem
+	Field Font:TBitmapFont
+End Type
+rem
+	bbdoc: This class is instantiated and passed as a parameter for any DrawActionChar callback used for advanced text drawing.
+end rem
+Type TDrawCharAction
+	rem
+		bbdoc: 16 BIT unicode character to be printed. This is overridable
+	end rem
+	Field Char:Int
+	rem
+		bbdoc: the X position where the character is going to be drawed. This is overridable
+	end rem
+	Field X:Float
+	rem
+		bbdoc: the Y position where the character is going to be drawed. This is overridable
+	end rem
+	Field Y:Float
+	rem
+		bbdoc: Read only ScaleX factor when the DrawChar ation was fired.
+	end rem
+	Field CurrentScaleX:Float
+	rem
+		bbdoc: Read only ScaleY factor when the DrawChar ation was fired.
+	end rem
+	Field CurrentScaleY:Float
+	rem
+		bbdoc: The bitmapfont object that has fired the Draw Char action. This is read only.
+	end rem
+	Field font:TBitmapFont
+
+	rem
+		bbdoc: Handled flag. If this is set to true, the character won't be automatically drawn after the DrawCharAction has ended.
+	end rem	
+	Field Handled:Int = False
+
+	rem
+		bbdoc: Has a value of type eDrawCharStatus that indicates if the character is being drawn as FACE, BORDER or SHADOW. This is read only.
+	end rem	
+	Field Status:Int
+End Type
+
+Type eDrawCharStatus Final
+	Const Face:Int = 1
+	Const Border:Int = 2
+	Const Shadow:Int = 4
+End Type

File diff suppressed because it is too large
+ 0 - 0
fontmachine.mod/FontMachine.bls


+ 12 - 0
fontmachine.mod/Utils/Check Version.bmx

@@ -0,0 +1,12 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+Rem
+	bbdoc:Type Type contains the version information of the current FontMachine module
+End Rem
+Type TFontMachineVersion Abstract
+	rem
+		bbdoc: This function returns a string representation of the current Font Machine Module version.
+	end rem
+	Function Version:String()
+		Return My.Application.AssemblyInfo
+	End Function
+End Type

+ 80 - 0
fontmachine.mod/Utils/Drawing.bmx

@@ -0,0 +1,80 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+Rem
+	bbdoc: Rectangle type
+end rem
+Type TRectangle
+	rem
+		bbdoc: X coordinate of the rectangle
+	end rem
+	Field X:Float
+	rem
+		bbdoc: Y coordinate of the rectangle
+	end rem
+	Field Y:Float
+	rem
+		bbdoc: Rectangle width
+	end rem
+	Field Width:Float
+	rem
+		bbdoc: Rectangle height
+	end rem
+	Field Height:Float
+
+	rem
+		bbdoc: Create a rectangle with the specified X, Y coordinates, and the given Width and Height
+	end rem
+	Function Create:TRectangle(X:Float, Y:Float, Width:Float, Height:Float) 
+		Local RC:TRectangle = New TRectangle
+		rc.X = x
+		rc.Y = y
+		rc.Width = width
+		rc.Height = height
+		Return rc
+	End Function
+	Method Clone:TRectangle() 
+		Return CreateRectangle(Self.X, Self.Y, Self.Width, Self.Height) 
+	End Method
+End Type
+
+rem
+	bbdoc: Create a rectangle with the specified X, Y coordinates, and the given Width and Height
+end rem
+Function CreateRectangle:TRectangle(X:Float, Y:Float, Width:Float, Height:Float) 
+	Return TRectangle.Create(x, y, width, height) 
+End Function
+
+rem
+	bbdoc: Drawing Point type
+end rem
+
+Type TDrawingPoint
+	rem
+		bbdoc:X coordinate of a drawing point
+	end rem
+	Field X:Float
+	rem
+		bbdoc:Y corrdinate of a drawing point
+	end rem
+	Field Y:Float
+	
+	rem
+		bbdoc: Create a DrawingPoint with the specified X and Y coordinates
+	end rem
+	Function Create:TDrawingPoint(X:Float, Y:Float) 
+		Local DP:TDrawingPoint = New TDrawingPoint
+		dp.X = x
+		dp.Y = y
+		Return dp
+	End Function
+	Method Clone:TDrawingPoint() 
+		Return CreateDrawingPoint(Self.X, Self.Y) 
+	End Method
+End Type
+
+rem
+	bbdoc: Create a DrawingPoint with the specified X and Y coordinates
+end rem
+Function CreateDrawingPoint:TDrawingPoint(X:Float, Y:Float) 
+	Return TDrawingPoint.Create(x, y) 
+End Function
+

+ 94 - 0
fontmachine.mod/Utils/fontmachineUtils.bmx

@@ -0,0 +1,94 @@
+REM
+This file was created by the BLIde solution explorer and should not be modified from outside BLIde
+EndRem
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HFF Program Info
+'Program: Untitled
+'Version: 0
+'Subversion: 0
+'Revision: 1
+'#EndRegion &HFF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H01 Compile Options
+Strict
+'#EndRegion &H01
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H0F Framework
+Import brl.math
+Import brl.basic
+'#EndRegion &H0F
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HAF Imports
+
+'#EndRegion &HAF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H04 MyNamespace
+'LIB
+'guid:84d6b1ac_20df_4ac4_b754_f05b5e01c02b
+Private
+TYPE z_84d6b1ac_20df_4ac4_b754_f05b5e01c02b_3_0 abstract  'Resource folder
+End Type
+
+
+TYPE z_blide_bg84d6b1ac_20df_4ac4_b754_f05b5e01c02b Abstract
+    Const Name:string = "Untitled" 'This string contains the name of the program
+    Const MajorVersion:Int = 0  'This Const contains the major version number of the program
+    Const MinorVersion:Int = 0  'This Const contains the minor version number of the program
+    Const Revision:Int =  1  'This Const contains the revision number of the current program version
+    Const VersionString:String = MajorVersion + "." + MinorVersion + "." + Revision   'This string contains the assembly version in format (MAJOR.MINOR.REVISION)
+    Const AssemblyInfo:String = Name + " " + MajorVersion + "." + MinorVersion + "." + Revision   'This string represents the available assembly info.
+    ?win32
+    Const Platform:String = "Win32" 'This constant contains "Win32", "MacOs" or "Linux" depending on the current running platoform for your game or application.
+    ?
+    ?MacOs
+    Const Platform:String = "MacOs"
+    ?
+    ?Linux
+    Const Platform:String = "Linux"
+    ?
+    ?PPC
+    Const Architecture:String = "PPC" 'This const contains "x86" or "Ppc" depending on the running architecture of the running computer. x64 should return also a x86 value
+    ?
+    ?x86
+    Const Architecture:String = "x86" 
+    ?
+    ?debug
+    Const DebugOn : Int = True    'This const will have the integer value of TRUE if the application was build on debug mode, or false if it was build on release mode
+    ?
+    ?not debug
+    Const DebugOn : Int = False
+    ?
+EndType
+
+
+Type z_My_84d6b1ac_20df_4ac4_b754_f05b5e01c02b Abstract 'This type has all the run-tima binary information of your assembly
+    Global Application:z_blide_bg84d6b1ac_20df_4ac4_b754_f05b5e01c02b  'This item has all the currently available assembly version information.
+    Global Resources:z_84d6b1ac_20df_4ac4_b754_f05b5e01c02b_3_0  'This item has all the currently available incbined files names and relative location.
+End Type
+
+
+Global My:z_My_84d6b1ac_20df_4ac4_b754_f05b5e01c02b 'This GLOBAL has all the run-time binary information of your assembly, and embeded resources shortcuts.
+Public
+'#EndRegion &H04 MyNamespace
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H03 Includes
+Include "Check Version.bmx"
+Include "Drawing.bmx"
+Include "functions.bmx"
+ 
+'#EndRegion &H03
+

+ 30 - 0
fontmachine.mod/Utils/functions.bmx

@@ -0,0 +1,30 @@
+'This BMX file was edited with BLIde ( http://www.blide.org )
+'Private
+Function GetRotationCords:TDrawingPoint(Angle:Float, Source:TDrawingPoint, Center:TDrawingPoint) 
+?Not debug
+	If angle >= - 0.01 And angle <= 0.01 Then	'Little optimization for release mode
+		Return CreateDrawingPoint(source.X, source.Y) 
+	End If
+?
+	Local Radius:Double = ((source.X - center.x) ^ 2 + (source.Y - center.Y) ^ 2) ^ 0.5
+	Local NewX:Double = Double(Center.X) + Double(radius) * Cos(angle) 
+	Local NewY:Double = Double(Center.Y) + Double(radius) * Sin(angle) 
+	Return CreateDrawingPoint(Float(newx), Float(newy)) 
+End Function
+
+Function DPrints(T:String) 
+	?debug
+		Print t
+	?
+
+End Function
+
+
+Rem
+	bbdoc: This function rounds properly a decimal value.
+end rem
+Function FM_Round:Int(number:Double)
+	Return Int(number + 0.5:Double * Sgn(number))
+End Function
+
+'Public

BIN
fontmachine.mod/doc/Banner1.png


+ 19 - 0
fontmachine.mod/doc/DrawBitMapText.bmx

@@ -0,0 +1,19 @@
+SuperStrict
+'First, we tell BlitzMax we are using the font machine module:
+Import blide.fontmachine
+
+'Start the graphics window:
+Graphics 800, 600
+
+'We tell BlitzMax that there is an object called fnt1 wich is a bitmap font:
+Local fnt1:TBitmapFont
+
+'We create the object, loading the font samplefont.fmf
+fnt1 = LoadBitmapFont("samplefont.fmf") 
+
+'Main loop:
+While Not KeyHit(KEY_ESCAPE) 
+	Cls
+	DrawBitMapText(fnt1,"Hello world!", 0, 0) 
+	Flip
+Wend

+ 20 - 0
fontmachine.mod/doc/DrawText.bmx

@@ -0,0 +1,20 @@
+SuperStrict
+'First, we tell BlitzMax we are using the font machine module:
+
+Import blide.fontmachine
+
+'Start the graphics window:
+Graphics 800, 600, 0
+
+'We tell BlitzMax that there is an object called fnt1 wich is a bitmap font:
+Local fnt1:TBitmapFont
+
+'We create the object, loading the font samplefont.fmf
+fnt1 = LoadBitmapFont("samplefont.fmf") 
+
+'Main loop:
+While Not KeyHit(KEY_ESCAPE) 
+	Cls
+	fnt1.DrawText("Hello world!", 0, 0) 
+	Flip
+Wend

+ 58 - 0
fontmachine.mod/doc/DrawTextBegin.bmx

@@ -0,0 +1,58 @@
+SuperStrict
+'This is a simple example of how to create a font FX
+
+'First, we tell BlitzMax we are using the font machine module:
+Import blide.fontmachine
+
+rem
+	To create a spetial FX text drawer, we have to create ower own FX object.
+	This can be easilly done by extending the iTextRendererFXBase object.
+	This object has been created as a 'sort of' interface.
+end rem
+Type FontFx1 Extends iTextRendererFXBase
+	'This method will be automatically called by the Font Machine engine before any border char is drawed.
+	Method DrawBorderChar(e:TDrawCharAction) 
+		
+	End Method
+	'This method will be automatically called by the Font Machine engine before any shadow char is drawed.
+	Method DrawShadowChar(e:TDrawCharAction) 
+		
+	End Method
+
+	'This method will be automatically called by the Font Machine engine before any face char is drawed.
+	Method DrawFaceChar(e:TDrawCharAction) 
+
+	End Method
+	
+	'This method will be called automatically by the font machine engine when a draw text operation is started.
+	Method DrawTextBegin(e:TDrawTextAction) 
+		e.Font.Kerning.SetHKerning(Sin(MilliSecs()))  'This is the special FX for this renderer.
+	End Method
+
+	'This method will be called automatically by the font machine engine when a draw text operation is ended.
+	Method DrawTextEnd(e:TDrawTextAction) 
+		
+	End Method
+End Type
+
+
+
+'Start the graphics window:
+Graphics 800, 600
+
+'We tell BlitzMax that there is an object called fnt1 wich is a bitmap font:
+Local fnt1:TBitmapFont
+
+'We create the object, loading the font samplefont.fmf
+fnt1 = LoadBitmapFont("samplefont.fmf") 
+
+'We connect the font with the FX:
+fnt1.RenderFX = New FontFx1
+
+'Main loop:
+While Not KeyHit(KEY_ESCAPE)
+	Cls
+	DrawBitMapText(fnt1, "Hello World", 0, 0) 
+	Flip
+Wend
+

BIN
fontmachine.mod/doc/Examples/Test Program/Fonts/Jungle.fmf


BIN
fontmachine.mod/doc/Examples/Test Program/Fonts/NewCaveman.fmf


BIN
fontmachine.mod/doc/Examples/Test Program/Fonts/Small.fmf


BIN
fontmachine.mod/doc/Examples/Test Program/Fonts/luxury.fmf


BIN
fontmachine.mod/doc/Examples/Test Program/Images/GNOME-GreenField_1024x768.jpg


BIN
fontmachine.mod/doc/Examples/Test Program/Sample Program1.bmx


+ 113 - 0
fontmachine.mod/doc/Examples/Test Program/TestProgram 1.bmx

@@ -0,0 +1,113 @@
+'This is a simple fonrmachine test program
+REM
+This file was created by the BLIde solution explorer and should not be modified from outside BLIde
+EndRem
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HFF Program Info
+'Program: FontMachine Test Program 1
+'Version: 0
+'Subversion: 2
+'Revision: 1
+'#EndRegion &HFF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H01 Compile Options
+Strict
+'#EndRegion &H01
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H0F Framework
+Import blide.fontmachine
+'#EndRegion &H0F
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HAF Imports
+
+'#EndRegion &HAF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H04 MyNamespace
+'GUI
+'guid:6daa6268_2f2d_4b47_82b1_681021ebb211
+Private
+TYPE z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_0 abstract  'Resource folder
+    Global Fonts:z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_1 '<b>Resource folder</b>
+    Global Images:z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_2 '<b>Resource folder</b>
+End Type
+
+
+TYPE z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_1 abstract  'Resource folder
+    Const luxury_fmf:String = "incbin::Fonts\luxury.fmf" 'String constant containing the value: "<b><font color=#0000AA>incbin::Fonts\luxury.fmf</font></b>"
+    Const NewCaveman_fmf:String = "incbin::Fonts\NewCaveman.fmf" 'String constant containing the value: "<b><font color=#0000AA>incbin::Fonts\NewCaveman.fmf</font></b>"
+    Const Small_fmf:String = "incbin::Fonts\Small.fmf" 'String constant containing the value: "<b><font color=#0000AA>incbin::Fonts\Small.fmf</font></b>"
+    Const Jungle_fmf:String = "incbin::Fonts\Jungle.fmf" 'String constant containing the value: "<b><font color=#0000AA>incbin::Fonts\Jungle.fmf</font></b>"
+End Type
+
+
+TYPE z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_2 abstract  'Resource folder
+    Const GNOME_GreenField_1024x768_jpg:String = "incbin::Images\GNOME-GreenField_1024x768.jpg" 'String constant containing the value: "<b><font color=#0000AA>incbin::Images\GNOME-GreenField_1024x768.jpg</font></b>"
+End Type
+
+
+TYPE z_blide_bg6daa6268_2f2d_4b47_82b1_681021ebb211 Abstract
+    Const Name:string = "FontMachine Test Program 1" 'This string contains the name of the program
+    Const MajorVersion:Int = 0  'This Const contains the major version number of the program
+    Const MinorVersion:Int = 2  'This Const contains the minor version number of the program
+    Const Revision:Int =  1  'This Const contains the revision number of the current program version
+    Const VersionString:String = MajorVersion + "." + MinorVersion + "." + Revision   'This string contains the assembly version in format (MAJOR.MINOR.REVISION)
+    Const AssemblyInfo:String = Name + " " + MajorVersion + "." + MinorVersion + "." + Revision   'This string represents the available assembly info.
+    ?win32
+    Const Platform:String = "Win32" 'This constant contains "Win32", "MacOs" or "Linux" depending on the current running platoform for your game or application.
+    ?
+    ?MacOs
+    Const Platform:String = "MacOs"
+    ?
+    ?Linux
+    Const Platform:String = "Linux"
+    ?
+    ?PPC
+    Const Architecture:String = "PPC" 'This const contains "x86" or "Ppc" depending on the running architecture of the running computer. x64 should return also a x86 value
+    ?
+    ?x86
+    Const Architecture:String = "x86" 
+    ?
+    ?debug
+    Const DebugOn : Int = True    'This const will have the integer value of TRUE if the application was build on debug mode, or false if it was build on release mode
+    ?
+    ?not debug
+    Const DebugOn : Int = False
+    ?
+EndType
+
+
+Type z_My_6daa6268_2f2d_4b47_82b1_681021ebb211 Abstract 'This type has all the run-tima binary information of your assembly
+    Global Application:z_blide_bg6daa6268_2f2d_4b47_82b1_681021ebb211  'This item has all the currently available assembly version information.
+    Global Resources:z_6daa6268_2f2d_4b47_82b1_681021ebb211_3_0  'This item has all the currently available incbined files names and relative location.
+End Type
+
+
+Global My:z_My_6daa6268_2f2d_4b47_82b1_681021ebb211 'This GLOBAL has all the run-time binary information of your assembly, and embeded resources shortcuts.
+Public
+'#EndRegion &H04 MyNamespace
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H03 Includes
+Include "Sample Program1.bmx"
+ 
+Incbin "Fonts\luxury.fmf"
+Incbin "Fonts\NewCaveman.fmf"
+'#EndRegion &H03
+Incbin "Fonts\Small.fmf"
+
+Incbin "Images\GNOME-GreenField_1024x768.jpg"
+
+Incbin "Fonts\Jungle.fmf"

+ 108 - 0
fontmachine.mod/doc/Examples/TestProgram2/FMFPreview.bmx

@@ -0,0 +1,108 @@
+'This is a simple font machine test program
+REM
+This file was created by the BLIde solution explorer and should not be modified from outside BLIde
+EndRem
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HFF Program Info
+'Program: FontMachine preview
+'Version: 0
+'Subversion: 1
+'Revision: 2
+'#EndRegion &HFF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H01 Compile Options
+Strict
+'#EndRegion &H01
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H0F Framework
+Import blide.fontmachine
+Import maxgui.drivers
+Import maxgui.maxgui
+'#EndRegion &H0F
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HAF Imports
+
+'#EndRegion &HAF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H04 MyNamespace
+'GUI
+'guid:9f486ac6_cae1_4dac_985e_db3ff45ca63d
+Private
+TYPE z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_0 abstract  'Resource folder
+    Global TestForn1:z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_1 '<b>Resource folder</b>
+    Global Images:z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_2 '<b>Resource folder</b>
+End Type
+
+
+TYPE z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_1 abstract  'Resource folder
+    Const Small_fmf:String = "incbin::TestForn1\Small.fmf" 'String constant containing the value: "<b><font color=#0000AA>incbin::TestForn1\Small.fmf</font></b>"
+End Type
+
+
+TYPE z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_2 abstract  'Resource folder
+    Const fondo_png:String = "incbin::Images\fondo.png" 'String constant containing the value: "<b><font color=#0000AA>incbin::Images\fondo.png</font></b>"
+End Type
+
+
+TYPE z_blide_bg9f486ac6_cae1_4dac_985e_db3ff45ca63d Abstract
+    Const Name:string = "FontMachine preview" 'This string contains the name of the program
+    Const MajorVersion:Int = 0  'This Const contains the major version number of the program
+    Const MinorVersion:Int = 1  'This Const contains the minor version number of the program
+    Const Revision:Int =  2  'This Const contains the revision number of the current program version
+    Const VersionString:String = MajorVersion + "." + MinorVersion + "." + Revision   'This string contains the assembly version in format (MAJOR.MINOR.REVISION)
+    Const AssemblyInfo:String = Name + " " + MajorVersion + "." + MinorVersion + "." + Revision   'This string represents the available assembly info.
+    ?win32
+    Const Platform:String = "Win32" 'This constant contains "Win32", "MacOs" or "Linux" depending on the current running platoform for your game or application.
+    ?
+    ?MacOs
+    Const Platform:String = "MacOs"
+    ?
+    ?Linux
+    Const Platform:String = "Linux"
+    ?
+    ?PPC
+    Const Architecture:String = "PPC" 'This const contains "x86" or "Ppc" depending on the running architecture of the running computer. x64 should return also a x86 value
+    ?
+    ?x86
+    Const Architecture:String = "x86" 
+    ?
+    ?debug
+    Const DebugOn : Int = True    'This const will have the integer value of TRUE if the application was build on debug mode, or false if it was build on release mode
+    ?
+    ?not debug
+    Const DebugOn : Int = False
+    ?
+EndType
+
+
+Type z_My_9f486ac6_cae1_4dac_985e_db3ff45ca63d Abstract 'This type has all the run-tima binary information of your assembly
+    Global Application:z_blide_bg9f486ac6_cae1_4dac_985e_db3ff45ca63d  'This item has all the currently available assembly version information.
+    Global Resources:z_9f486ac6_cae1_4dac_985e_db3ff45ca63d_3_0  'This item has all the currently available incbined files names and relative location.
+End Type
+
+
+Global My:z_My_9f486ac6_cae1_4dac_985e_db3ff45ca63d 'This GLOBAL has all the run-time binary information of your assembly, and embeded resources shortcuts.
+Public
+'#EndRegion &H04 MyNamespace
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H03 Includes
+Include "Preview dialog.bmx"
+ 
+Incbin "TestForn1\Small.fmf"
+Incbin "Images\fondo.png"
+'#EndRegion &H03
+

BIN
fontmachine.mod/doc/Examples/TestProgram2/Images/fondo.png


+ 203 - 0
fontmachine.mod/doc/Examples/TestProgram2/Preview dialog.bmx

@@ -0,0 +1,203 @@
+AppTitle = My.Application.AssemblyInfo
+Const Space:Int = 200
+If AppArgs.length = 1 Then
+	Notify("Missing command parameter.")
+	End
+End If
+SetGraphicsDriver GLMax2DDriver()
+Global Fondo:Timage
+Global Window:TGadget = CreateWindow("Font Machine Font Preview", 10, 10, 800, 600, Null, WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_RESIZABLE)
+Global CanvPanel:TGadget = CreatePanel(0, 0, window.width - space, window.height, window, PANEL_BORDER)
+SetGadgetLayout (CanvPanel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)
+
+Global Canvas:TGadget = CreateCanvas(0, 0, window.width - Space, window.height, CanvPanel)
+SetGadgetLayout (Canvas, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED)
+
+'PANEL:
+Global Panel:TGadget = createpanel(window.width - Space, 0, Space, window.height, window)
+SetGadgetLayout (Panel, EDGE_CENTERED, EDGE_ALIGNED, EDGE_RELATIVE, EDGE_ALIGNED)
+'Panel.SetColor(255, 0, 0)
+
+'LABEL:
+Global Label:TGadget = CreateLabel("Text:", 0, 0, space - 20, 17, panel)
+SetGadgetLayout (Label, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+
+'TEXTFIELD:
+Global Text:TGadget = CreateTextField(0, 17, Space - 20, 20, panel)
+SetGadgetLayout (Text, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+Text.SetText("Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
+
+'SIZELABEL:
+Global Label2:TGadget = CreateLabel("Size:", 0, text.ypos + 23, space - 20, 17, panel)
+SetGadgetLayout (Label2, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+
+'SIZER:
+Global Sizer:TGadget = CreateSlider(0, label2.ypos + 17, space - 20, 17, panel, SLIDER_HORIZONTAL)
+SetGadgetLayout (Sizer, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+SetSliderRange(Sizer, 5, 350)
+Sizer.SetProp(100)
+
+'HKERNING LABEL:
+Global Label3:TGadget = CreateLabel("Horizontal Kerning", 0, Sizer.ypos + 23, space - 20, 17, panel)
+SetGadgetLayout (Label3, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+
+'HKERNING:
+Global HKERNING:TGadget = CreateSlider(0, label3.ypos + 17, space - 20, 17, panel, SLIDER_HORIZONTAL)
+SetGadgetLayout (HKERNING, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+SetSliderRange(HKERNING, 0, 250)
+HKERNING.SetProp(50)
+
+'VKERNING LABEL:
+Global Label4:TGadget = CreateLabel("Vertical Kerning", 0, HKERNING.ypos + 23, space - 20, 17, panel)
+SetGadgetLayout (Label4, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+
+'VKERNING:
+Global VKERNING:TGadget = CreateSlider(0, label4.ypos + 17, space - 20, 17, panel, SLIDER_HORIZONTAL)
+SetGadgetLayout (VKERNING, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+SetSliderRange(VKERNING, 0, 250)
+VKERNING.SetProp(50)
+
+
+'Color
+Global ButColor:TGadget = CreateButton("Set back color", 0, VKERNING.ypos + 20, space - 20, 20, panel)
+SetGadgetLayout (ButColor, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+
+'Border:
+Global Chkborder:TGadget = CreateButton("Draw border", 0, butcolor.ypos + 20, space - 20, 20, panel, BUTTON_CHECKBOX)
+SetGadgetLayout (Chkborder, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+'Chkborder.SetProp(True)
+SetButtonState(Chkborder, 1)
+
+'Shadow:
+Global Chkshadow:TGadget = CreateButton("Draw shadow", 0, chkborder.ypos + 20, space - 20, 20, panel, BUTTON_CHECKBOX)
+SetGadgetLayout (Chkshadow, EDGE_ALIGNED, EDGE_CENTERED, EDGE_ALIGNED, EDGE_CENTERED)
+'Chkshadow.SetProp(True)
+SetButtonState(Chkshadow, 1)
+
+
+Global BackRed:Int = 255, BackGreen:Int = 255, backblue:Int = -255
+
+SetGraphics(canvas.CanvasGraphics())
+
+AddHook EmitEventHook, MyHook
+
+'Graphics 400, 300
+SetClsColor 255, 255, 255
+Cls
+Flip
+Global fntsmall:TBitmapFont = LoadBitmapFont(My.Resources.TestForn1.Small_fmf)
+
+Global fnt:TBitmapFont = New TBitmapFont
+Cls
+SetColor 0, 0, 0
+Local MSG:String = "Loading the font..."
+fntsmall.DrawText(MSG, GadgetWidth(Canvas) / 2 - fntsmall.GetTxtWidth(MSG) / 2, GadgetHeight(Canvas) / 2 - fntsmall.GetFontHeight())
+
+Global Scale:Float = 1
+
+Flip
+fnt.SetProgressFunction(Loading)
+fnt.UseMask = True
+fnt.MaskColorBlue = 255
+fnt.MaskColorGreen = 255
+fnt.MaskColorRed = 255
+'fnt.SetFaceBlend(EConstBlend.Mask )
+fnt.SetDrawBorder (False)
+'DebugStop
+fnt.SetDrawshadow (False)
+fnt.Load(AppArgs[1])
+If fnt.FontLoaded() = False Then
+	Notify("The font could not be loaded.")
+	'debugstop
+	End
+End If
+Flip()
+Repeat
+	WaitEvent()
+Forever
+
+
+'While Not KeyHit(KEY_ESCAPE)
+'Wend
+
+
+Function MyHook:Object(iId:Int, tData:Object, tContext:Object)
+	Local Event:TEvent = TEvent(TData)
+	'Print event.ToString()
+  	If event = Null Return Null
+	
+	If (Event.ID = EVENT_GADGETPAINT) Or (Event.ID = EVENT_WINDOWSIZE) Or (Event.ID = EVENT_WINDOWMOVE) Or (Event.ID = Event_AppResume) Then 
+		'ReDraw the canvas when requested (GadgetPaint) or when the window was moved, sized, resumed..
+		Canvas.SetArea(0, 0, Window.width, Window.height)
+		ReDraw()
+	ElseIf (event.id = EVENT_WINDOWCLOSE)
+		End
+	ElseIf (event.id = EVENT_GADGETACTION)
+		If event.source = Text Then
+			ReDraw()
+		ElseIf event.source = Sizer Or event.source = HKERNING Or event.source = VKERNING Then
+			'Print event.ToString()
+			ReDraw()
+		ElseIf event.source = ButColor Then
+			RequestColor(BackRed, BackGreen, backblue)
+			BackRed = RequestedRed()
+			BackGreen = RequestedGreen()
+			backblue = RequestedBlue()
+			ReDraw()
+		ElseIf event.source = Chkborder Or event.source = Chkshadow Then
+			ReDraw()
+		End If
+	End If
+	Return TData
+End Function
+
+Function ReDraw()
+	SetGraphics CanvasGraphics (Canvas)
+	If Fondo = Null Then
+		Fondo = LoadImage(My.Resources.Images.fondo_png)
+	End If
+	SetViewport 0, 0, GadgetWidth(Canvas), GadgetHeight(Canvas)
+	SetColor 255, 255, 255
+	If backblue >= 0 Then
+		SetClsColor BackRed, BackGreen, backblue
+		Cls
+	Else
+		Cls 
+		TileImage(Fondo, 0, 0)
+	EndIf
+	
+	fnt.SetDrawBorder(ButtonState(Chkborder) <> 0)
+	fnt.SetDrawshadow(ButtonState(Chkshadow) <> 0)
+	fnt.Kerning.SetHKerning(HKERNING.GetProp() - 50)
+	fnt.Kerning.SetVKerning(VKERNING.GetProp() - 50)
+	Local Txt:String = Text.GetText()
+	Local resize:Float = Float(Sizer.GetProp() / 100.0)
+	SetScale resize, resize
+
+	fnt.DrawTextMaxWidth (txt, 10, 10, GadgetWidth(Canvas) - (Space + 20),True)
+	SetScale 1, 1
+	Flip
+End Function
+
+Function Loading(Percent:Float)
+	Global lastpercent:Int = MilliSecs()
+	If MilliSecs() - lastpercent > 200 Then
+		lastpercent = MilliSecs()
+		Cls
+		SetColor 0, 0, 0
+		Local MSG:String = "Loading the font (" + Int(percent) + "%)..."
+		Local Width:Float = fntsmall.GetTxtWidth(MSG)
+		Local X:Float = GadgetWidth(Canvas) / 2 - width / 2
+		Local Y:Float = GadgetHeight(Canvas) / 2 - fntsmall.GetFontHeight()
+		fntsmall.DrawText(MSG, X, Y)
+		SetColor(100, 100, 100)
+		y:+fntsmall.GetFontHeight()
+		Const progHeight:Int = 6
+		DrawRect(x, y, width, progHeight)
+		SetColor(255, 255, 255)
+		DrawRect(x + 1, y + 1, width - 2, progHeight - 2)
+		SetColor (155, 155, 155)
+		DrawRect(x + 1, y + 1, (percent / 100.0) * (width - 2), progHeight - 2)
+		Flip
+	EndIf
+End Function

BIN
fontmachine.mod/doc/Examples/TestProgram2/TestForn1/Small.fmf


BIN
fontmachine.mod/doc/SampleFont.fmf


+ 29 - 0
fontmachine.mod/doc/SetHKerning.bmx

@@ -0,0 +1,29 @@
+SuperStrict
+'First, we tell BlitzMax we are using the font machine module:
+Import blide.fontmachine
+
+'Start the graphics window:
+Graphics 800, 600
+
+'We tell BlitzMax that there is an object called fnt1 wich is a bitmap font:
+Local fnt1:TBitmapFont
+
+'We create the object, loading the font samplefont.fmf
+fnt1 = LoadBitmapFont("samplefont.fmf") 
+
+'Main loop:
+While Not KeyHit(KEY_ESCAPE) 
+	Cls
+	DrawBitMapText(fnt1, "Q,W change the~nfont horizontal~nkerning", 0, 0) 
+	If KeyDown(KEY_Q) Then
+		Local TempValue:Float
+		TempValue = fnt1.Kerning.GetHKerning() 
+		fnt1.Kerning.SetHKerning(TempValue + 0.1) 
+	EndIf
+	If KeyDown(KEY_W) Then
+		Local TempValue:Float
+		TempValue = fnt1.Kerning.GetHKerning() 
+		fnt1.Kerning.SetHKerning(TempValue - 0.1) 
+	End If
+	Flip
+Wend

+ 29 - 0
fontmachine.mod/doc/SetVKerning.bmx

@@ -0,0 +1,29 @@
+SuperStrict
+'First, we tell BlitzMax we are using the font machine module:
+Import blide.fontmachine
+
+'Start the graphics window:
+Graphics 800, 600
+
+'We tell BlitzMax that there is an object called fnt1 wich is a bitmap font:
+Local fnt1:TBitmapFont
+
+'We create the object, loading the font samplefont.fmf
+fnt1 = LoadBitmapFont("samplefont.fmf") 
+
+'Main loop:
+While Not KeyHit(KEY_ESCAPE) 
+	Cls
+	DrawBitMapText(fnt1, "Q,W change the~nfont vertical~nkerning", 0, 0) 
+	If KeyDown(KEY_Q) Then
+		Local TempValue:Float
+		TempValue = fnt1.Kerning.GetVKerning() 
+		fnt1.Kerning.SetVKerning(TempValue + 0.5) 
+	EndIf
+	If KeyDown(KEY_W) Then
+		Local TempValue:Float
+		TempValue = fnt1.Kerning.GetVKerning() 
+		fnt1.Kerning.SetVKerning(TempValue - 0.5) 
+	End If
+	Flip
+Wend

+ 105 - 0
fontmachine.mod/fontmachine.bmx

@@ -0,0 +1,105 @@
+REM
+This file was created by the BLIde solution explorer and should not be modified from outside BLIde
+EndRem
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HFF Program Info
+'Program: Font Machine
+'Version: 1
+'Subversion: 5
+'Revision: 1
+'#EndRegion &HFF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H01 Compile Options
+SuperStrict
+Rem
+    bbdoc:blide\fontmachine
+End Rem
+Module blide.fontmachine
+'#EndRegion &H01
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H0F Framework
+Import brl.max2d
+Import brl.pngloader
+Import brl.retro
+Import brl.system
+Import brl.reflection
+'#EndRegion &H0F
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &HAF Imports
+'?flags
+Import ".\Utils\fontmachineUtils.bmx"
+'?
+'#EndRegion &HAF
+
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H04 MyNamespace
+'GUI
+'guid:e3390d53_c8a7_41d3_9293_f4dcf0f638b5
+Private
+TYPE z_e3390d53_c8a7_41d3_9293_f4dcf0f638b5_3_0 abstract  'Resource folder
+End Type
+
+
+TYPE z_blide_bge3390d53_c8a7_41d3_9293_f4dcf0f638b5 Abstract
+    Const Name:string = "Font Machine" 'This string contains the name of the program
+    Const MajorVersion:Int = 1  'This Const contains the major version number of the program
+    Const MinorVersion:Int = 5  'This Const contains the minor version number of the program
+    Const Revision:Int =  1  'This Const contains the revision number of the current program version
+    Const VersionString:String = MajorVersion + "." + MinorVersion + "." + Revision   'This string contains the assembly version in format (MAJOR.MINOR.REVISION)
+    Const AssemblyInfo:String = Name + " " + MajorVersion + "." + MinorVersion + "." + Revision   'This string represents the available assembly info.
+    ?win32
+    Const Platform:String = "Win32" 'This constant contains "Win32", "MacOs" or "Linux" depending on the current running platoform for your game or application.
+    ?
+    ?MacOs
+    Const Platform:String = "MacOs"
+    ?
+    ?Linux
+    Const Platform:String = "Linux"
+    ?
+    ?PPC
+    Const Architecture:String = "PPC" 'This const contains "x86" or "Ppc" depending on the running architecture of the running computer. x64 should return also a x86 value
+    ?
+    ?x86
+    Const Architecture:String = "x86" 
+    ?
+    ?debug
+    Const DebugOn : Int = True    'This const will have the integer value of TRUE if the application was build on debug mode, or false if it was build on release mode
+    ?
+    ?not debug
+    Const DebugOn : Int = False
+    ?
+EndType
+
+
+Type z_My_e3390d53_c8a7_41d3_9293_f4dcf0f638b5 Abstract 'This type has all the run-tima binary information of your assembly
+    Global Application:z_blide_bge3390d53_c8a7_41d3_9293_f4dcf0f638b5  'This item has all the currently available assembly version information.
+    Global Resources:z_e3390d53_c8a7_41d3_9293_f4dcf0f638b5_3_0  'This item has all the currently available incbined files names and relative location.
+End Type
+
+
+Global My:z_My_e3390d53_c8a7_41d3_9293_f4dcf0f638b5 'This GLOBAL has all the run-time binary information of your assembly, and embeded resources shortcuts.
+Public
+'#EndRegion &H04 MyNamespace
+
+
+'------------------------------------------------------------------------------------------------------------------------------------------------------
+'#Region &H03 Includes
+Include "BitMapFont.bmx"
+Include "Font Properties\fontBlends.bmx"
+Include "Exceptions\TDrawTextException.bmx"
+Include "Font Properties\BitMapChar.bmx"
+Include "FontFX\TextRendererFX.bmx"
+Include "FontFX\FontKerning.bmx"
+
+'#EndRegion &H03
+

Some files were not shown because too many files changed in this diff