Hello, is there a way to adjust the properties of the loaded font?
I need more line-height..
Cya Dirk
LoadFont and line-height
Re: LoadFont and line-height
Can you provide a small piece of code that illustrates your problem?
Re: LoadFont and line-height
i dont think he has a problem, i think he is asking how to change line-height of a font
this is a css atribute , and long as i know you can not do with spiderbasci commands
have to tweak css directly
this is a css atribute , and long as i know you can not do with spiderbasci commands
have to tweak css directly
Christos
Re: LoadFont and line-height
line-height always refers to the element that uses the font; not to the font itself.plouf wrote:i think he is asking how to change line-height of a font this is a css atribute
As there are many gadgets, I asked for a concrete example.
Furthermore, a sample code makes it easier for us to help.
yes, that is correctplouf wrote:and long as i know you can not do with spiderbasci commands have to tweak css directly
Re: LoadFont and line-height
Last time I needed this I just used this:
Code: Select all
OpenWindow(0, 100, 100, 400, 400, "Line-Height")
LoadFont(0, "Arial", 50)
SetGadgetFont(#PB_Default, FontID(0))
TextGadget(0, 10, 10, 380, 380, "<div style='line-height:150%'>Lorem ipsum dolor sit amet, consetetur sadipscing elitr</div>")
Re: LoadFont and line-height
That's OK, but remember that you are adding an unnecessary div element to the TextGadget (span element). When changing text with SetGadgetText() you must always remember that the div element is included.munfraid wrote:Last time I needed this I just used this:Code: Select all
[...] TextGadget(0, 10, 10, 380, 380, "<div style='line-height:150%'>Lorem ipsum dolor sit amet, consetetur sadipscing elitr</div>")
For this reason I find the following solution more appropriate:
Code: Select all
EnableExplicit
Procedure SetGadgetLineHeight(Gadget, LineHeight.s)
If IsGadget(Gadget) = 0 : ProcedureReturn : EndIf
Protected GID = GadgetID(Gadget)
Select GadgetType(Gadget)
Case #PB_GadgetType_Text
! $(v_gid.gadget).css("line-height", v_lineheight);
EndSelect
EndProcedure
OpenWindow(0, 100, 100, 400, 400, "Line-Height")
LoadFont(0, "Arial", 50)
SetGadgetFont(#PB_Default, FontID(0))
TextGadget(0, 10, 10, 380, 380, "Lorem ipsum dolor sit amet, consetetur sadipscing elitr")
SetGadgetLineHeight(0, "150%")
Re: LoadFont and line-height
That's much better indeed. Thanks, Peter!
-
- Posts: 333
- Joined: Fri Sep 22, 2017 7:02 am
Re: LoadFont and line-height
Hello Peter, great, thank you very much! This is exactly what I need.
I use a textgadget to display some text. When I use my own font (bigger than the standard 13px font) the line height stays at 13px and the text is squeezed too much.
I use a textgadget to display some text. When I use my own font (bigger than the standard 13px font) the line height stays at 13px and the text is squeezed too much.