Create my own font with lib VECTOR
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Create my own font with lib VECTOR
Hello at all
I have a stupid question .....(Like usually !! Several members probably say)
I want to know, if at your advice, it's possible to create my own font (pixel by pixel) in a canvas gadget and lib vector.
I don't want using DrawText, it's for just a matrix of 80 x 24 characters
But i wondering, if i write all my hundred characters, pixel by pixel i can resizing the canvas without have flickering ?
Someone have already do that ? or i'm again the only one donkey of the world who have this idea
Have a good day
I have a stupid question .....(Like usually !! Several members probably say)
I want to know, if at your advice, it's possible to create my own font (pixel by pixel) in a canvas gadget and lib vector.
I don't want using DrawText, it's for just a matrix of 80 x 24 characters
But i wondering, if i write all my hundred characters, pixel by pixel i can resizing the canvas without have flickering ?
Someone have already do that ? or i'm again the only one donkey of the world who have this idea
Have a good day
The happiness is a road...
Not a destination
Not a destination
Re: Create my own font with lib VECTOR
Hi KCC
You have posted in the Progressbar_EX thread
http://www.purebasic.fr/english/viewtop ... 12&t=68732
Looking, directly under your posting is a little code
This code make exactly this, you can extract simple what you want and also looking how its work
Not needed code parts you can simple delete, looking for "text$"
You have posted in the Progressbar_EX thread
http://www.purebasic.fr/english/viewtop ... 12&t=68732
Looking, directly under your posting is a little code
This code make exactly this, you can extract simple what you want and also looking how its work
Not needed code parts you can simple delete, looking for "text$"
Re: Create my own font with lib VECTOR
I found sprites font...
Link http://www.purebasic.fr/english/viewtop ... 92#p359614
Draw found on sprites...
Link http://www.purebasic.fr/english/viewtop ... 92#p359614
Draw found on sprites...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
First, thanks at you two for your help
@Walbus
The code you show me not really do what i search
Because you use LoadFont() and DrawRotatedText()
And i can't use this natives functions
In fact i have create a IBM 3270 simulator, with 80 collumns and 24 lines
The main function of this emulator, is to be resized, and the characters resized in the same time
I have try several method for do that, the EMF pictures and others i don't remember, but the top is the lib VECTOR and that run perfectly
Except a problem, because they are always a problem
The lib VECTOR can't use font not registred, me and others members don't know why, probably a bug, but it's not sure :
After, i have try also several codes, using "AddFontMemResourceEx_()" or "AddFontResource_()" and that not works, the font is in windows, because WORDS and EXCEL see it, and i can writing with her, but not the libvector
And i have try "RegisterFontFile()" and here it's worst again, the code is locked at this line, on my machine
Surely the right administrator needed, or Active directory not allows the install for security
FRED never answer my question since 2016, so i have another time show the problem
http://www.purebasic.fr/english/viewtop ... 75#p510775
Then, i say to me, perhaps it's possible to jump the loading of font, drawing a copy of my favorite font, pixel by pixel, one time for all, like this, never i have again this problem like several years
My problem is what ?
For simulate the old IBM, i can't use ARIAL, or other font already installed on all windows machine, but a special font "*.fon"
Then, when i run my simuilator on new machine, i'm forcing to instal it before, and on all the machine i use, i'm not admin and the active directory is very restrictive, it's impossible to install fonts, without be administrator for a security problem.
I have search yesterday, and everybody say it's not possible, except if i use external soft, who perhaps can simulate the install, but i found it's not really a good solution
@Mk-Soft
It's interesting, but i'm not sure i can resize the windows and the characters is resizing in the same time ?
Furthermore, i'm not sure too, i can choose the font without load it
@Walbus
The code you show me not really do what i search
Because you use LoadFont() and DrawRotatedText()
And i can't use this natives functions
In fact i have create a IBM 3270 simulator, with 80 collumns and 24 lines
The main function of this emulator, is to be resized, and the characters resized in the same time
I have try several method for do that, the EMF pictures and others i don't remember, but the top is the lib VECTOR and that run perfectly
Except a problem, because they are always a problem
The lib VECTOR can't use font not registred, me and others members don't know why, probably a bug, but it's not sure :
http://www.purebasic.fr/english/viewtop ... 52#p489452RASHAD wrote:Hi KCC
Yes it is a bug with VectorFont()
If you installed the fonts using windows install the VectorFont() will work as expected
You can report it as a bug
You can install the fonts using code by coping the files direct to windows fonts directory then add some registry data
After, i have try also several codes, using "AddFontMemResourceEx_()" or "AddFontResource_()" and that not works, the font is in windows, because WORDS and EXCEL see it, and i can writing with her, but not the libvector
And i have try "RegisterFontFile()" and here it's worst again, the code is locked at this line, on my machine
Surely the right administrator needed, or Active directory not allows the install for security
FRED never answer my question since 2016, so i have another time show the problem
http://www.purebasic.fr/english/viewtop ... 75#p510775
Then, i say to me, perhaps it's possible to jump the loading of font, drawing a copy of my favorite font, pixel by pixel, one time for all, like this, never i have again this problem like several years
My problem is what ?
For simulate the old IBM, i can't use ARIAL, or other font already installed on all windows machine, but a special font "*.fon"
Then, when i run my simuilator on new machine, i'm forcing to instal it before, and on all the machine i use, i'm not admin and the active directory is very restrictive, it's impossible to install fonts, without be administrator for a security problem.
I have search yesterday, and everybody say it's not possible, except if i use external soft, who perhaps can simulate the install, but i found it's not really a good solution
@Mk-Soft
It's interesting, but i'm not sure i can resize the windows and the characters is resizing in the same time ?
Furthermore, i'm not sure too, i can choose the font without load it
The happiness is a road...
Not a destination
Not a destination
Re: Create my own font with lib VECTOR
Hi KCC
You can replace the text call with any other things
This code give you a skeleton for flicker free animation any things on canvas
You can replace the text call with any other things
This code give you a skeleton for flicker free animation any things on canvas
Re: Create my own font with lib VECTOR
The easiest way might be to store the font as one bitmap image (like a sprite sheet) and copy the characters from there.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
Thanks WALBUS
This is my goal, in fact i believe i have my answer
This morning, i have write quickly this, for see if VECTOR is also fast for rewrite hundred characters in resizing, before try to spent much time to create pixel by pixel my own font
Apparently no problem...
I hope if the characters is differents, it's the same thing
This is the A, i can now officially announce the creation of the first character of my first font
This is my goal, in fact i believe i have my answer
This morning, i have write quickly this, for see if VECTOR is also fast for rewrite hundred characters in resizing, before try to spent much time to create pixel by pixel my own font
Apparently no problem...
I hope if the characters is differents, it's the same thing
This is the A, i can now officially announce the creation of the first character of my first font
Code: Select all
Enumeration
#Form
#Canvas
EndEnumeration
Global StartX.f
Global StartY.f
Procedure A(x, y, SizeX, SizeY, Strong)
MovePathCursor(x, y)
AddPathLine(0, - SizeY, #PB_Path_Relative)
AddPathLine(SizeX, 0, #PB_Path_Relative)
AddPathLine(0, SizeY, #PB_Path_Relative)
CursorY = SizeY/2
MovePathCursor(PathCursorX(), PathCursorY() - CursorY)
AddPathLine(- SizeX, 0, #PB_Path_Relative)
StrokePath(Strong, #PB_Path_Default)
EndProcedure
Procedure WriteText(x.f = 0, y.f = 0, Couleur = 0)
ClearGadgetItems(#Canvas)
If StartVectorDrawing(CanvasVectorOutput(#Canvas))
VectorSourceColor(RGBA(255,255,255,255))
FillVectorOutput()
VectorSourceColor(Couleur)
ScaleCoordinates(x, y)
For Lig = 1 To 300 Step 8
For Col = 1 To 400 Step 8
A(Col, Lig, 5, 5, 1)
Next
Next
StopVectorDrawing()
EndIf
EndProcedure
Procedure WinCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_SIZE
CoefX.f = WindowWidth(#Form) / StartX
CoefY.f = WindowHeight(#Form) / StartY
ResizeGadget(#Canvas, #PB_Ignore, #PB_Ignore, WindowWidth(#Form), WindowHeight(#Form))
WriteText(CoefX, CoefY, RGBA(255, 0, 0, 255))
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(#Form, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback())
CanvasGadget(#Canvas, 0, 0, 400, 200)
StartX = WindowWidth(#Form)
StartY = WindowHeight(#Form)
WriteText(0, 0, RGBA(255, 0, 0, 255))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
The happiness is a road...
Not a destination
Not a destination
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
Hello WILBERTWILBERT wrote:The easiest way might be to store the font as one bitmap image (like a sprite sheet) and copy the characters from there.
You mean, it's possible to capture the Font i need, letter by letter in BMP, and after show each BMP by the libvector, and the result is perfect even if i resize very large or very small the canvas
Are you sure i not lost in clearness ??
The happiness is a road...
Not a destination
Not a destination
Re: Create my own font with lib VECTOR
On the BucketFill_advanced download packet, you can found demo codes for output any sprite sheets directly on canvas
With alpha blending, resizing and flicker free
The function is named "Sprite_CSS_sheet_BF"
But, you must looking what you want exactely do, mostly it is not a good idea try creating self propietary fonts
With alpha blending, resizing and flicker free
The function is named "Sprite_CSS_sheet_BF"
But, you must looking what you want exactely do, mostly it is not a good idea try creating self propietary fonts
Re: Create my own font with lib VECTOR
I think I misunderstood you. I assumed you wanted the font to look pixelated even when resizing.Kwai chang caine wrote:You mean, it's possible to capture the Font i need, letter by letter in BMP, and after show each BMP by the libvector, and the result is perfect even if i resize very large or very small the canvas
Are you sure i not lost in clearness ??
If you really want to use vectors, I recommend you take a look at the AddPathSegments(Segments$ [, Flags]) command and store the characters more like svg data.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
I completely aggree with you, you don't know how muchWalbus wrote:mostly it is not a good idea try creating self propietary fonts
My goal is to have the same font on all the machines, without load it, and mainly without passing all the futur night of my life with a pencil
I search the better and quick way for have a good result, without recreate the wheel
I take a look soon to the "BucketFill_advanced download packet", thanks a lot for the tips
In fact, i have see this splendid work, but sometime, some librairies do so much things very well, that i not really understand what she do exactely
I have take a look to this function, effectively she are really more simply, for create what i search to doWilbert wrote:If you really want to use vectors, I recommend you take a look at the AddPathSegments(Segments$ [, Flags]) command and store the characters more like svg data.
So i'm when even forced to writing each characters, one by one, and like say WALBUS it's not sure it's the better way
But you give to me a very nice idea
Perhaps, they exist software, or a PB code to translate bmp to SVG for not have to all hand writing ?
Or better, cut each character, analyse the picture BMP and write automaticaly the AddPathSegments() you show to me
Already, i have try like you say to me, and the result is not perfect, but not also ugly too ....
I think the better way, is capturing the letter, the most big possible, for not pixelise when the window is very big
Because i have see it's more simple for libvector to reduce than resize more big
The letter E
http://erdsjb.free.fr/purestorage/provisoires/E.bmp
Code: Select all
Enumeration
#Form
#Canvas
#Image
EndEnumeration
Global StartX.f
Global StartY.f
Procedure WriteImage(x.f = 0, y.f = 0)
If StartVectorDrawing(CanvasVectorOutput(#Canvas))
VectorSourceColor(RGBA(0,0,0,255))
FillVectorOutput()
ScaleCoordinates(x, y)
DrawVectorImage(ImageID(#Image), 255, ImageWidth(#Image), ImageHeight(#Image))
StopVectorDrawing()
EndIf
EndProcedure
Procedure WinCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_SIZE
CoefX.f = WindowWidth(#Form) / StartX
CoefY.f = WindowHeight(#Form) / StartY
ResizeGadget(#Canvas, #PB_Ignore, #PB_Ignore, WindowWidth(#Form), WindowHeight(#Form))
WriteImage(CoefX, CoefY)
EndSelect
ProcedureReturn Result
EndProcedure
If OpenWindow(#Form, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowCallback(@WinCallback())
CanvasGadget(#Canvas, 0, 0, 400, 200)
StartX = WindowWidth(#Form)
StartY = WindowHeight(#Form)
LoadImage(#Image, "E.bmp")
WriteImage(0, 0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
The happiness is a road...
Not a destination
Not a destination
Re: Create my own font with lib VECTOR
Yep,
looking to this demo code "Sprite_using_CSS_Sheet_BF_delays_presetted.pb"
A other little code for creating sheets you found also
For BucketFill_advanced, a complete book, for handling all abilities is needed, but this is a lot of work and my english not good
looking to this demo code "Sprite_using_CSS_Sheet_BF_delays_presetted.pb"
A other little code for creating sheets you found also
For BucketFill_advanced, a complete book, for handling all abilities is needed, but this is a lot of work and my english not good
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
Waooouuuh WALBUS !!!!
I have not all understand again
But i have found this code, my E is very perfect
But the window can't be resized
I continue to search a resized window
I have not all understand again
But i have found this code, my E is very perfect
But the window can't be resized
I continue to search a resized window
The happiness is a road...
Not a destination
Not a destination
Re: Create my own font with lib VECTOR
This function handle your font picture as sprite
For other font colors it is available you must reduce or remove the function "SetColorDistanceSpriteMask_BF"
The function can handle also JPG compressed images
You must not have SVG for this, the function get automatically the image background color from pos 0,0 and make this color invisible
Enhance the code for resizing the window or canvas, BF handle internal all other full automatic, how ever you want
You found in the download packet code samples for output directly on images and on canvas
You can give the function simple a canvas ID for output or a image ID
For other font colors it is available you must reduce or remove the function "SetColorDistanceSpriteMask_BF"
The function can handle also JPG compressed images
You must not have SVG for this, the function get automatically the image background color from pos 0,0 and make this color invisible
Enhance the code for resizing the window or canvas, BF handle internal all other full automatic, how ever you want
You found in the download packet code samples for output directly on images and on canvas
You can give the function simple a canvas ID for output or a image ID
Last edited by walbus on Wed Aug 23, 2017 1:05 pm, edited 2 times in total.
- Kwai chang caine
- Always Here
- Posts: 5342
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: Create my own font with lib VECTOR
@Wilbert
I continue also my search in your way
I have found a site for convert my E in SVG
https://convertio.co/fr/bmp-svg/
But i'm sad because, i have read the answer of KEYA
http://www.purebasic.fr/english/viewtop ... 73#p498773
I'm like a cunt with my E.svg now ....
In fact the TTF is a little bit like lib vector no ???
I continue also my search in your way
I have found a site for convert my E in SVG
https://convertio.co/fr/bmp-svg/
But i'm sad because, i have read the answer of KEYA
http://www.purebasic.fr/english/viewtop ... 73#p498773
I'm like a cunt with my E.svg now ....
In fact the TTF is a little bit like lib vector no ???
The happiness is a road...
Not a destination
Not a destination