Page 1 of 2
Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 5:41 pm
by bbanelli
Greetings to all,
in order to use VectorFont drawing, 32 bit color is required. However, ColorRequester() only returns 24 bit color. What is the procedure to add transparency to that value?
TIA!
Bruno
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 5:52 pm
by Keya
Code: Select all
color24.l = RGB($11,$22,$33) ;11 22 33 00 \
color32.l = RGBA($11,$22,$33,$FF) ;11 22 33 FF / ShowMemory(@colorn,4)
therefore:
Code: Select all
color32 = color24 | $FF000000 ;FF=opaque - 0=transparent

Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 6:32 pm
by bbanelli
Keya wrote:Code: Select all
color24.l = RGB($11,$22,$33) ;11 22 33 00 \
color32.l = RGBA($11,$22,$33,$FF) ;11 22 33 FF / ShowMemory(@colorn,4)
therefore:
Code: Select all
color32 = color24 | $FF000000 ;FF=opaque - 0=transparent

Thx for the tip, Keya, seems to be working great!
BTW, why can't I load this particular font to Vector library?
http://www.fontfabric.com/code-free-font-3/ Same thing is for Trajan Pro, Charlemagne Std and many other Windows fonts... Fonts get loaded properly but simply won't be printed at all.
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 6:49 pm
by wilbert
bbanelli wrote:BTW, why can't I load this particular font to Vector library?
It think that the Vector library maybe currently only supports ttf fonts and not otf fonts.
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 7:04 pm
by bbanelli
wilbert wrote:bbanelli wrote:BTW, why can't I load this particular font to Vector library?
It think that the Vector library maybe currently only supports ttf fonts and not otf fonts.
Perhaps. But that doesn't seem to be the case for mistral Regular, Lucida and some other OpenType work well.
Then I thought that maybe the fonts without "Designed for" (language) types cannot be displays. Isn't the case - no pattern there. Font embeddability makes no difference as well - some editable fonts won't display as well.
Can someone confirm that only TTF are supported? Though that would be really really bad...

