COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-25-2018, 05:04 PM   #1
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default ITextControl font?

How does one select a different font for an ITextControl?
Thanks
Guod3 is offline   Reply With Quote
Old 02-25-2018, 06:46 PM   #2
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 338
Default

With ITextControl, you need to set everything up with the IText that you pass to the control. So, you would do something like this...
Code:
IText lFontWhite(20, &COLOR_WHITE, "Futura", IText::kStyleNormal, IText::kAlignCenter, IText::kAlignMiddle, 0, IText::EQuality::kQualityClearType, &COLOR_BLACK);
pGraphics->AttachControl(new ITextControl(this, thisRect, &lFontWhite, "something"));
You just need to make sure that whatever font you use will be installed on the users' computers. If it is not a system font, you need to include it in the installer.
__________________
Website: LVC-Audio
random_id is online now   Reply With Quote
Old 02-25-2018, 08:46 PM   #3
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Thanks. Following your example I'm finding the font property not changing, although most of the other properties reflect changes made to them. I'm after a fixed spaced font such as Terminal which would be on every system. Is there anything else I need to do to make the fonts available?
(PS the code snippet has one too many alignment properties)
Guod3 is offline   Reply With Quote
Old 02-26-2018, 04:20 AM   #4
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

The only fonts I can display in my plugin are the ones in the ITextControl example plugin. The control panel fonts dialog has lots of fonts but they seem to be installed already.
Guod3 is offline   Reply With Quote
Old 02-26-2018, 12:06 PM   #5
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Have you looked into using Cairo fonts? I'm bundling a custom font in the resources of my plug and can use that across all my controls. It's possible to use more than one font as well with extra work. Here's a thread about it:

https://forum.cockos.com/showthread.php?t=197181

My code on the last post can be optimised, as it's creating the text path twice - once for the outline and once for the fill, where it only needs to create the path once and instead of the first cairo_stroke use cairo_stroke_preserve.
Bobflip is online now   Reply With Quote
Old 02-26-2018, 01:58 PM   #6
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 338
Default

Quote:
Originally Posted by Guod3 View Post
Thanks. Following your example I'm finding the font property not changing, although most of the other properties reflect changes made to them. I'm after a fixed spaced font such as Terminal which would be on every system. Is there anything else I need to do to make the fonts available?
(PS the code snippet has one too many alignment properties)
Sorry, I modified the code for vertical alignment (which I am not really using anyway).

You just need to make sure the font is installed on the computer, and the name you are using is the same name as the font. If there are any problems with the name, it will default back to a system font. I forget what that is for a Mac/PC.
__________________
Website: LVC-Audio
random_id is online now   Reply With Quote
Old 02-26-2018, 04:42 PM   #7
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Quote:
Originally Posted by Bobflip View Post
Have you looked into using Cairo fonts?
I definitely want to use cairo. ATM the Youlean framework is crashing with my current plugin, so I'm kind of waiting for some clarity on that...
Guod3 is offline   Reply With Quote
Old 02-26-2018, 04:47 PM   #8
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Ah, of course, I remember your trouble from the other thread. There was a new update released since then, did you try that one? It sorted my Bitwig crashes out.
Bobflip is online now   Reply With Quote
Old 02-26-2018, 04:50 PM   #9
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Quote:
Originally Posted by random_id View Post
You just need to make sure the font is installed on the computer, and the name you are using is the same name as the font. If there are any problems with the name, it will default back to a system font. I forget what that is for a Mac/PC.
I've looked at the control panel/fonts dialog (Windows 7). When I inspect a sample of a font there is a greyed out button "install", so I'm assuming its installed already. Is the name you use the same as the caption of the font icon? I've noticed there is a font filename in the properties that is different and has an extension e.g *.fon
Guod3 is offline   Reply With Quote
Old 02-26-2018, 05:44 PM   #10
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Quote:
Originally Posted by Bobflip View Post
Ah, of course, I remember your trouble from the other thread. There was a new update released since then, did you try that one? It sorted my Bitwig crashes out.
I was looking for a confirmation of a new release since the weekend, expected to hear on the Youlean thread. I must have missed it. Great news.
Do you use the Github desktop app? Does it help with updating your working copy of the framework? I installed it and used it to get the Youlean framework onto my computer. I'm a long time TortoiseSVN user and can be a bit slow to adopt new tools unless there are upsides that are obvious to me. Manually cloning the folder tree then moving my sources by hand seems a bit daft. I'm sure a better way is there for me to use!
Guod3 is offline   Reply With Quote
Old 02-26-2018, 05:54 PM   #11
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Quote:
Originally Posted by Guod3 View Post
I was looking for a confirmation of a new release since the weekend, expected to hear on the Youlean thread. I must have missed it. Great news.
Do you use the Github desktop app? Does it help with updating your working copy of the framework? I installed it and used it to get the Youlean framework onto my computer. I'm a long time TortoiseSVN user and can be a bit slow to adopt new tools unless there are upsides that are obvious to me. Manually cloning the folder tree then moving my sources by hand seems a bit daft. I'm sure a better way is there for me to use!
Ah yeah, was uploaded Saturday... I was watching like a hawk as I want to get my pluging update released asap, haha.