I appreciate any assistance of whatsoever!
With my best,
Bruno
Edit: after converting font to TTF with online converter, it seems to be working properly. Maybe this should be documented?
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 7:16 pm
by srod
Yes I agree this needs clearing up. Exactly what type of fonts can we use with the vector lib? I tried the OT font as well and can confirm your results.
Best ask Fred / Freak for clarification I reckon.
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 7:33 pm
by bbanelli
I have also noticed there is huge difference between drawing quality of VectorText and VectorParagraph functions. You can see examples
here. Is this only me or it is a bug of a sort? Sam font, same settings, only difference is that left picture uses DrawVectorText() and right picture uses DrawVectorParagraph(). This seems to happen only on Windows, Linux version looks fine...
Code: Select all
Enumeration
#ImageID
EndEnumeration
UsePNGImageDecoder()
UsePNGImageEncoder()
CreateImage(#ImageID, 640, 640)
If FontRequester("",0,0)
LoadFont(100,SelectedFontName(),SelectedFontSize(),SelectedFontStyle())
Else
End
EndIf
If StartVectorDrawing(ImageVectorOutput((#ImageID)))
VectorFont(FontID(100), SelectedFontSize())
VectorSourceColor(RGBA(255,255,255,255))
MovePathCursor(0, 0)
Text$ = "ABCDEFGH" + #CRLF$ + "IJKLMNOP" + #CRLF$ + "RSTUVZ" + #CRLF$ + "čćžšđČĆŽĐ"
DrawVectorText(Text$)
; DrawVectorParagraph(Text$, 640, 640, #PB_VectorParagraph_Left)
StopVectorDrawing()
SaveImage(#ImageID, "preview.png", #PB_ImagePlugin_PNG, #PB_Ignore, 32)
EndIf
Edit: I've also discovered that CODE font (from the link I've posted above) works without a problem on Linux.
So, it it safe to conclude that VectorParagraph and inability to properly load some fonts should be reported as Windows vector library bugs?
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 7:49 pm
by srod
I can't see much difference with your images... but I can when I run your program. DrawVectorParagraph() seems sharper.
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 8:04 pm
by bbanelli
srod wrote:I can't see much difference with your images... but I can when I run your program. DrawVectorParagraph() seems sharper.
Zoom in and check the curves. It's like those with DrawVectorParagraph() are not anti-aliased or something...
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 8:15 pm
by srod
Got it yes.
I seem to recall similar issues with alpha blended text with the 2d drawing lib and am not sure that was ever fixed? Might be wrong though.
Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 8:20 pm
by Keya
DrawVectorParagraph() vs DrawVectorText(), Arial Bold 16 @ Win32, zoomed in. Interesting differences! They both beat DrawText() though

Re: Get RGBA from ColorRequester?
Posted: Thu Feb 25, 2016 8:34 pm
by heartbone
Keya wrote:DrawVectorParagraph() vs DrawVectorText(), Arial Bold 16 @ Win32, zoomed in. Interesting differences! They both beat DrawText() though

The text on the left looks suspiciously like Microsoft® ClearType technology.
It might prove interesting to check for the differences in Linux, or turn off the functionality in Windows®.
Re: Get RGBA from ColorRequester?
Posted: Fri Feb 26, 2016 9:12 am
by DoubleDutch
Yes, the colour being added looks like it is cleartype. Doesn't look good if printed as it adds colour to the edges of fonts.
Re: Get RGBA from ColorRequester?
Posted: Fri Feb 26, 2016 4:17 pm
by Michael Vogel
Okay, drifting a little bit away from the topic - but I wouldn't say, windows is the (only) reason for the color effects above, Purebasic changed it's behaviour to draw text somewhen (I believe it was between version 4.31 and 4.61 or so). Before that, I did never see such issues.
Code: Select all
OpenWindow(0,0,0,480,200,"")
CreateImage(0,480,200,32)
LoadFont(0,"Arial",-60)
StartDrawing(ImageOutput(0))
Box(0,0,240,200,#White)
Title.s="Test Hanburg"
DrawingMode(#PB_2DDrawing_AlphaBlend); : (
;DrawingMode(#PB_2DDrawing_Default); : )
DrawingFont(FontID(0))
DrawText(20,10,Title,$ff000000,$ffffffff)
DrawText(20,100,Title,$ffffffff,$ff000000)
StopDrawing()
ImageGadget(0,0,0,0,0,ImageID(0))
HideWindow(0,0)
Repeat
Event=WaitWindowEvent()
If Event=#WM_LBUTTONDOWN
SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0)
EndIf
Until Event=#PB_Event_CloseWindow Or Event=#WM_CHAR
Re: Get RGBA from ColorRequester?
Posted: Fri Feb 26, 2016 4:58 pm
by heartbone
Michael Vogel wrote:Okay, drifting a little bit away from the topic - but I wouldn't say, windows is the (only) reason for the color effects above, Purebasic changed it's behaviour to draw text somewhen (I believe it was between version 4.31 and 4.61 or so). Before that, I did never see such issues.
Good demo. What's up with the -60 point size?
Those color artifacts that you see are 100% the result of
Microsoft® ClearType technology.
It's supposed to work best with a white background, but your demo indicates otherwise for larger sized fonts.
Turn off ClearType, and the produced bitmaps are all grayscale.
I'm quite sure that when I reboot to Linux and run your code, the produced bitmaps will be grayscale.
It looks as if the application can have control over the font rendering, whether ClearType is used or not.
"There are many examples where applications decide one way or another to use rendering other than the system default—just as applications that choose to use different fonts, colors, sizes, or other text attributes. The most typical example is in applications that wish to have reproducible layout and flow of documents. By being specific about which way to render text, the applications can be certain of how text will flow across different PCs. Another common example, as mentioned above, is Print Preview where the ability to properly render representations of higher resolution output, particularly for small text sizes, is much improved. We recognize that for some it is counter-intuitive that an aspect viewed as a “display” property is something that applications can choose to “over-ride”. We’ve designed rendering so that the default case is to respect the setting, but applications, including Windows itself, might have elements that require explicit rendering techniques.
Although each application can make the choice on a per-font basis of which rendering to use, the majority of applications choose the default rendering. Therefore, making the decision to change the default for Windows Vista was not taken lightly. The trends in the hardware displays were strongly showing a rapid movement from CRTs to LCD-based displays as we have shown in earlier blog posts based on the Windows XP and Windows Vista real-world telemetry. Even though there were still CRTs in use, feedback from Windows XP customers was positive on the quality of ClearType rendering on CRTs. After we made the choice, the feedback on the decision to enable ClearType as the default for Windows Vista was overwhelmingly positive."
A flag into
LoadFont()?
DrawText()?