I don't use the Github app, you have to pay a monthly fee to get a private repository and I didn't fancy putting my code up publically! It certainly looks handy to be able to only download the changed files though, and I think it's possible on the free one, but haven't tried setting that up yet. I only just set a watch on Youlean's framework a few days ago! Usually I go the inefficient path of downloading the new framework and copying my folders, though occasionally I've looked at the change list and made the same tweaks to the framework's files on my hard drive.
Bobflip is online now   Reply With Quote
Old 02-26-2018, 09:43 PM   #12
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

It should be possible to update the local copy automatically merging Youlean's changes with your own code. At the touch of a button. TortioseSVN works this way.
If you get into version control and repositories (which I recommend) there are repo providers which offer free, private hosting. I have used assembla https://www.assembla.com/home I have had my own free, private SVN repos (they do Git as well) hosted there for some 5 years. My account says Free Repo Plus and it seems to offer 1GB of space (I'm using 20MB). Having said all this I hope I'm not just on a legacy product which is no longer offered to new users! If so, there will no doubt be other hosts that have a freebee accounts for small users.
Guod3 is offline   Reply With Quote
Old 02-27-2018, 06:05 AM   #13
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Yeah, should definitely be possible, I just personally haven't made any roads towards setting it up. Looks like Assembla don't have a free version any more, but something like that does look handy.
Bobflip is online now   Reply With Quote
Old 03-06-2018, 02:47 AM   #14
Guod3
Human being with feelings
 
Guod3's Avatar
 
Join Date: Jan 2008
Posts: 506
Default

Quote:
Originally Posted by Bobflip View Post
Have you looked into using Cairo fonts? I'm bundling a custom font in the resources of my plug and can use that across all my controls. It's possible to use more than one font as well with extra work. Here's a thread about it:

https://forum.cockos.com/showthread.php?t=197181

My code on the last post can be optimised, as it's creating the text path twice - once for the outline and once for the fill, where it only needs to create the path once and instead of the first cairo_stroke use cairo_stroke_preserve.
Having success using this recipe!!! I can use any font now. I simplified the text rendering to single layer. Otherwise I noticed the speed slowdown (my patch editor librarian view shows groups of 128 patches, thats a lot of text!)
Still don't know why my font choice was so limited with WDL-OL, but its great to be using Cairo graphics now, it is certainly very powerful for rich graphics.
Guod3 is offline   Reply With Quote
Old 03-06-2018, 03:27 AM   #15
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 316
Default

Good work! Btw - The speed is better when you compile for release rather than debug.
Bobflip is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.